-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Closed
Copy link
Labels
comp-codegenIssue is related to code generatorIssue is related to code generatorcomp-springIssue is related to Spring projects supportIssue is related to Spring projects supportctg-enhancementNew feature, improvement or change requestNew feature, improvement or change request
Description
Description
Consider generating Spring integration tests for the following controller method
@RestController
@RequestMapping(value = "/api")
public class OrderController {
private OrderService orderService;
public OrderController(OrderService orderService) {
this.orderService = orderService;
}
@PostMapping(path = "/isMajorityExpensive")
public boolean isMajorityExpensive(@RequestParam int threshold) {
return orderService.isMajorityExpensive(threshold);
}
}where service contains the function
public boolean isMajorityExpensive(int threshold)Expected behavior
Generated code looks like as follows:
@Test
public void testIsMajorityExpensive() throws Exception {
UriComponentsBuilder uriComponentsBuilder = fromPath("/api/isMajorityExpensive");
Object[] values = new Object[] { 4097 };
UriComponentsBuilder uriComponentsBuilder1 = uriComponentsBuilder.queryParam("threshold", values);
String urlTemplate = uriComponentsBuilder1.toUriString();
Object[] uriVariables = {};
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = post(urlTemplate, uriVariables);
ResultActions actual = mockMvc.perform(mockHttpServletRequestBuilder);
actual.andDo(print());
actual.andExpect((status()).is(200));
actual.andExpect((content()).string("false"));
}Context
Current appearance is worse:
@Test
public void testIsMajorityExpensive() throws Exception {
UriComponentsBuilder uriComponentsBuilder = fromPath("/api/isMajorityExpensive");
List list = new ArrayList();
list.add(4097);
UriComponentsBuilder uriComponentsBuilder1 = uriComponentsBuilder.queryParam("threshold", ((Collection) list));
String string = uriComponentsBuilder1.toUriString();
Object[] objectArray = {};
MockHttpServletRequestBuilder mockHttpServletRequestBuilder = post(string, objectArray);
ResultActions actual = mockMvc.perform(mockHttpServletRequestBuilder);
actual.andDo(print());
actual.andExpect((status()).is(200));
actual.andExpect((content()).string("false"));
}Metadata
Metadata
Assignees
Labels
comp-codegenIssue is related to code generatorIssue is related to code generatorcomp-springIssue is related to Spring projects supportIssue is related to Spring projects supportctg-enhancementNew feature, improvement or change requestNew feature, improvement or change request
Type
Projects
Status
Done