Java @Service组件中POST请求的Junit
我已经编写了一个包含POST请求的方法。这是在包含@Service注释的Java文件中编写的,而不是在@RestController中编写的。 这是一个springBoot项目,并使用rector WebClient调用POSTJava @Service组件中POST请求的Junit,java,spring-boot,junit,reactive-programming,project-reactor,Java,Spring Boot,Junit,Reactive Programming,Project Reactor,我已经编写了一个包含POST请求的方法。这是在包含@Service注释的Java文件中编写的,而不是在@RestController中编写的。 这是一个springBoot项目,并使用rector WebClient调用POST public void createCustomer(Employee employee) { WebClient client; URI uri = URI.create("invet/service/test?_action=create");
public void createCustomer(Employee employee) {
WebClient client;
URI uri = URI.create("invet/service/test?_action=create");
this.client.post()
.uri(uriBuilder -> uriBuilder
.path(uri.getPath())
.query(uri.getQuery()).build())
.bodyValue(employee)
.headers(httpHeaders -> httpHeaders.addAll(getHeaders()))
.accept(APPLICATION_JSON)
.exchange()
.flatMap(response -> {
if (response.statusCode().isError())
return Mono.error(new myException("Error while creating employee"));
return response.bodyToMono(Response.class);
}).block();
}}
有人能帮我写下Junit吗?使用mokito/powermockito等。文档中用不同的解决方案解释了一切