method2testcases
stringlengths
118
6.63k
### Question: SwaggerBasePathRewritingFilter extends SendResponseFilter { @Override public boolean shouldFilter() { return RequestContext.getCurrentContext().getRequest().getRequestURI().endsWith(Swagger2Controller.DEFAULT_URL); } SwaggerBasePathRewritingFilter(); @Override String filterType(); @Override int filterOrder(); @Override boolean shouldFilter(); @Override Object run(); static byte[] gzipData(String content); }### Answer: @Test public void shouldFilter_on_default_swagger_url() { MockHttpServletRequest request = new MockHttpServletRequest("GET", DEFAULT_URL); RequestContext.getCurrentContext().setRequest(request); assertTrue(filter.shouldFilter()); } @Test public void shouldFilter_on_default_swagger_url_with_param() { MockHttpServletRequest request = new MockHttpServletRequest("GET", DEFAULT_URL); request.setParameter("debug", "true"); RequestContext.getCurrentContext().setRequest(request); assertTrue(filter.shouldFilter()); } @Test public void shouldNotFilter_on_wrong_url() { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/management/info"); RequestContext.getCurrentContext().setRequest(request); assertFalse(filter.shouldFilter()); }
### Question: SwaggerBasePathRewritingFilter extends SendResponseFilter { @Override public Object run() { RequestContext context = RequestContext.getCurrentContext(); context.getResponse().setCharacterEncoding("UTF-8"); String rewrittenResponse = rewriteBasePath(context); if (context.getResponseGZipped()) { try { context.setResponseDataStream(new ByteArrayInputStream(gzipData(rewrittenResponse))); } catch (IOException e) { log.error("Swagger-docs filter error", e); } } else { context.setResponseBody(rewrittenResponse); } return null; } SwaggerBasePathRewritingFilter(); @Override String filterType(); @Override int filterOrder(); @Override boolean shouldFilter(); @Override Object run(); static byte[] gzipData(String content); }### Answer: @Test public void run_on_valid_response() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/service1" + DEFAULT_URL); RequestContext context = RequestContext.getCurrentContext(); context.setRequest(request); MockHttpServletResponse response = new MockHttpServletResponse(); context.setResponseGZipped(false); context.setResponse(response); InputStream in = IOUtils.toInputStream("{\"basePath\":\"/\"}", StandardCharsets.UTF_8); context.setResponseDataStream(in); filter.run(); assertEquals("UTF-8", response.getCharacterEncoding()); assertEquals("{\"basePath\":\"/service1\"}", context.getResponseBody()); }
### Question: Employee { public String getName() { return name; } Employee(Integer id, String name, Double salary); Integer getId(); void setId(Integer id); String getName(); void setName(String name); Double getSalary(); void setSalary(Double salary); void salaryIncrement(Double percentage); String toString(); }### Answer: @Test public void whenStreamMapping_thenGetMap() { Map<Character, List<Integer>> idGroupedByAlphabet = empList.stream().collect( Collectors.groupingBy(e -> new Character(e.getName().charAt(0)), Collectors.mapping(Employee::getId, Collectors.toList()))); assertEquals(idGroupedByAlphabet.get('B').get(0), new Integer(2)); assertEquals(idGroupedByAlphabet.get('J').get(0), new Integer(1)); assertEquals(idGroupedByAlphabet.get('M').get(0), new Integer(3)); } @Test public void whenStreamGroupingAndReducing_thenGetMap() { Comparator<Employee> byNameLength = Comparator.comparing(Employee::getName); Map<Character, Optional<Employee>> longestNameByAlphabet = empList.stream().collect( Collectors.groupingBy(e -> new Character(e.getName().charAt(0)), Collectors.reducing(BinaryOperator.maxBy(byNameLength)))); assertEquals(longestNameByAlphabet.get('B').get().getName(), "Bill Gates"); assertEquals(longestNameByAlphabet.get('J').get().getName(), "Jeff Bezos"); assertEquals(longestNameByAlphabet.get('M').get().getName(), "Mark Zuckerberg"); } @Test public void whenSortStream_thenGetSortedStream() { List<Employee> employees = empList.stream() .sorted((e1, e2) -> e1.getName().compareTo(e2.getName())) .collect(Collectors.toList()); assertEquals(employees.get(0).getName(), "Bill Gates"); assertEquals(employees.get(1).getName(), "Jeff Bezos"); assertEquals(employees.get(2).getName(), "Mark Zuckerberg"); } @Test public void whenStreamGroupingBy_thenGetMap() { Map<Character, List<Employee>> groupByAlphabet = empList.stream().collect( Collectors.groupingBy(e -> new Character(e.getName().charAt(0)))); assertEquals(groupByAlphabet.get('B').get(0).getName(), "Bill Gates"); assertEquals(groupByAlphabet.get('J').get(0).getName(), "Jeff Bezos"); assertEquals(groupByAlphabet.get('M').get(0).getName(), "Mark Zuckerberg"); }
### Question: Employee { public Double getSalary() { return salary; } Employee(Integer id, String name, Double salary); Integer getId(); void setId(Integer id); String getName(); void setName(String name); Double getSalary(); void setSalary(Double salary); void salaryIncrement(Double percentage); String toString(); }### Answer: @Test public void whenStreamReducing_thenGetValue() { Double percentage = 10.0; Double salIncrOverhead = empList.stream().collect(Collectors.reducing( 0.0, e -> e.getSalary() * percentage / 100, (s1, s2) -> s1 + s2)); assertEquals(salIncrOverhead, 60000.0, 0); } @Test public void whenFilterEmployees_thenGetFilteredStream() { Integer[] empIds = { 1, 2, 3, 4 }; List<Employee> employees = Stream.of(empIds) .map(employeeRepository::findById) .filter(e -> e != null) .filter(e -> e.getSalary() > 200000) .collect(Collectors.toList()); assertEquals(Arrays.asList(arrayOfEmps[2]), employees); } @Test public void whenFindFirst_thenGetFirstEmployeeInStream() { Integer[] empIds = { 1, 2, 3, 4 }; Employee employee = Stream.of(empIds) .map(employeeRepository::findById) .filter(e -> e != null) .filter(e -> e.getSalary() > 100000) .findFirst() .orElse(null); assertEquals(employee.getSalary(), new Double(200000)); } @Test public void whenStreamCount_thenGetElementCount() { Long empCount = empList.stream() .filter(e -> e.getSalary() > 200000) .count(); assertEquals(empCount, new Long(1)); } @Test public void whenFindMax_thenGetMaxElementFromStream() { Employee maxSalEmp = empList.stream() .max(Comparator.comparing(Employee::getSalary)) .orElseThrow(NoSuchElementException::new); assertEquals(maxSalEmp.getSalary(), new Double(300000.0)); }
### Question: TshirtSizeController { @RequestMapping(value ="convertSize", method = RequestMethod.GET) public int convertSize(@RequestParam(value = "label") final String label, @RequestParam(value = "countryCode", required = false) final String countryCode) { return service.convertSize(label, countryCode); } TshirtSizeController(SizeConverterService service); @RequestMapping(value ="convertSize", method = RequestMethod.GET) int convertSize(@RequestParam(value = "label") final String label, @RequestParam(value = "countryCode", required = false) final String countryCode); }### Answer: @Test void whenConvertSize_thenOK() { String label = "S"; String countryCode = "fr"; int result = 36; when(service.convertSize(label, countryCode)).thenReturn(result); int actual = tested.convertSize(label, countryCode); assertEquals(actual, result); }
### Question: Order { public Order id(Long id) { this.id = id; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getPetId(); void setPetId(Long petId); Order quantity(Integer quantity); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getQuantity(); void setQuantity(Integer quantity); Order shipDate(OffsetDateTime shipDate); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) OffsetDateTime getShipDate(); void setShipDate(OffsetDateTime shipDate); Order status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "Order Status") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); Order complete(Boolean complete); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Boolean getComplete(); void setComplete(Boolean complete); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_PET_ID; static final String JSON_PROPERTY_QUANTITY; static final String JSON_PROPERTY_SHIP_DATE; static final String JSON_PROPERTY_STATUS; static final String JSON_PROPERTY_COMPLETE; }### Answer: @Test public void idTest() { }
### Question: Order { public Order petId(Long petId) { this.petId = petId; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getPetId(); void setPetId(Long petId); Order quantity(Integer quantity); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getQuantity(); void setQuantity(Integer quantity); Order shipDate(OffsetDateTime shipDate); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) OffsetDateTime getShipDate(); void setShipDate(OffsetDateTime shipDate); Order status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "Order Status") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); Order complete(Boolean complete); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Boolean getComplete(); void setComplete(Boolean complete); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_PET_ID; static final String JSON_PROPERTY_QUANTITY; static final String JSON_PROPERTY_SHIP_DATE; static final String JSON_PROPERTY_STATUS; static final String JSON_PROPERTY_COMPLETE; }### Answer: @Test public void petIdTest() { }
### Question: Order { public Order quantity(Integer quantity) { this.quantity = quantity; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getPetId(); void setPetId(Long petId); Order quantity(Integer quantity); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getQuantity(); void setQuantity(Integer quantity); Order shipDate(OffsetDateTime shipDate); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) OffsetDateTime getShipDate(); void setShipDate(OffsetDateTime shipDate); Order status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "Order Status") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); Order complete(Boolean complete); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Boolean getComplete(); void setComplete(Boolean complete); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_PET_ID; static final String JSON_PROPERTY_QUANTITY; static final String JSON_PROPERTY_SHIP_DATE; static final String JSON_PROPERTY_STATUS; static final String JSON_PROPERTY_COMPLETE; }### Answer: @Test public void quantityTest() { }
### Question: Order { public Order shipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getPetId(); void setPetId(Long petId); Order quantity(Integer quantity); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getQuantity(); void setQuantity(Integer quantity); Order shipDate(OffsetDateTime shipDate); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) OffsetDateTime getShipDate(); void setShipDate(OffsetDateTime shipDate); Order status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "Order Status") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); Order complete(Boolean complete); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Boolean getComplete(); void setComplete(Boolean complete); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_PET_ID; static final String JSON_PROPERTY_QUANTITY; static final String JSON_PROPERTY_SHIP_DATE; static final String JSON_PROPERTY_STATUS; static final String JSON_PROPERTY_COMPLETE; }### Answer: @Test public void shipDateTest() { }
### Question: Order { public Order status(StatusEnum status) { this.status = status; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getPetId(); void setPetId(Long petId); Order quantity(Integer quantity); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getQuantity(); void setQuantity(Integer quantity); Order shipDate(OffsetDateTime shipDate); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) OffsetDateTime getShipDate(); void setShipDate(OffsetDateTime shipDate); Order status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "Order Status") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); Order complete(Boolean complete); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Boolean getComplete(); void setComplete(Boolean complete); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_PET_ID; static final String JSON_PROPERTY_QUANTITY; static final String JSON_PROPERTY_SHIP_DATE; static final String JSON_PROPERTY_STATUS; static final String JSON_PROPERTY_COMPLETE; }### Answer: @Test public void statusTest() { }
### Question: Order { public Order complete(Boolean complete) { this.complete = complete; return this; } Order id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Order petId(Long petId); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PET_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getPetId(); void setPetId(Long petId); Order quantity(Integer quantity); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_QUANTITY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getQuantity(); void setQuantity(Integer quantity); Order shipDate(OffsetDateTime shipDate); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_SHIP_DATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) OffsetDateTime getShipDate(); void setShipDate(OffsetDateTime shipDate); Order status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "Order Status") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); Order complete(Boolean complete); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_COMPLETE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Boolean getComplete(); void setComplete(Boolean complete); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_PET_ID; static final String JSON_PROPERTY_QUANTITY; static final String JSON_PROPERTY_SHIP_DATE; static final String JSON_PROPERTY_STATUS; static final String JSON_PROPERTY_COMPLETE; }### Answer: @Test public void completeTest() { }
### Question: User { public User id(Long id) { this.id = id; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getUsername(); void setUsername(String username); User firstName(String firstName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getFirstName(); void setFirstName(String firstName); User lastName(String lastName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getLastName(); void setLastName(String lastName); User email(String email); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getEmail(); void setEmail(String email); User password(String password); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPassword(); void setPassword(String password); User phone(String phone); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPhone(); void setPhone(String phone); User userStatus(Integer userStatus); @javax.annotation.Nullable @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getUserStatus(); void setUserStatus(Integer userStatus); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_USERNAME; static final String JSON_PROPERTY_FIRST_NAME; static final String JSON_PROPERTY_LAST_NAME; static final String JSON_PROPERTY_EMAIL; static final String JSON_PROPERTY_PASSWORD; static final String JSON_PROPERTY_PHONE; static final String JSON_PROPERTY_USER_STATUS; }### Answer: @Test public void idTest() { }
### Question: User { public User username(String username) { this.username = username; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getUsername(); void setUsername(String username); User firstName(String firstName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getFirstName(); void setFirstName(String firstName); User lastName(String lastName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getLastName(); void setLastName(String lastName); User email(String email); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getEmail(); void setEmail(String email); User password(String password); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPassword(); void setPassword(String password); User phone(String phone); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPhone(); void setPhone(String phone); User userStatus(Integer userStatus); @javax.annotation.Nullable @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getUserStatus(); void setUserStatus(Integer userStatus); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_USERNAME; static final String JSON_PROPERTY_FIRST_NAME; static final String JSON_PROPERTY_LAST_NAME; static final String JSON_PROPERTY_EMAIL; static final String JSON_PROPERTY_PASSWORD; static final String JSON_PROPERTY_PHONE; static final String JSON_PROPERTY_USER_STATUS; }### Answer: @Test public void usernameTest() { }
### Question: User { public User firstName(String firstName) { this.firstName = firstName; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getUsername(); void setUsername(String username); User firstName(String firstName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getFirstName(); void setFirstName(String firstName); User lastName(String lastName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getLastName(); void setLastName(String lastName); User email(String email); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getEmail(); void setEmail(String email); User password(String password); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPassword(); void setPassword(String password); User phone(String phone); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPhone(); void setPhone(String phone); User userStatus(Integer userStatus); @javax.annotation.Nullable @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getUserStatus(); void setUserStatus(Integer userStatus); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_USERNAME; static final String JSON_PROPERTY_FIRST_NAME; static final String JSON_PROPERTY_LAST_NAME; static final String JSON_PROPERTY_EMAIL; static final String JSON_PROPERTY_PASSWORD; static final String JSON_PROPERTY_PHONE; static final String JSON_PROPERTY_USER_STATUS; }### Answer: @Test public void firstNameTest() { }
### Question: User { public User lastName(String lastName) { this.lastName = lastName; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getUsername(); void setUsername(String username); User firstName(String firstName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getFirstName(); void setFirstName(String firstName); User lastName(String lastName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getLastName(); void setLastName(String lastName); User email(String email); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getEmail(); void setEmail(String email); User password(String password); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPassword(); void setPassword(String password); User phone(String phone); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPhone(); void setPhone(String phone); User userStatus(Integer userStatus); @javax.annotation.Nullable @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getUserStatus(); void setUserStatus(Integer userStatus); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_USERNAME; static final String JSON_PROPERTY_FIRST_NAME; static final String JSON_PROPERTY_LAST_NAME; static final String JSON_PROPERTY_EMAIL; static final String JSON_PROPERTY_PASSWORD; static final String JSON_PROPERTY_PHONE; static final String JSON_PROPERTY_USER_STATUS; }### Answer: @Test public void lastNameTest() { }
### Question: User { public User email(String email) { this.email = email; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getUsername(); void setUsername(String username); User firstName(String firstName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getFirstName(); void setFirstName(String firstName); User lastName(String lastName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getLastName(); void setLastName(String lastName); User email(String email); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getEmail(); void setEmail(String email); User password(String password); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPassword(); void setPassword(String password); User phone(String phone); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPhone(); void setPhone(String phone); User userStatus(Integer userStatus); @javax.annotation.Nullable @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getUserStatus(); void setUserStatus(Integer userStatus); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_USERNAME; static final String JSON_PROPERTY_FIRST_NAME; static final String JSON_PROPERTY_LAST_NAME; static final String JSON_PROPERTY_EMAIL; static final String JSON_PROPERTY_PASSWORD; static final String JSON_PROPERTY_PHONE; static final String JSON_PROPERTY_USER_STATUS; }### Answer: @Test public void emailTest() { }
### Question: User { public User password(String password) { this.password = password; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getUsername(); void setUsername(String username); User firstName(String firstName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getFirstName(); void setFirstName(String firstName); User lastName(String lastName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getLastName(); void setLastName(String lastName); User email(String email); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getEmail(); void setEmail(String email); User password(String password); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPassword(); void setPassword(String password); User phone(String phone); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPhone(); void setPhone(String phone); User userStatus(Integer userStatus); @javax.annotation.Nullable @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getUserStatus(); void setUserStatus(Integer userStatus); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_USERNAME; static final String JSON_PROPERTY_FIRST_NAME; static final String JSON_PROPERTY_LAST_NAME; static final String JSON_PROPERTY_EMAIL; static final String JSON_PROPERTY_PASSWORD; static final String JSON_PROPERTY_PHONE; static final String JSON_PROPERTY_USER_STATUS; }### Answer: @Test public void passwordTest() { }
### Question: User { public User phone(String phone) { this.phone = phone; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getUsername(); void setUsername(String username); User firstName(String firstName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getFirstName(); void setFirstName(String firstName); User lastName(String lastName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getLastName(); void setLastName(String lastName); User email(String email); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getEmail(); void setEmail(String email); User password(String password); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPassword(); void setPassword(String password); User phone(String phone); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPhone(); void setPhone(String phone); User userStatus(Integer userStatus); @javax.annotation.Nullable @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getUserStatus(); void setUserStatus(Integer userStatus); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_USERNAME; static final String JSON_PROPERTY_FIRST_NAME; static final String JSON_PROPERTY_LAST_NAME; static final String JSON_PROPERTY_EMAIL; static final String JSON_PROPERTY_PASSWORD; static final String JSON_PROPERTY_PHONE; static final String JSON_PROPERTY_USER_STATUS; }### Answer: @Test public void phoneTest() { }
### Question: User { public User userStatus(Integer userStatus) { this.userStatus = userStatus; return this; } User id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); User username(String username); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getUsername(); void setUsername(String username); User firstName(String firstName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_FIRST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getFirstName(); void setFirstName(String firstName); User lastName(String lastName); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_LAST_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getLastName(); void setLastName(String lastName); User email(String email); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getEmail(); void setEmail(String email); User password(String password); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPassword(); void setPassword(String password); User phone(String phone); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_PHONE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getPhone(); void setPhone(String phone); User userStatus(Integer userStatus); @javax.annotation.Nullable @ApiModelProperty(value = "User Status") @JsonProperty(JSON_PROPERTY_USER_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getUserStatus(); void setUserStatus(Integer userStatus); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_USERNAME; static final String JSON_PROPERTY_FIRST_NAME; static final String JSON_PROPERTY_LAST_NAME; static final String JSON_PROPERTY_EMAIL; static final String JSON_PROPERTY_PASSWORD; static final String JSON_PROPERTY_PHONE; static final String JSON_PROPERTY_USER_STATUS; }### Answer: @Test public void userStatusTest() { }
### Question: Pet { public Pet id(Long id) { this.id = id; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Category getCategory(); void setCategory(Category category); Pet name(String name); @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) String getName(); void setName(String name); Pet photoUrls(List<String> photoUrls); Pet addPhotoUrlsItem(String photoUrlsItem); @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) List<String> getPhotoUrls(); void setPhotoUrls(List<String> photoUrls); Pet tags(List<Tag> tags); Pet addTagsItem(Tag tagsItem); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) List<Tag> getTags(); void setTags(List<Tag> tags); Pet status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "pet status in the store") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_CATEGORY; static final String JSON_PROPERTY_NAME; static final String JSON_PROPERTY_PHOTO_URLS; static final String JSON_PROPERTY_TAGS; static final String JSON_PROPERTY_STATUS; }### Answer: @Test public void idTest() { }
### Question: Pet { public Pet category(Category category) { this.category = category; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Category getCategory(); void setCategory(Category category); Pet name(String name); @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) String getName(); void setName(String name); Pet photoUrls(List<String> photoUrls); Pet addPhotoUrlsItem(String photoUrlsItem); @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) List<String> getPhotoUrls(); void setPhotoUrls(List<String> photoUrls); Pet tags(List<Tag> tags); Pet addTagsItem(Tag tagsItem); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) List<Tag> getTags(); void setTags(List<Tag> tags); Pet status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "pet status in the store") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_CATEGORY; static final String JSON_PROPERTY_NAME; static final String JSON_PROPERTY_PHOTO_URLS; static final String JSON_PROPERTY_TAGS; static final String JSON_PROPERTY_STATUS; }### Answer: @Test public void categoryTest() { }
### Question: Pet { public Pet name(String name) { this.name = name; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Category getCategory(); void setCategory(Category category); Pet name(String name); @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) String getName(); void setName(String name); Pet photoUrls(List<String> photoUrls); Pet addPhotoUrlsItem(String photoUrlsItem); @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) List<String> getPhotoUrls(); void setPhotoUrls(List<String> photoUrls); Pet tags(List<Tag> tags); Pet addTagsItem(Tag tagsItem); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) List<Tag> getTags(); void setTags(List<Tag> tags); Pet status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "pet status in the store") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_CATEGORY; static final String JSON_PROPERTY_NAME; static final String JSON_PROPERTY_PHOTO_URLS; static final String JSON_PROPERTY_TAGS; static final String JSON_PROPERTY_STATUS; }### Answer: @Test public void nameTest() { }
### Question: Pet { public Pet photoUrls(List<String> photoUrls) { this.photoUrls = photoUrls; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Category getCategory(); void setCategory(Category category); Pet name(String name); @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) String getName(); void setName(String name); Pet photoUrls(List<String> photoUrls); Pet addPhotoUrlsItem(String photoUrlsItem); @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) List<String> getPhotoUrls(); void setPhotoUrls(List<String> photoUrls); Pet tags(List<Tag> tags); Pet addTagsItem(Tag tagsItem); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) List<Tag> getTags(); void setTags(List<Tag> tags); Pet status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "pet status in the store") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_CATEGORY; static final String JSON_PROPERTY_NAME; static final String JSON_PROPERTY_PHOTO_URLS; static final String JSON_PROPERTY_TAGS; static final String JSON_PROPERTY_STATUS; }### Answer: @Test public void photoUrlsTest() { }
### Question: Pet { public Pet tags(List<Tag> tags) { this.tags = tags; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Category getCategory(); void setCategory(Category category); Pet name(String name); @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) String getName(); void setName(String name); Pet photoUrls(List<String> photoUrls); Pet addPhotoUrlsItem(String photoUrlsItem); @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) List<String> getPhotoUrls(); void setPhotoUrls(List<String> photoUrls); Pet tags(List<Tag> tags); Pet addTagsItem(Tag tagsItem); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) List<Tag> getTags(); void setTags(List<Tag> tags); Pet status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "pet status in the store") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_CATEGORY; static final String JSON_PROPERTY_NAME; static final String JSON_PROPERTY_PHOTO_URLS; static final String JSON_PROPERTY_TAGS; static final String JSON_PROPERTY_STATUS; }### Answer: @Test public void tagsTest() { }
### Question: Pet { public Pet status(StatusEnum status) { this.status = status; return this; } Pet id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Pet category(Category category); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CATEGORY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Category getCategory(); void setCategory(Category category); Pet name(String name); @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) String getName(); void setName(String name); Pet photoUrls(List<String> photoUrls); Pet addPhotoUrlsItem(String photoUrlsItem); @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PHOTO_URLS) @JsonInclude(value = JsonInclude.Include.ALWAYS) List<String> getPhotoUrls(); void setPhotoUrls(List<String> photoUrls); Pet tags(List<Tag> tags); Pet addTagsItem(Tag tagsItem); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) List<Tag> getTags(); void setTags(List<Tag> tags); Pet status(StatusEnum status); @javax.annotation.Nullable @ApiModelProperty(value = "pet status in the store") @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) StatusEnum getStatus(); void setStatus(StatusEnum status); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_CATEGORY; static final String JSON_PROPERTY_NAME; static final String JSON_PROPERTY_PHOTO_URLS; static final String JSON_PROPERTY_TAGS; static final String JSON_PROPERTY_STATUS; }### Answer: @Test public void statusTest() { }
### Question: Category { public Category id(Long id) { this.id = id; return this; } Category id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Category name(String name); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getName(); void setName(String name); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_NAME; }### Answer: @Test public void idTest() { }
### Question: Category { public Category name(String name) { this.name = name; return this; } Category id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Category name(String name); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getName(); void setName(String name); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_NAME; }### Answer: @Test public void nameTest() { }
### Question: ModelApiResponse { public ModelApiResponse code(Integer code) { this.code = code; return this; } ModelApiResponse code(Integer code); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getCode(); void setCode(Integer code); ModelApiResponse type(String type); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getType(); void setType(String type); ModelApiResponse message(String message); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getMessage(); void setMessage(String message); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_CODE; static final String JSON_PROPERTY_TYPE; static final String JSON_PROPERTY_MESSAGE; }### Answer: @Test public void codeTest() { }
### Question: ModelApiResponse { public ModelApiResponse type(String type) { this.type = type; return this; } ModelApiResponse code(Integer code); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getCode(); void setCode(Integer code); ModelApiResponse type(String type); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getType(); void setType(String type); ModelApiResponse message(String message); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getMessage(); void setMessage(String message); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_CODE; static final String JSON_PROPERTY_TYPE; static final String JSON_PROPERTY_MESSAGE; }### Answer: @Test public void typeTest() { }
### Question: ModelApiResponse { public ModelApiResponse message(String message) { this.message = message; return this; } ModelApiResponse code(Integer code); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Integer getCode(); void setCode(Integer code); ModelApiResponse type(String type); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getType(); void setType(String type); ModelApiResponse message(String message); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_MESSAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getMessage(); void setMessage(String message); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_CODE; static final String JSON_PROPERTY_TYPE; static final String JSON_PROPERTY_MESSAGE; }### Answer: @Test public void messageTest() { }
### Question: Tag { public Tag id(Long id) { this.id = id; return this; } Tag id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Tag name(String name); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getName(); void setName(String name); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_NAME; }### Answer: @Test public void idTest() { }
### Question: Tag { public Tag name(String name) { this.name = name; return this; } Tag id(Long id); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) Long getId(); void setId(Long id); Tag name(String name); @javax.annotation.Nullable @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) String getName(); void setName(String name); @Override boolean equals(java.lang.Object o); @Override int hashCode(); @Override String toString(); static final String JSON_PROPERTY_ID; static final String JSON_PROPERTY_NAME; }### Answer: @Test public void nameTest() { }
### Question: UserApi { public void createUser(User body) throws RestClientException { createUserWithHttpInfo(body); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArrayInput(List<User> body); ResponseEntity<Void> createUsersWithArrayInputWithHttpInfo(List<User> body); void createUsersWithListInput(List<User> body); ResponseEntity<Void> createUsersWithListInputWithHttpInfo(List<User> body); void deleteUser(String username); ResponseEntity<Void> deleteUserWithHttpInfo(String username); User getUserByName(String username); ResponseEntity<User> getUserByNameWithHttpInfo(String username); String loginUser(String username, String password); ResponseEntity<String> loginUserWithHttpInfo(String username, String password); void logoutUser(); ResponseEntity<Void> logoutUserWithHttpInfo(); void updateUser(String username, User body); ResponseEntity<Void> updateUserWithHttpInfo(String username, User body); }### Answer: @Test public void createUserTest() { User body = null; api.createUser(body); }
### Question: UserApi { public void createUsersWithArrayInput(List<User> body) throws RestClientException { createUsersWithArrayInputWithHttpInfo(body); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArrayInput(List<User> body); ResponseEntity<Void> createUsersWithArrayInputWithHttpInfo(List<User> body); void createUsersWithListInput(List<User> body); ResponseEntity<Void> createUsersWithListInputWithHttpInfo(List<User> body); void deleteUser(String username); ResponseEntity<Void> deleteUserWithHttpInfo(String username); User getUserByName(String username); ResponseEntity<User> getUserByNameWithHttpInfo(String username); String loginUser(String username, String password); ResponseEntity<String> loginUserWithHttpInfo(String username, String password); void logoutUser(); ResponseEntity<Void> logoutUserWithHttpInfo(); void updateUser(String username, User body); ResponseEntity<Void> updateUserWithHttpInfo(String username, User body); }### Answer: @Test public void createUsersWithArrayInputTest() { List<User> body = null; api.createUsersWithArrayInput(body); }
### Question: UserApi { public void createUsersWithListInput(List<User> body) throws RestClientException { createUsersWithListInputWithHttpInfo(body); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArrayInput(List<User> body); ResponseEntity<Void> createUsersWithArrayInputWithHttpInfo(List<User> body); void createUsersWithListInput(List<User> body); ResponseEntity<Void> createUsersWithListInputWithHttpInfo(List<User> body); void deleteUser(String username); ResponseEntity<Void> deleteUserWithHttpInfo(String username); User getUserByName(String username); ResponseEntity<User> getUserByNameWithHttpInfo(String username); String loginUser(String username, String password); ResponseEntity<String> loginUserWithHttpInfo(String username, String password); void logoutUser(); ResponseEntity<Void> logoutUserWithHttpInfo(); void updateUser(String username, User body); ResponseEntity<Void> updateUserWithHttpInfo(String username, User body); }### Answer: @Test public void createUsersWithListInputTest() { List<User> body = null; api.createUsersWithListInput(body); }
### Question: UserApi { public void deleteUser(String username) throws RestClientException { deleteUserWithHttpInfo(username); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArrayInput(List<User> body); ResponseEntity<Void> createUsersWithArrayInputWithHttpInfo(List<User> body); void createUsersWithListInput(List<User> body); ResponseEntity<Void> createUsersWithListInputWithHttpInfo(List<User> body); void deleteUser(String username); ResponseEntity<Void> deleteUserWithHttpInfo(String username); User getUserByName(String username); ResponseEntity<User> getUserByNameWithHttpInfo(String username); String loginUser(String username, String password); ResponseEntity<String> loginUserWithHttpInfo(String username, String password); void logoutUser(); ResponseEntity<Void> logoutUserWithHttpInfo(); void updateUser(String username, User body); ResponseEntity<Void> updateUserWithHttpInfo(String username, User body); }### Answer: @Test public void deleteUserTest() { String username = null; api.deleteUser(username); }
### Question: UserApi { public User getUserByName(String username) throws RestClientException { return getUserByNameWithHttpInfo(username).getBody(); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArrayInput(List<User> body); ResponseEntity<Void> createUsersWithArrayInputWithHttpInfo(List<User> body); void createUsersWithListInput(List<User> body); ResponseEntity<Void> createUsersWithListInputWithHttpInfo(List<User> body); void deleteUser(String username); ResponseEntity<Void> deleteUserWithHttpInfo(String username); User getUserByName(String username); ResponseEntity<User> getUserByNameWithHttpInfo(String username); String loginUser(String username, String password); ResponseEntity<String> loginUserWithHttpInfo(String username, String password); void logoutUser(); ResponseEntity<Void> logoutUserWithHttpInfo(); void updateUser(String username, User body); ResponseEntity<Void> updateUserWithHttpInfo(String username, User body); }### Answer: @Test public void getUserByNameTest() { String username = null; User response = api.getUserByName(username); }
### Question: UserApi { public String loginUser(String username, String password) throws RestClientException { return loginUserWithHttpInfo(username, password).getBody(); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArrayInput(List<User> body); ResponseEntity<Void> createUsersWithArrayInputWithHttpInfo(List<User> body); void createUsersWithListInput(List<User> body); ResponseEntity<Void> createUsersWithListInputWithHttpInfo(List<User> body); void deleteUser(String username); ResponseEntity<Void> deleteUserWithHttpInfo(String username); User getUserByName(String username); ResponseEntity<User> getUserByNameWithHttpInfo(String username); String loginUser(String username, String password); ResponseEntity<String> loginUserWithHttpInfo(String username, String password); void logoutUser(); ResponseEntity<Void> logoutUserWithHttpInfo(); void updateUser(String username, User body); ResponseEntity<Void> updateUserWithHttpInfo(String username, User body); }### Answer: @Test public void loginUserTest() { String username = null; String password = null; String response = api.loginUser(username, password); }
### Question: UserApi { public void logoutUser() throws RestClientException { logoutUserWithHttpInfo(); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArrayInput(List<User> body); ResponseEntity<Void> createUsersWithArrayInputWithHttpInfo(List<User> body); void createUsersWithListInput(List<User> body); ResponseEntity<Void> createUsersWithListInputWithHttpInfo(List<User> body); void deleteUser(String username); ResponseEntity<Void> deleteUserWithHttpInfo(String username); User getUserByName(String username); ResponseEntity<User> getUserByNameWithHttpInfo(String username); String loginUser(String username, String password); ResponseEntity<String> loginUserWithHttpInfo(String username, String password); void logoutUser(); ResponseEntity<Void> logoutUserWithHttpInfo(); void updateUser(String username, User body); ResponseEntity<Void> updateUserWithHttpInfo(String username, User body); }### Answer: @Test public void logoutUserTest() { api.logoutUser(); }
### Question: UserApi { public void updateUser(String username, User body) throws RestClientException { updateUserWithHttpInfo(username, body); } UserApi(); @Autowired UserApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void createUser(User body); ResponseEntity<Void> createUserWithHttpInfo(User body); void createUsersWithArrayInput(List<User> body); ResponseEntity<Void> createUsersWithArrayInputWithHttpInfo(List<User> body); void createUsersWithListInput(List<User> body); ResponseEntity<Void> createUsersWithListInputWithHttpInfo(List<User> body); void deleteUser(String username); ResponseEntity<Void> deleteUserWithHttpInfo(String username); User getUserByName(String username); ResponseEntity<User> getUserByNameWithHttpInfo(String username); String loginUser(String username, String password); ResponseEntity<String> loginUserWithHttpInfo(String username, String password); void logoutUser(); ResponseEntity<Void> logoutUserWithHttpInfo(); void updateUser(String username, User body); ResponseEntity<Void> updateUserWithHttpInfo(String username, User body); }### Answer: @Test public void updateUserTest() { String username = null; User body = null; api.updateUser(username, body); }
### Question: StoreApi { public void deleteOrder(Long orderId) throws RestClientException { deleteOrderWithHttpInfo(orderId); } StoreApi(); @Autowired StoreApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void deleteOrder(Long orderId); ResponseEntity<Void> deleteOrderWithHttpInfo(Long orderId); Map<String, Integer> getInventory(); ResponseEntity<Map<String, Integer>> getInventoryWithHttpInfo(); Order getOrderById(Long orderId); ResponseEntity<Order> getOrderByIdWithHttpInfo(Long orderId); Order placeOrder(Order body); ResponseEntity<Order> placeOrderWithHttpInfo(Order body); }### Answer: @Test public void deleteOrderTest() { Long orderId = null; api.deleteOrder(orderId); }
### Question: StoreApi { public Map<String, Integer> getInventory() throws RestClientException { return getInventoryWithHttpInfo().getBody(); } StoreApi(); @Autowired StoreApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void deleteOrder(Long orderId); ResponseEntity<Void> deleteOrderWithHttpInfo(Long orderId); Map<String, Integer> getInventory(); ResponseEntity<Map<String, Integer>> getInventoryWithHttpInfo(); Order getOrderById(Long orderId); ResponseEntity<Order> getOrderByIdWithHttpInfo(Long orderId); Order placeOrder(Order body); ResponseEntity<Order> placeOrderWithHttpInfo(Order body); }### Answer: @Test public void getInventoryTest() { Map<String, Integer> response = api.getInventory(); }
### Question: StoreApi { public Order getOrderById(Long orderId) throws RestClientException { return getOrderByIdWithHttpInfo(orderId).getBody(); } StoreApi(); @Autowired StoreApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void deleteOrder(Long orderId); ResponseEntity<Void> deleteOrderWithHttpInfo(Long orderId); Map<String, Integer> getInventory(); ResponseEntity<Map<String, Integer>> getInventoryWithHttpInfo(); Order getOrderById(Long orderId); ResponseEntity<Order> getOrderByIdWithHttpInfo(Long orderId); Order placeOrder(Order body); ResponseEntity<Order> placeOrderWithHttpInfo(Order body); }### Answer: @Test public void getOrderByIdTest() { Long orderId = null; Order response = api.getOrderById(orderId); }
### Question: StoreApi { public Order placeOrder(Order body) throws RestClientException { return placeOrderWithHttpInfo(body).getBody(); } StoreApi(); @Autowired StoreApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void deleteOrder(Long orderId); ResponseEntity<Void> deleteOrderWithHttpInfo(Long orderId); Map<String, Integer> getInventory(); ResponseEntity<Map<String, Integer>> getInventoryWithHttpInfo(); Order getOrderById(Long orderId); ResponseEntity<Order> getOrderByIdWithHttpInfo(Long orderId); Order placeOrder(Order body); ResponseEntity<Order> placeOrderWithHttpInfo(Order body); }### Answer: @Test public void placeOrderTest() { Order body = null; Order response = api.placeOrder(body); }
### Question: PetApi { public void addPet(Pet body) throws RestClientException { addPetWithHttpInfo(body); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String apiKey); ResponseEntity<Void> deletePetWithHttpInfo(Long petId, String apiKey); List<Pet> findPetsByStatus(List<String> status); ResponseEntity<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status); @Deprecated List<Pet> findPetsByTags(List<String> tags); @Deprecated ResponseEntity<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags); Pet getPetById(Long petId); ResponseEntity<Pet> getPetByIdWithHttpInfo(Long petId); void updatePet(Pet body); ResponseEntity<Void> updatePetWithHttpInfo(Pet body); void updatePetWithForm(Long petId, String name, String status); ResponseEntity<Void> updatePetWithFormWithHttpInfo(Long petId, String name, String status); ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file); ResponseEntity<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file); }### Answer: @Test public void addPetTest() { Pet body = null; api.addPet(body); }
### Question: PetApi { public void deletePet(Long petId, String apiKey) throws RestClientException { deletePetWithHttpInfo(petId, apiKey); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String apiKey); ResponseEntity<Void> deletePetWithHttpInfo(Long petId, String apiKey); List<Pet> findPetsByStatus(List<String> status); ResponseEntity<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status); @Deprecated List<Pet> findPetsByTags(List<String> tags); @Deprecated ResponseEntity<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags); Pet getPetById(Long petId); ResponseEntity<Pet> getPetByIdWithHttpInfo(Long petId); void updatePet(Pet body); ResponseEntity<Void> updatePetWithHttpInfo(Pet body); void updatePetWithForm(Long petId, String name, String status); ResponseEntity<Void> updatePetWithFormWithHttpInfo(Long petId, String name, String status); ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file); ResponseEntity<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file); }### Answer: @Test public void deletePetTest() { Long petId = null; String apiKey = null; api.deletePet(petId, apiKey); }
### Question: PetApi { public List<Pet> findPetsByStatus(List<String> status) throws RestClientException { return findPetsByStatusWithHttpInfo(status).getBody(); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String apiKey); ResponseEntity<Void> deletePetWithHttpInfo(Long petId, String apiKey); List<Pet> findPetsByStatus(List<String> status); ResponseEntity<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status); @Deprecated List<Pet> findPetsByTags(List<String> tags); @Deprecated ResponseEntity<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags); Pet getPetById(Long petId); ResponseEntity<Pet> getPetByIdWithHttpInfo(Long petId); void updatePet(Pet body); ResponseEntity<Void> updatePetWithHttpInfo(Pet body); void updatePetWithForm(Long petId, String name, String status); ResponseEntity<Void> updatePetWithFormWithHttpInfo(Long petId, String name, String status); ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file); ResponseEntity<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file); }### Answer: @Test public void findPetsByStatusTest() { List<String> status = null; List<Pet> response = api.findPetsByStatus(status); }
### Question: PetApi { @Deprecated public List<Pet> findPetsByTags(List<String> tags) throws RestClientException { return findPetsByTagsWithHttpInfo(tags).getBody(); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String apiKey); ResponseEntity<Void> deletePetWithHttpInfo(Long petId, String apiKey); List<Pet> findPetsByStatus(List<String> status); ResponseEntity<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status); @Deprecated List<Pet> findPetsByTags(List<String> tags); @Deprecated ResponseEntity<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags); Pet getPetById(Long petId); ResponseEntity<Pet> getPetByIdWithHttpInfo(Long petId); void updatePet(Pet body); ResponseEntity<Void> updatePetWithHttpInfo(Pet body); void updatePetWithForm(Long petId, String name, String status); ResponseEntity<Void> updatePetWithFormWithHttpInfo(Long petId, String name, String status); ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file); ResponseEntity<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file); }### Answer: @Test public void findPetsByTagsTest() { List<String> tags = null; List<Pet> response = api.findPetsByTags(tags); }
### Question: PetApi { public Pet getPetById(Long petId) throws RestClientException { return getPetByIdWithHttpInfo(petId).getBody(); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String apiKey); ResponseEntity<Void> deletePetWithHttpInfo(Long petId, String apiKey); List<Pet> findPetsByStatus(List<String> status); ResponseEntity<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status); @Deprecated List<Pet> findPetsByTags(List<String> tags); @Deprecated ResponseEntity<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags); Pet getPetById(Long petId); ResponseEntity<Pet> getPetByIdWithHttpInfo(Long petId); void updatePet(Pet body); ResponseEntity<Void> updatePetWithHttpInfo(Pet body); void updatePetWithForm(Long petId, String name, String status); ResponseEntity<Void> updatePetWithFormWithHttpInfo(Long petId, String name, String status); ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file); ResponseEntity<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file); }### Answer: @Test public void getPetByIdTest() { Long petId = null; Pet response = api.getPetById(petId); }
### Question: PetApi { public void updatePet(Pet body) throws RestClientException { updatePetWithHttpInfo(body); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String apiKey); ResponseEntity<Void> deletePetWithHttpInfo(Long petId, String apiKey); List<Pet> findPetsByStatus(List<String> status); ResponseEntity<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status); @Deprecated List<Pet> findPetsByTags(List<String> tags); @Deprecated ResponseEntity<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags); Pet getPetById(Long petId); ResponseEntity<Pet> getPetByIdWithHttpInfo(Long petId); void updatePet(Pet body); ResponseEntity<Void> updatePetWithHttpInfo(Pet body); void updatePetWithForm(Long petId, String name, String status); ResponseEntity<Void> updatePetWithFormWithHttpInfo(Long petId, String name, String status); ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file); ResponseEntity<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file); }### Answer: @Test public void updatePetTest() { Pet body = null; api.updatePet(body); }
### Question: PetApi { public void updatePetWithForm(Long petId, String name, String status) throws RestClientException { updatePetWithFormWithHttpInfo(petId, name, status); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String apiKey); ResponseEntity<Void> deletePetWithHttpInfo(Long petId, String apiKey); List<Pet> findPetsByStatus(List<String> status); ResponseEntity<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status); @Deprecated List<Pet> findPetsByTags(List<String> tags); @Deprecated ResponseEntity<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags); Pet getPetById(Long petId); ResponseEntity<Pet> getPetByIdWithHttpInfo(Long petId); void updatePet(Pet body); ResponseEntity<Void> updatePetWithHttpInfo(Pet body); void updatePetWithForm(Long petId, String name, String status); ResponseEntity<Void> updatePetWithFormWithHttpInfo(Long petId, String name, String status); ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file); ResponseEntity<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file); }### Answer: @Test public void updatePetWithFormTest() { Long petId = null; String name = null; String status = null; api.updatePetWithForm(petId, name, status); }
### Question: PetApi { public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws RestClientException { return uploadFileWithHttpInfo(petId, additionalMetadata, file).getBody(); } PetApi(); @Autowired PetApi(ApiClient apiClient); ApiClient getApiClient(); void setApiClient(ApiClient apiClient); void addPet(Pet body); ResponseEntity<Void> addPetWithHttpInfo(Pet body); void deletePet(Long petId, String apiKey); ResponseEntity<Void> deletePetWithHttpInfo(Long petId, String apiKey); List<Pet> findPetsByStatus(List<String> status); ResponseEntity<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status); @Deprecated List<Pet> findPetsByTags(List<String> tags); @Deprecated ResponseEntity<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags); Pet getPetById(Long petId); ResponseEntity<Pet> getPetByIdWithHttpInfo(Long petId); void updatePet(Pet body); ResponseEntity<Void> updatePetWithHttpInfo(Pet body); void updatePetWithForm(Long petId, String name, String status); ResponseEntity<Void> updatePetWithFormWithHttpInfo(Long petId, String name, String status); ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file); ResponseEntity<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file); }### Answer: @Test public void uploadFileTest() { Long petId = null; String additionalMetadata = null; File file = null; ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file); }
### Question: Formatter { public static String getFormattedDate() { DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); Date date = new Date(); return dateFormat.format(date); } static String getFormattedDate(); }### Answer: @Test public void testFormatter() { String dateRegex1 = "^((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01]) ([2][0-3]|[0-1][0-9]|[1-9]):[0-5][0-9]:([0-5][0-9]|[6][0])$"; String dateString = Formatter.getFormattedDate(); assertTrue(Pattern .matches(dateRegex1, dateString)); }
### Question: WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); initMetrics(servletContext, disps); if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { initH2Console(servletContext); } log.info("Web application fully configured"); } WebConfigurer(Environment env, JHipsterProperties jHipsterProperties); @Override void onStartup(ServletContext servletContext); @Override void customize(WebServerFactory server); @Bean CorsFilter corsFilter(); @Autowired(required = false) void setMetricRegistry(MetricRegistry metricRegistry); }### Answer: @Test public void testStartUpProdServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry); verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class)); verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class)); verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class)); } @Test public void testStartUpDevServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry); verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class)); verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class)); verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class)); }
### Question: WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> { @Override public void customize(WebServerFactory server) { setMimeMappings(server); if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) && server instanceof UndertowServletWebServerFactory) { ((UndertowServletWebServerFactory) server) .addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true)); } } WebConfigurer(Environment env, JHipsterProperties jHipsterProperties); @Override void onStartup(ServletContext servletContext); @Override void customize(WebServerFactory server); @Bean CorsFilter corsFilter(); @Autowired(required = false) void setMetricRegistry(MetricRegistry metricRegistry); }### Answer: @Test public void testCustomizeServletContainer() { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); UndertowServletWebServerFactory container = new UndertowServletWebServerFactory(); webConfigurer.customize(container); assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg"); assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8"); assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8"); Builder builder = Undertow.builder(); container.getBuilderCustomizers().forEach(c -> c.customize(builder)); OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions"); assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull(); } @Test public void testUndertowHttp2Enabled() { props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0); UndertowServletWebServerFactory container = new UndertowServletWebServerFactory(); webConfigurer.customize(container); Builder builder = Undertow.builder(); container.getBuilderCustomizers().forEach(c -> c.customize(builder)); OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions"); assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isTrue(); }
### Question: Employee { public Integer getId() { return id; } Employee(Integer id, String name, Double salary); Integer getId(); void setId(Integer id); String getName(); void setName(String name); Double getSalary(); void setSalary(Double salary); void salaryIncrement(Double percentage); String toString(); }### Answer: @Test public void whenFindMin_thenGetMinElementFromStream() { Employee firstEmp = empList.stream() .min((e1, e2) -> e1.getId() - e2.getId()) .orElseThrow(NoSuchElementException::new); assertEquals(firstEmp.getId(), new Integer(1)); }
### Question: OAuth2AuthenticationService { public ResponseEntity<OAuth2AccessToken> authenticate(HttpServletRequest request, HttpServletResponse response, Map<String, String> params) { try { String username = params.get("username"); String password = params.get("password"); boolean rememberMe = Boolean.valueOf(params.get("rememberMe")); OAuth2AccessToken accessToken = authorizationClient.sendPasswordGrant(username, password); OAuth2Cookies cookies = new OAuth2Cookies(); cookieHelper.createCookies(request, accessToken, rememberMe, cookies); cookies.addCookiesTo(response); if (log.isDebugEnabled()) { log.debug("successfully authenticated user {}", params.get("username")); } return ResponseEntity.ok(accessToken); } catch (HttpClientErrorException ex) { log.error("failed to get OAuth2 tokens from UAA", ex); throw new InvalidPasswordException(); } } OAuth2AuthenticationService(OAuth2TokenEndpointClient authorizationClient, OAuth2CookieHelper cookieHelper); ResponseEntity<OAuth2AccessToken> authenticate(HttpServletRequest request, HttpServletResponse response, Map<String, String> params); HttpServletRequest refreshToken(HttpServletRequest request, HttpServletResponse response, Cookie refreshCookie); void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse); HttpServletRequest stripTokens(HttpServletRequest httpServletRequest); }### Answer: @Test public void testAuthenticationCookies() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("www.test.com"); request.addHeader("Authorization", CLIENT_AUTHORIZATION); Map<String, String> params = new HashMap<>(); params.put("username", "user"); params.put("password", "user"); params.put("rememberMe", "true"); MockHttpServletResponse response = new MockHttpServletResponse(); authenticationService.authenticate(request, response, params); Cookie accessTokenCookie = response.getCookie(OAuth2CookieHelper.ACCESS_TOKEN_COOKIE); Assert.assertEquals(ACCESS_TOKEN_VALUE, accessTokenCookie.getValue()); Cookie refreshTokenCookie = response.getCookie(OAuth2CookieHelper.REFRESH_TOKEN_COOKIE); Assert.assertEquals(REFRESH_TOKEN_VALUE, OAuth2CookieHelper.getRefreshTokenValue(refreshTokenCookie)); Assert.assertTrue(OAuth2CookieHelper.isRememberMe(refreshTokenCookie)); } @Test public void testAuthenticationNoRememberMe() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("www.test.com"); Map<String, String> params = new HashMap<>(); params.put("username", "user"); params.put("password", "user"); params.put("rememberMe", "false"); MockHttpServletResponse response = new MockHttpServletResponse(); authenticationService.authenticate(request, response, params); Cookie accessTokenCookie = response.getCookie(OAuth2CookieHelper.ACCESS_TOKEN_COOKIE); Assert.assertEquals(ACCESS_TOKEN_VALUE, accessTokenCookie.getValue()); Cookie refreshTokenCookie = response.getCookie(OAuth2CookieHelper.SESSION_TOKEN_COOKIE); Assert.assertEquals(REFRESH_TOKEN_VALUE, OAuth2CookieHelper.getRefreshTokenValue(refreshTokenCookie)); Assert.assertFalse(OAuth2CookieHelper.isRememberMe(refreshTokenCookie)); } @Test public void testInvalidPassword() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setServerName("www.test.com"); Map<String, String> params = new HashMap<>(); params.put("username", "user"); params.put("password", "user2"); params.put("rememberMe", "false"); MockHttpServletResponse response = new MockHttpServletResponse(); expectedException.expect(InvalidPasswordException.class); authenticationService.authenticate(request, response, params); }
### Question: OAuth2AuthenticationService { public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { cookieHelper.clearCookies(httpServletRequest, httpServletResponse); } OAuth2AuthenticationService(OAuth2TokenEndpointClient authorizationClient, OAuth2CookieHelper cookieHelper); ResponseEntity<OAuth2AccessToken> authenticate(HttpServletRequest request, HttpServletResponse response, Map<String, String> params); HttpServletRequest refreshToken(HttpServletRequest request, HttpServletResponse response, Cookie refreshCookie); void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse); HttpServletRequest stripTokens(HttpServletRequest httpServletRequest); }### Answer: @Test public void testLogout() { MockHttpServletRequest request = new MockHttpServletRequest(); Cookie accessTokenCookie = new Cookie(OAuth2CookieHelper.ACCESS_TOKEN_COOKIE, ACCESS_TOKEN_VALUE); Cookie refreshTokenCookie = new Cookie(OAuth2CookieHelper.REFRESH_TOKEN_COOKIE, REFRESH_TOKEN_VALUE); request.setCookies(accessTokenCookie, refreshTokenCookie); MockHttpServletResponse response = new MockHttpServletResponse(); authenticationService.logout(request, response); Cookie newAccessTokenCookie = response.getCookie(OAuth2CookieHelper.ACCESS_TOKEN_COOKIE); Assert.assertEquals(0, newAccessTokenCookie.getMaxAge()); Cookie newRefreshTokenCookie = response.getCookie(OAuth2CookieHelper.REFRESH_TOKEN_COOKIE); Assert.assertEquals(0, newRefreshTokenCookie.getMaxAge()); }
### Question: OAuth2AuthenticationService { public HttpServletRequest stripTokens(HttpServletRequest httpServletRequest) { Cookie[] cookies = cookieHelper.stripCookies(httpServletRequest.getCookies()); return new CookiesHttpServletRequestWrapper(httpServletRequest, cookies); } OAuth2AuthenticationService(OAuth2TokenEndpointClient authorizationClient, OAuth2CookieHelper cookieHelper); ResponseEntity<OAuth2AccessToken> authenticate(HttpServletRequest request, HttpServletResponse response, Map<String, String> params); HttpServletRequest refreshToken(HttpServletRequest request, HttpServletResponse response, Cookie refreshCookie); void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse); HttpServletRequest stripTokens(HttpServletRequest httpServletRequest); }### Answer: @Test public void testStripTokens() { MockHttpServletRequest request = createMockHttpServletRequest(); HttpServletRequest newRequest = authenticationService.stripTokens(request); CookieCollection cookies = new CookieCollection(newRequest.getCookies()); Assert.assertFalse(cookies.contains(OAuth2CookieHelper.ACCESS_TOKEN_COOKIE)); Assert.assertFalse(cookies.contains(OAuth2CookieHelper.REFRESH_TOKEN_COOKIE)); }
### Question: CookieCollection implements Collection<Cookie> { @Override public int size() { return cookieMap.size(); } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void size() throws Exception { CookieCollection cookies = new CookieCollection(); Assert.assertEquals(0, cookies.size()); cookies.add(cookie); Assert.assertEquals(1, cookies.size()); }
### Question: CookieCollection implements Collection<Cookie> { @Override public boolean isEmpty() { return cookieMap.isEmpty(); } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void isEmpty() throws Exception { CookieCollection cookies = new CookieCollection(); Assert.assertTrue(cookies.isEmpty()); cookies.add(cookie); Assert.assertFalse(cookies.isEmpty()); }
### Question: CookieCollection implements Collection<Cookie> { @Override public boolean contains(Object o) { if (o instanceof String) { return cookieMap.containsKey(o); } if (o instanceof Cookie) { return cookieMap.containsValue(o); } return false; } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void contains() throws Exception { CookieCollection cookies = new CookieCollection(cookie); Assert.assertTrue(cookies.contains(cookie)); Assert.assertTrue(cookies.contains(COOKIE_NAME)); Assert.assertFalse(cookies.contains("yuck")); }
### Question: CookieCollection implements Collection<Cookie> { @Override public Iterator<Cookie> iterator() { return cookieMap.values().iterator(); } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void iterator() throws Exception { CookieCollection cookies = new CookieCollection(cookie); Iterator<Cookie> it = cookies.iterator(); Assert.assertTrue(it.hasNext()); Assert.assertEquals(cookie, it.next()); Assert.assertFalse(it.hasNext()); }
### Question: CookieCollection implements Collection<Cookie> { public Cookie[] toArray() { Cookie[] cookies = new Cookie[cookieMap.size()]; return toArray(cookies); } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void toArray() throws Exception { CookieCollection cookies = new CookieCollection(cookie); Cookie[] array = cookies.toArray(); Assert.assertEquals(cookies.size(), array.length); Assert.assertEquals(cookie, array[0]); }
### Question: CookieCollection implements Collection<Cookie> { @Override public boolean add(Cookie cookie) { if (cookie == null) { return false; } cookieMap.put(cookie.getName(), cookie); return true; } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void add() throws Exception { CookieCollection cookies = new CookieCollection(cookie); Cookie newCookie = new Cookie(BROWNIE_NAME, "mmh"); cookies.add(newCookie); Assert.assertEquals(2, cookies.size()); Assert.assertTrue(cookies.contains(newCookie)); Assert.assertTrue(cookies.contains(BROWNIE_NAME)); }
### Question: Employee { public String toString() { return "Id: " + id + " Name:" + name + " Price:" + salary; } Employee(Integer id, String name, Double salary); Integer getId(); void setId(Integer id); String getName(); void setName(String name); Double getSalary(); void setSalary(Double salary); void salaryIncrement(Double percentage); String toString(); }### Answer: @Test public void whenCollectByJoining_thenGetJoinedString() { String empNames = empList.stream() .map(Employee::getName) .collect(Collectors.joining(", ")) .toString(); assertEquals(empNames, "Jeff Bezos, Bill Gates, Mark Zuckerberg"); }
### Question: CookieCollection implements Collection<Cookie> { public Cookie get(String name) { return cookieMap.get(name); } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void get() { CookieCollection cookies = new CookieCollection(cookie, brownieCookie, cupsCookie); Cookie c = cookies.get(COOKIE_NAME); Assert.assertNotNull(c); Assert.assertEquals(cookie, c); }
### Question: CookieCollection implements Collection<Cookie> { @Override public boolean remove(Object o) { if (o instanceof String) { return cookieMap.remove((String)o) != null; } if (o instanceof Cookie) { Cookie c = (Cookie)o; return cookieMap.remove(c.getName()) != null; } return false; } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void remove() throws Exception { CookieCollection cookies = new CookieCollection(cookie, brownieCookie, cupsCookie); cookies.remove(cookie); Assert.assertEquals(2, cookies.size()); Assert.assertFalse(cookies.contains(cookie)); Assert.assertFalse(cookies.contains(COOKIE_NAME)); Assert.assertTrue(cookies.contains(brownieCookie)); Assert.assertTrue(cookies.contains(BROWNIE_NAME)); }
### Question: CookieCollection implements Collection<Cookie> { @Override public boolean containsAll(Collection<?> collection) { for(Object o : collection) { if (!contains(o)) { return false; } } return true; } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void containsAll() throws Exception { List<Cookie> content = Arrays.asList(cookie, brownieCookie); CookieCollection cookies = new CookieCollection(content); Assert.assertTrue(cookies.containsAll(content)); Assert.assertTrue(cookies.containsAll(Collections.singletonList(cookie))); Assert.assertFalse(cookies.containsAll(Arrays.asList(cookie, brownieCookie, cupsCookie))); Assert.assertTrue(cookies.containsAll(Arrays.asList(COOKIE_NAME, BROWNIE_NAME))); }
### Question: CookieCollection implements Collection<Cookie> { @Override public boolean addAll(Collection<? extends Cookie> collection) { boolean result = false; for(Cookie cookie : collection) { result|= add(cookie); } return result; } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test @SuppressWarnings("unchecked") public void addAll() throws Exception { CookieCollection cookies = new CookieCollection(); List<Cookie> content = Arrays.asList(cookie, brownieCookie, cupsCookie); boolean modified = cookies.addAll(content); Assert.assertTrue(modified); Assert.assertEquals(3, cookies.size()); Assert.assertTrue(cookies.containsAll(content)); Assert.assertFalse(cookies.addAll(Collections.EMPTY_LIST)); }
### Question: CookieCollection implements Collection<Cookie> { @Override public boolean removeAll(Collection<?> collection) { boolean result = false; for(Object cookie : collection) { result|= remove(cookie); } return result; } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void removeAll() throws Exception { CookieCollection cookies = new CookieCollection(cookie, brownieCookie, cupsCookie); boolean modified = cookies.removeAll(Arrays.asList(brownieCookie, cupsCookie)); Assert.assertTrue(modified); Assert.assertEquals(1, cookies.size()); Assert.assertFalse(cookies.contains(brownieCookie)); Assert.assertFalse(cookies.contains(cupsCookie)); Assert.assertFalse(cookies.removeAll(Collections.EMPTY_LIST)); }
### Question: CookieCollection implements Collection<Cookie> { @Override public boolean retainAll(Collection<?> collection) { boolean result = false; Iterator<Map.Entry<String, Cookie>> it = cookieMap.entrySet().iterator(); while(it.hasNext()) { Map.Entry<String, Cookie> e = it.next(); if (!collection.contains(e.getKey()) && !collection.contains(e.getValue())) { it.remove(); result = true; } } return result; } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void retainAll() throws Exception { CookieCollection cookies = new CookieCollection(cookie, brownieCookie, cupsCookie); List<Cookie> content = Arrays.asList(cookie, brownieCookie); boolean modified = cookies.retainAll(content); Assert.assertTrue(modified); Assert.assertEquals(2, cookies.size()); Assert.assertTrue(cookies.containsAll(content)); Assert.assertFalse(cookies.contains(cupsCookie)); Assert.assertFalse(cookies.retainAll(content)); }
### Question: CookieCollection implements Collection<Cookie> { @Override public void clear() { cookieMap.clear(); } CookieCollection(); CookieCollection(Cookie... cookies); CookieCollection(Collection<? extends Cookie> cookies); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<Cookie> iterator(); Cookie[] toArray(); @Override T[] toArray(T[] ts); @Override boolean add(Cookie cookie); @Override boolean remove(Object o); Cookie get(String name); @Override boolean containsAll(Collection<?> collection); @Override boolean addAll(Collection<? extends Cookie> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); @Override void clear(); }### Answer: @Test public void clear() throws Exception { CookieCollection cookies = new CookieCollection(cookie); cookies.clear(); Assert.assertTrue(cookies.isEmpty()); }
### Question: WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); initMetrics(servletContext, disps); if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) { initCachingHttpHeadersFilter(servletContext, disps); } if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { initH2Console(servletContext); } log.info("Web application fully configured"); } WebConfigurer(Environment env, JHipsterProperties jHipsterProperties); @Override void onStartup(ServletContext servletContext); @Override void customize(WebServerFactory server); @Bean CorsFilter corsFilter(); @Autowired(required = false) void setMetricRegistry(MetricRegistry metricRegistry); }### Answer: @Test public void testStartUpProdServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry); verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class)); verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class)); verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class)); verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class)); } @Test public void testStartUpDevServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry); verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class)); verify(servletContext).addServlet(eq("metricsServlet"), any(MetricsServlet.class)); verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class)); verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class)); }
### Question: ProjectValidator implements Validator { @Override public boolean supports(Class<?> clazz) { return Project.class.equals(clazz); } @Autowired ProjectValidator(ProjectRepository projectRepository, QualityProfileRepository profileRepository, SonarConnectionSettingsValidator sonarConnectionSettingsValidator, ScmConnectionSettingsValidator scmConnectionSettingsValidator, CodeChangeSettingsValidator codeChangeSettingsValidator); @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors); }### Answer: @Test public void shouldSupportProjectType() { assertThat(validator.supports(Project.class)).isTrue(); } @Test public void shouldNotSupportOtherTypeThanProject() { assertThat(validator.supports(Object.class)).isFalse(); }
### Question: CodeChangeSettingsValidator implements Validator { @Override public boolean supports(Class<?> clazz) { return CodeChangeSettings.class.equals(clazz); } @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors); }### Answer: @Test public void shouldSupportCodeChangeSettingsType() { assertThat(validator.supports(CodeChangeSettings.class)).isTrue(); } @Test public void shouldNotSupportOtherTypeThanCodeChangeSettings() { assertThat(validator.supports(Object.class)).isFalse(); }
### Question: ProjectConnectionsValidator implements Validator { @Override public boolean supports(Class<?> clazz) { return Project.class.equals(clazz); } @Autowired ProjectConnectionsValidator(ProjectValidator projectValidator, SonarConnectionCheckerService sonarConnectionCheckerService, ScmAvailabilityCheckerServiceFactory scmAvailabilityCheckerServiceFactory); @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors); }### Answer: @Test public void shouldSupportProjectType() { assertThat(validator.supports(Project.class)).isTrue(); } @Test public void shouldNotSupportOtherTypeThanProject() { assertThat(validator.supports(Object.class)).isFalse(); }
### Question: ProjectConnectionsValidator implements Validator { @Override public void validate(Object target, Errors errors) { ValidationUtils.invokeValidator(projectValidator, target, errors); Project project = (Project) target; if (!sonarConnectionCheckerService.isReachable(project.getSonarConnectionSettings())) { errors.rejectValue("sonarConnectionSettings", "sonar.not.reachable"); } try { if (!scmAvailabilityCheckerServiceFactory.create(project.getScmSettings()).isAvailable(project.getScmSettings())) { scmSystemNotAvailable(errors); } } catch (UnsupportedScmSystem e) { scmSystemNotAvailable(errors); } } @Autowired ProjectConnectionsValidator(ProjectValidator projectValidator, SonarConnectionCheckerService sonarConnectionCheckerService, ScmAvailabilityCheckerServiceFactory scmAvailabilityCheckerServiceFactory); @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors); }### Answer: @Test public void shouldCallSuppliedProjectValidator() { when(sonarConnectionCheckerService.isReachable(any(SonarConnectionSettings.class))).thenReturn(true); mockAvailableScmSystem(); validateProject(project); verify(projectValidator).validate(any(), any(Errors.class)); }
### Question: ScmConnectionSettingsValidator implements Validator { @Override public boolean supports(Class<?> clazz) { return ScmConnectionSettings.class.equals(clazz); } @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors); }### Answer: @Test public void shouldSupportScmConnectionSettingsType() { assertThat(validator.supports(ScmConnectionSettings.class)).isTrue(); } @Test public void shouldNotSupportOtherTypeThanScmConnectionSettings() { assertThat(validator.supports(Object.class)).isFalse(); }
### Question: InvestmentAmountParser { public int parseMinutes(String formattedInvestmentAmount) throws InvestmentParsingException { if (formattedInvestmentAmount.isEmpty()) { return 0; } Pattern pattern = Pattern.compile("(\\d*h)?\\s?(\\d*m)?"); Matcher matcher = pattern.matcher(formattedInvestmentAmount); int minutes = 0; if (!matcher.find()) { throw new InvestmentParsingException(); } String[] timeValues = matcher.group().split("\\s"); minutes += getMinutesFor(timeValues[0]); if (timeValues.length > 1) { minutes += getMinutesFor(timeValues[1]); } return minutes; } int parseMinutes(String formattedInvestmentAmount); }### Answer: @Test public void emptyStringShouldBeParsedToZeroMinutes() throws InvestmentParsingException { assertThat(parser.parseMinutes("")).isEqualTo(0); } @Test public void shouldParseHoursProperly() throws InvestmentParsingException { assertThat(parser.parseMinutes("3h")).isEqualTo(180); } @Test public void shouldParseMinutesProperly() throws InvestmentParsingException { assertThat(parser.parseMinutes("21m")).isEqualTo(21); } @Test public void shouldParseHoursAndMinutesProperly() throws InvestmentParsingException { assertThat(parser.parseMinutes("3h 70m")).isEqualTo(250); } @Test(expected = InvestmentParsingException.class) public void shouldThrowExceptionWhenGivenStringIsNotParsable() throws InvestmentParsingException { parser.parseMinutes("abc0m"); }
### Question: ProfitCalculator { public double calculateProfit(QualityViolation violation) { double nonRemediationCosts = violation.getNonRemediationCosts() * (violation.getArtefact().hasManualEstimate() ? violation.getArtefact().getManualEstimate() / 100.0 : violation.getArtefact().getChangeProbability()); return violation.getRequirement().isAutomaticallyFixable() ? nonRemediationCosts - violation.getRemediationCosts() : nonRemediationCosts - violation.getRemediationCosts() * violation.getArtefact().getSecureChangeProbability(); } double calculateProfit(QualityViolation violation); }### Answer: @Test public void profitForAutomaticFixableViolation() { when(requirement.isAutomaticallyFixable()).thenReturn(true); assertThat(calculator.calculateProfit(violation)).isEqualTo(2.0); } @Test public void profitForNotAutomaticFixableViolation() { when(requirement.isAutomaticallyFixable()).thenReturn(false); when(artefact.getSecureChangeProbability()).thenReturn(1.1); assertThat(calculator.calculateProfit(violation)).isEqualTo(1.0); } @Test public void profitForViolationWhereArtefactHasManualEstimate() { when(requirement.isAutomaticallyFixable()).thenReturn(true); when(artefact.getManualEstimate()).thenReturn(80); when(artefact.hasManualEstimate()).thenReturn(true); assertThat(calculator.calculateProfit(violation)).isEqualTo(6.0); }
### Question: WeightedProfitCalculator { public double calculateWeightedProfit(QualityViolation violation) { return profitCalculator.calculateProfit(violation) / violation.getWeightingMetricValue(); } @Autowired WeightedProfitCalculator(ProfitCalculator profitCalculator); double calculateWeightedProfit(QualityViolation violation); }### Answer: @Test public void shouldDivideProfitOfViolationByWeightingMetricValue() { ProfitCalculator profitCalculator = mock(ProfitCalculator.class); when(profitCalculator.calculateProfit(any(QualityViolation.class))).thenReturn(20.0); QualityViolation violation = mock(QualityViolation.class); when(violation.getWeightingMetricValue()).thenReturn(13.0); WeightedProfitCalculator weightedProfitCalculator = new WeightedProfitCalculator(profitCalculator); assertThat(weightedProfitCalculator.calculateWeightedProfit(violation)).isEqualTo(1.54, Delta.delta(0.01)); }
### Question: CommitBasedCodeChangeProbabilityCalculator implements CodeChangeProbabilityCalculator { @Override public double calculateCodeChangeProbability(ScmConnectionSettings connectionSettings, String file) throws CodeChurnCalculationException, ScmConnectionEncodingException { log.info("Calculate code change probability for file {}", file); final CodeChurnCalculator codeChurnCalculator = codeChurnCalculatorFactory.create(connectionSettings); CodeChurn codeChurn = codeChurnCalculator.calculateCodeChurnForLastCommits(connectionSettings, file, numberOfCommits); double changeProbability = 0.0; for (Double codeChurnProportion : codeChurn.getCodeChurnProportions()) { changeProbability += codeChurnProportion * (1 / (double) numberOfCommits); } return Math.min(1.0, changeProbability); } CommitBasedCodeChangeProbabilityCalculator(CodeChurnCalculatorFactory codeChurnCalculatorFactory, int numberOfCommits); @Override double calculateCodeChangeProbability(ScmConnectionSettings connectionSettings, String file); }### Answer: @Test public void codeChurnForOneLastCommit() throws CodeChurnCalculationException, ScmConnectionEncodingException { fakeCodeChurnCalculator.addCodeChurnWithoutDay("A", new CodeChurn(Arrays.asList(0.8))); CodeChangeProbabilityCalculator codeChangeProbabilityCalculator = new CommitBasedCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, 1); assertThat(codeChangeProbabilityCalculator.calculateCodeChangeProbability(dummyConnectionSettings, "A")).isEqualTo(0.8); } @Test public void codeChurnForManyLastCommits() throws CodeChurnCalculationException, ScmConnectionEncodingException { fakeCodeChurnCalculator.addCodeChurnWithoutDay("A", new CodeChurn(Arrays.asList(0.8))); fakeCodeChurnCalculator.addCodeChurnWithoutDay("A", new CodeChurn(Arrays.asList(1.0))); fakeCodeChurnCalculator.addCodeChurnWithoutDay("A", new CodeChurn(Arrays.asList(0.2))); CodeChangeProbabilityCalculator codeChangeProbabilityCalculator = new CommitBasedCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, 4); assertThat(codeChangeProbabilityCalculator.calculateCodeChangeProbability(dummyConnectionSettings, "A")).isEqualTo(0.5); } @Test public void maxPossibleProbabilityShouldBeOne() throws CodeChurnCalculationException, ScmConnectionEncodingException { fakeCodeChurnCalculator.addCodeChurnWithoutDay("A", new CodeChurn(Arrays.asList(10.0))); CodeChangeProbabilityCalculator codeChangeProbabilityCalculator = new CommitBasedCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, 1); assertThat(codeChangeProbabilityCalculator.calculateCodeChangeProbability(dummyConnectionSettings, "A")).isEqualTo(1.0); }
### Question: CodeChurnCalculatorFactory { public CodeChurnCalculator create(ScmConnectionSettings connectionSettings) { if (connectionSettings.getType() == SupportedScmSystem.SVN.getType()) { return svnCodeChurnCalculator; } throw new UnsupportedScmSystem(); } @Autowired CodeChurnCalculatorFactory(SvnCodeChurnCalculatorService svnCodeChurnCalculator); CodeChurnCalculator create(ScmConnectionSettings connectionSettings); }### Answer: @Test(expected = UnsupportedScmSystem.class) public void shouldFailForNotSupportedSvmTypesWithException() { ScmConnectionSettings connectionSettings = mock(ScmConnectionSettings.class); when(connectionSettings.getType()).thenReturn(Integer.MAX_VALUE); codeChurnCalculatorFactory.create(connectionSettings); } @Test public void createSvnCodeChurnCalculatorForSvnType() { ScmConnectionSettings connectionSettings = mock(ScmConnectionSettings.class); when(connectionSettings.getType()).thenReturn(SupportedScmSystem.SVN.getType()); assertThat(codeChurnCalculatorFactory.create(connectionSettings)).isInstanceOf(SvnCodeChurnCalculatorService.class); }
### Question: SvnServerAvailabilityCheckerService implements ScmAvailabilityCheckerService { @Override public boolean isAvailable(ScmConnectionSettings connectionSettings) { if (connectionSettings == null || Strings.isNullOrEmpty(connectionSettings.getUrl())) { return false; } try { SvnRepositoryFactory.create(connectionSettings).testConnection(); log.info("The given svn server is reachable with connection settings: {}", connectionSettings); return true; } catch (SVNException e) { log.warn("The given svn server is not reachable during connection check.", e); return false; } } @Override boolean isAvailable(ScmConnectionSettings connectionSettings); }### Answer: @Test public void notAvailableWhenScmSettingsAreNull() { assertThat(availabilityCheckerService.isAvailable(null)).isFalse(); } @Test public void notAvailableWhenUrlOfScmSettingsIsNull() { assertThat(availabilityCheckerService.isAvailable(new ScmConnectionSettings(null))).isFalse(); } @Test public void notAvailableWhenUrlOfScmSettingsIsEmpty() { assertThat(availabilityCheckerService.isAvailable(new ScmConnectionSettings(""))).isFalse(); }
### Question: SvnFileRevision { String getFilePartOfOldPath(ScmConnectionSettings connectionSettings) throws SVNException { SVNURL svnurl = SVNURL.parseURIEncoded(connectionSettings.getUrl()); List<String> splittedBasePath = splitUrl(svnurl.getPath()); List<String> splittedOldPath = splitUrl(oldPath); int i = 0; boolean foundBeginningOfSomeCommonParts = false; for (String s : splittedBasePath) { if (!foundBeginningOfSomeCommonParts && s.equalsIgnoreCase(splittedOldPath.get(0))) { foundBeginningOfSomeCommonParts = true; } if (foundBeginningOfSomeCommonParts) { i++; } } StringBuilder filePart = new StringBuilder(); boolean isFirst = true; for (; i < splittedOldPath.size(); i++) { if (!isFirst) { filePart.append('/'); } filePart.append(splittedOldPath.get(i)); isFirst = false; } return filePart.toString(); } }### Answer: @Test public void shouldParseFilePartOutOfOldPathProperly() throws SVNException { ScmConnectionSettings connectionSettings = new ScmConnectionSettings("http: SvnFileRevision fileRevision = new SvnFileRevision(0L, "/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/reloading/ManagedReloadingStrategy.java", null); assertThat(fileRevision.getFilePartOfOldPath(connectionSettings)).isEqualTo("org/apache/commons/configuration/reloading/ManagedReloadingStrategy.java"); }
### Question: SvnFile { int countLines() { if (content.isEmpty()) { return 0; } return content.split(lineSeparator).length; } SvnFile(String content, String lineSeparator); }### Answer: @Test public void countLinesWithSuppliedSeparator() { assertThat(new SvnFile("1a2a3", "a").countLines()).isEqualTo(3); } @Test public void shouldNotFailOnEmptyText() { assertThat(new SvnFile("", "a").countLines()).isEqualTo(0); } @Test public void countLineCorrectlyWhenSeparatorConsistsOfManyCharacters() { assertThat(new SvnFile("111abc222abc333", "abc").countLines()).isEqualTo(3); }
### Question: ProjectInformation implements Comparable { @Override public int compareTo(Object o) { if (o != null) { ProjectInformation otherProjectInformation = (ProjectInformation) o; if (otherProjectInformation.getName() != null && this.getName() != null) { return this.name.compareToIgnoreCase(otherProjectInformation.getName()); } } return 1; } ProjectInformation(); ProjectInformation(String name, String resourceKey); @Override int compareTo(Object o); }### Answer: @Test public void A_is_sorted_before_B() { assertThat(A.compareTo(B)).isEqualTo(comesBefore); } @Test public void a_is_sorted_before_B() { assertThat(a.compareTo(B)).isEqualTo(comesBefore); } @Test public void B_is_sorted_after_A() { assertThat(B.compareTo(A)).isEqualTo(comesAfter); } @Test public void A_and_a_are_the_same() { assertThat(a.compareTo(A)).isEqualTo(areTheSame); } @Test public void compared_to_null_is_the_same() { assertThat(B.compareTo(null)).isEqualTo(comesAfter); } @Test public void compared_to_null_name_is_sorted_after() { assertThat(B.compareTo(nullName)).isEqualTo(comesAfter); } @Test public void compared__valid_projectInfo_to_null_is_sorted_after() { assertThat(nullName.compareTo(A)).isEqualTo(comesAfter); }
### Question: MetricCollectorService { public double collectMetricForResource(SonarConnectionSettings connectionSettings, String resourceKey, String metricIdentifier) throws ResourceNotFoundException { if (!connectionSettings.hasProject()) { throw new IllegalArgumentException("you can only collect metric value for a resource with connection settings that has a project"); } Sonar sonar = new Sonar(new HttpClient4Connector(connectionSettings.asHostObject())); Resource resource = sonar.find(ResourceQuery.create(resourceKey).setMetrics(metricIdentifier)); if (resource == null) { log.debug("Could not find measurement for metric {} at resource {}", metricIdentifier, resourceKey); return DEFAULT_VALUE; } Double metricValue = resource.getMeasureValue(metricIdentifier); if (metricValue == null) { log.error("Metric identifier " + metricIdentifier + " is not supported by the given Sonar server at " + connectionSettings.toString()); throw new ResourceNotFoundException("Could not find metric with identifier: " + metricIdentifier); } log.debug("{} = {} for {}", metricIdentifier, metricValue, resourceKey); return metricValue; } double collectMetricForResource(SonarConnectionSettings connectionSettings, String resourceKey, String metricIdentifier); }### Answer: @Test(expected = IllegalArgumentException.class) public void shouldFailWhenConnectionSettingsMissProjectAttribute() throws ResourceNotFoundException { new MetricCollectorService().collectMetricForResource(new SonarConnectionSettings("dummy"), "", ""); }
### Question: ResourcesCollectorService { public Collection<Resource> collectAllResourcesForProject(SonarConnectionSettings connectionSettings) { if (!connectionSettings.hasProject()) { throw new IllegalArgumentException("you can only collect resources with connection settings that has a project"); } log.info("Start collecting all classes for project {} at Sonar server", connectionSettings.getProject()); Sonar sonar = new Sonar(new HttpClient4Connector(connectionSettings.asHostObject())); List<Resource> resources = sonar.findAll(ResourceQuery.create(connectionSettings.getProject()) .setAllDepths() .setScopes("FIL") .setQualifiers("FIL")); log.info("Found {} classes for project {}", resources.size(), connectionSettings.getProject()); return resources; } Collection<Resource> collectAllResourcesForProject(SonarConnectionSettings connectionSettings); }### Answer: @Test(expected = IllegalArgumentException.class) public void shouldFailWhenConnectionSettingsMissProjectAttribute() { new ResourcesCollectorService().collectAllResourcesForProject(new SonarConnectionSettings("dummy")); }
### Question: SonarConnectionCheckerService { public boolean isReachable(SonarConnectionSettings connectionSettings) { if (connectionSettings == null || Strings.isNullOrEmpty(connectionSettings.getUrl())) { return false; } HttpClient4Connector connector = new HttpClient4Connector(connectionSettings.asHostObject()); try { return connector.getHttpClient() .execute(new HttpGet(connectionSettings.getUrl() + "/api/metrics")).getStatusLine().getStatusCode() == OK; } catch (IOException e) { log.info("Sonar is not reachable during connection check.", e); return false; } } boolean isReachable(SonarConnectionSettings connectionSettings); }### Answer: @Test public void notReachableWhenConnectionSettingsAreNull() { assertThat(sonarConnectionCheckerService.isReachable(null)).isFalse(); } @Test public void notReachableWhenUrlOfConnectionSettingsIsNull() { assertThat(sonarConnectionCheckerService.isReachable(new SonarConnectionSettings(null))).isFalse(); } @Test public void notReachableWhenUrlOfConnectionSettingsIsEmpty() { assertThat(sonarConnectionCheckerService.isReachable(new SonarConnectionSettings(""))).isFalse(); }
### Question: CodeChangeProbabilityCalculatorFactory { CodeChangeProbabilityCalculator create(CodeChangeSettings codeChangeSettings) { if (codeChangeSettings.getMethod() == SupportedCodeChangeProbabilityMethod.WEIGHTED.getId()) { return new WeightedCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, LocalDate.now(), codeChangeSettings.getDays()); } else if (codeChangeSettings.getMethod() == SupportedCodeChangeProbabilityMethod.COMMIT_BASED.getId()) { return new CommitBasedCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, codeChangeSettings.getNumberOfCommits()); } else { return new DefaultCodeChangeProbabilityCalculator(codeChurnCalculatorFactory, LocalDate.now(), codeChangeSettings.getDays()); } } @Autowired CodeChangeProbabilityCalculatorFactory(CodeChurnCalculatorFactory codeChurnCalculatorFactory); }### Answer: @Test public void createCalculatorForDefaultSetting() { assertThat(codeChangeProbabilityCalculatorFactory.create(CodeChangeSettings.defaultSetting(0))) .isInstanceOf(DefaultCodeChangeProbabilityCalculator.class); } @Test public void createCalculatorWithCorrectNumberOfDaysForDefaultSetting() { assertThat(((DefaultCodeChangeProbabilityCalculator) codeChangeProbabilityCalculatorFactory.create(CodeChangeSettings.defaultSetting(30))).getDays()) .isEqualTo(30); } @Test public void createCalculatorForWeightedSetting() { assertThat(codeChangeProbabilityCalculatorFactory.create(CodeChangeSettings.weightedSetting(0))) .isInstanceOf(WeightedCodeChangeProbabilityCalculator.class); } @Test public void createCalculatorWithCorrectNumberOfDaysForWeightedSetting() { assertThat(((WeightedCodeChangeProbabilityCalculator) codeChangeProbabilityCalculatorFactory.create(CodeChangeSettings.weightedSetting(30))).getDays()) .isEqualTo(30); }
### Question: SecureChangeProbabilityCalculator { public double calculateSecureChangeProbability(QualityProfile qualityProfile, SonarConnectionSettings sonarConnectionSettings, Artefact artefact) throws ResourceNotFoundException { log.info("Calculate secure change probability for artefact {}", artefact.getName()); double secureChangeProbability = 1.0; for (ChangeRiskAssessmentFunction riskAssessmentFunction : qualityProfile.getChangeRiskAssessmentFunctions()) { final double metricValueForArtefact = metricCollectorService.collectMetricForResource(sonarConnectionSettings, artefact.getSonarIdentifier(), riskAssessmentFunction.getMetricIdentifier()); secureChangeProbability += riskAssessmentFunction.getRiskChargeAmount(metricValueForArtefact); } return secureChangeProbability; } @Autowired SecureChangeProbabilityCalculator(MetricCollectorService metricCollectorService); double calculateSecureChangeProbability(QualityProfile qualityProfile, SonarConnectionSettings sonarConnectionSettings, Artefact artefact); }### Answer: @Test public void profileWithNoChangeRiskAssessmentFunctions() throws ResourceNotFoundException { assertThat(secureChangeProbabilityCalculator.calculateSecureChangeProbability( profile, mock(SonarConnectionSettings.class), mock(Artefact.class))).isEqualTo(1.0); } @Test public void profileWithOneChangeRiskAssessmentFunction() throws ResourceNotFoundException { metricCollectorService.addMetricValue("A", "metric", 9.0); profile.addChangeRiskAssessmentFunction(new ChangeRiskAssessmentFunction(profile, "metric", Sets.newHashSet(new RiskCharge(0.2, "<", 10.0)))); assertThat(secureChangeProbabilityCalculator.calculateSecureChangeProbability( profile, mock(SonarConnectionSettings.class), artefact)).isEqualTo(1.2); } @Test public void profileWithManyChangeRiskAssessmentFunctions() throws ResourceNotFoundException { metricCollectorService.addMetricValue("A", "metric1", 9.0); metricCollectorService.addMetricValue("A", "metric2", -1.0); metricCollectorService.addMetricValue("A", "metric3", 0.0); profile.addChangeRiskAssessmentFunction(new ChangeRiskAssessmentFunction(profile, "metric1", Sets.newHashSet(new RiskCharge(0.2, "<", 10.0)))); profile.addChangeRiskAssessmentFunction(new ChangeRiskAssessmentFunction(profile, "metric2", Sets.newHashSet(new RiskCharge(0.11, ">", -2.0)))); profile.addChangeRiskAssessmentFunction(new ChangeRiskAssessmentFunction(profile, "metric3", Sets.newHashSet(new RiskCharge(0.005, ">=", 0.0)))); assertThat(secureChangeProbabilityCalculator.calculateSecureChangeProbability( profile, mock(SonarConnectionSettings.class), artefact)).isEqualTo(1.315); }
### Question: AnalyzerRunnable implements Runnable { @Override public void run() { Project project = projectRepository.findOne(projectId); if (project != null) { project.setHadAnalysis(true); projectRepository.save(project); log.info("Start analyzer run for project {}", project.getName()); qualityAnalyzerService.analyzeProject(project); log.info("Finished analyzer run for project {}", project.getName()); } else { log.error("Could not find project with id " + projectId + " for starting an analyzer run!"); } } AnalyzerRunnable(Project project, ProjectRepository projectRepository, QualityAnalyzerService qualityAnalyzerService); @Override void run(); }### Answer: @Test public void retrieveProjectWithRepositoryFromDatabaseAndTriggerAnalysisAfterwards() { analyzerRunnable.run(); InOrder inOrder = inOrder(projectRepository, analyzerService); inOrder.verify(projectRepository).findOne(1L); inOrder.verify(analyzerService).analyzeProject(project); inOrder.verifyNoMoreInteractions(); } @Test public void markProjectAsHadAnalysis() { analyzerRunnable.run(); verify(project).setHadAnalysis(true); } @Test public void executedProjectShouldBeSavedToDatabaseAfterMarkedAsHadAnalysis() { analyzerRunnable.run(); InOrder inOrder = inOrder(project, projectRepository); inOrder.verify(project).setHadAnalysis(true); inOrder.verify(projectRepository).save(project); } @Test public void notFailWhenProjectIsNotRetrievableViaRepository() { when(projectRepository.findOne(1L)).thenReturn(null); analyzerRunnable.run(); }
### Question: DefaultQualityAnalyzerScheduler implements QualityAnalyzerScheduler { public boolean scheduleAnalyzer(Project project) { if (alreadyScheduledProjects.contains(project)) { log.info("Project {} is already scheduled!", project.getName()); return false; } alreadyScheduledProjects.add(project); QualityAnalyzerService qualityAnalyzerService = createDefaultQualityAnalyzer(); scheduler.schedule(new AnalyzerRunnable(project, projectRepository, qualityAnalyzerService), new CronTrigger(project.getCronExpression())); log.info("Scheduled analyzer job for project {} with cron expression {}", project.getName(), project.getCronExpression()); return true; } @Autowired DefaultQualityAnalyzerScheduler(ProjectRepository projectRepository, ViolationsCalculatorService violationsCalculatorService, ScmAvailabilityCheckerServiceFactory scmAvailabilityCheckerServiceFactory, CodeChangeProbabilityCalculatorFactory codeChangeProbabilityCalculatorFactory, SecureChangeProbabilityCalculator secureChangeProbabilityCalculator, QualityViolationCostsCalculator costsCalculator, QualityAnalysisRepository qualityAnalysisRepository); void executeAnalyzer(Project project); boolean scheduleAnalyzer(Project project); }### Answer: @Test public void scheduleProjectForAnalysis() { assertThat(analyzerScheduler.scheduleAnalyzer(project)).isTrue(); } @Test public void failToScheduleProjectTwice() { analyzerScheduler.scheduleAnalyzer(project); assertThat(analyzerScheduler.scheduleAnalyzer(project)).isFalse(); } @Test public void scheduledProjectShouldNotBeMarkedAsHadAnalysis() { analyzerScheduler.scheduleAnalyzer(project); assertThat(project.hadAnalysis()).isFalse(); }
### Question: DefaultQualityAnalyzerScheduler implements QualityAnalyzerScheduler { public void executeAnalyzer(Project project) { project.setHadAnalysis(true); projectRepository.save(project); QualityAnalyzerService qualityAnalyzerService = createDefaultQualityAnalyzer(); scheduler.execute(new AnalyzerRunnable(project, projectRepository, qualityAnalyzerService)); log.info("Executing analyzer job for project {}", project.getName()); } @Autowired DefaultQualityAnalyzerScheduler(ProjectRepository projectRepository, ViolationsCalculatorService violationsCalculatorService, ScmAvailabilityCheckerServiceFactory scmAvailabilityCheckerServiceFactory, CodeChangeProbabilityCalculatorFactory codeChangeProbabilityCalculatorFactory, SecureChangeProbabilityCalculator secureChangeProbabilityCalculator, QualityViolationCostsCalculator costsCalculator, QualityAnalysisRepository qualityAnalysisRepository); void executeAnalyzer(Project project); boolean scheduleAnalyzer(Project project); }### Answer: @Test public void executedProjectShouldBeMarkedAsHadAnalysis() { analyzerScheduler.executeAnalyzer(project); assertThat(project.hadAnalysis()).isTrue(); } @Test public void executedProjectShouldBeSavedToDatabaseAfterMarkedAsHadAnalysis() { analyzerScheduler.executeAnalyzer(project); InOrder inOrder = inOrder(project, projectRepository); inOrder.verify(project).setHadAnalysis(true); inOrder.verify(projectRepository).save(project); }
### Question: QualityViolationCostsCalculator { public int calculateRemediationCosts(SonarConnectionSettings sonarConnectionSettings, ViolationOccurence violation) throws ResourceNotFoundException { log.info("Calculating remediation costs for {} with violated criteria {}", violation.getArtefact().getName(), violation.getRequirement().getCriteria()); return calculateCosts(sonarConnectionSettings, violation, violation.getRequirement().getRemediationCosts()); } @Autowired QualityViolationCostsCalculator(MetricCollectorService metricCollectorService); int calculateRemediationCosts(SonarConnectionSettings sonarConnectionSettings, ViolationOccurence violation); int calculateNonRemediationCosts(SonarConnectionSettings sonarConnectionSettings, ViolationOccurence violation); }### Answer: @Test public void calculateRemediationCostsProperlyForGreaterOperator() throws ResourceNotFoundException { QualityRequirement requirement = new QualityRequirement(qualityProfile, 20, 30, 100, "nloc", new QualityCriteria("metric", ">", 10.0)); ViolationOccurence violation = new ViolationOccurence(requirement, artefact, 0); assertThat(costsCalculator.calculateRemediationCosts(connectionSettings, violation)).isEqualTo(216); } @Test public void calculateRemediationCostsProperlyForLessOperator() throws ResourceNotFoundException { QualityRequirement requirement = new QualityRequirement(qualityProfile, 20, 30, 100, "nloc", new QualityCriteria("metric", "<", 1.0)); ViolationOccurence violation = new ViolationOccurence(requirement, artefact, 0); assertThat(costsCalculator.calculateRemediationCosts(connectionSettings, violation)).isEqualTo(48); }
### Question: QualityViolationCostsCalculator { public int calculateNonRemediationCosts(SonarConnectionSettings sonarConnectionSettings, ViolationOccurence violation) throws ResourceNotFoundException { log.info("Calculating non-remediation costs for {} with violated criteria {}", violation.getArtefact().getName(), violation.getRequirement().getCriteria()); return calculateCosts(sonarConnectionSettings, violation, violation.getRequirement().getNonRemediationCosts()); } @Autowired QualityViolationCostsCalculator(MetricCollectorService metricCollectorService); int calculateRemediationCosts(SonarConnectionSettings sonarConnectionSettings, ViolationOccurence violation); int calculateNonRemediationCosts(SonarConnectionSettings sonarConnectionSettings, ViolationOccurence violation); }### Answer: @Test public void calculateNonRemediationCostsProperlyForGreaterEqualsOperator() throws ResourceNotFoundException { QualityRequirement requirement = new QualityRequirement(qualityProfile, 20, 30, 100, "nloc", new QualityCriteria("metric", ">=", 5.0)); ViolationOccurence violation = new ViolationOccurence(requirement, artefact, 0); assertThat(costsCalculator.calculateNonRemediationCosts(connectionSettings, violation)).isEqualTo(108); }
### Question: Artefact implements Serializable { public String getFilename() { if (name.isEmpty()) { return ""; } return name.replace('.', '/') + ".java"; } protected Artefact(); Artefact(String name, String sonarIdentifier); String getFilename(); String getShortClassName(); boolean hasManualEstimate(); }### Answer: @Test public void shouldConvertPackageNameToFilenameProperly() { assertThat(new Artefact("org.my.class.AbcDe", "").getFilename()).isEqualTo("org/my/class/AbcDe.java"); } @Test public void shouldConvertClassNameToFilenameProperly() { assertThat(new Artefact("AbcDe", "").getFilename()).isEqualTo("AbcDe.java"); } @Test public void shouldConvertEmptyPackageNameToFilenameProperly() { assertThat(new Artefact("", "").getFilename()).isEqualTo(""); }
### Question: Artefact implements Serializable { public String getShortClassName() { String className = null; for (String packageName : Splitter.on('.').split(name)) { className = packageName; } return className; } protected Artefact(); Artefact(String name, String sonarIdentifier); String getFilename(); String getShortClassName(); boolean hasManualEstimate(); }### Answer: @Test public void shouldConvertFullyQualifiedClassNameToShortClassName() { assertThat(new Artefact("org.util.MyClass", "").getShortClassName()).isEqualTo("MyClass"); } @Test public void shouldConvertFullyQualifiedClassNameWithoutPackagesToShortClassName() { assertThat(new Artefact("Class123", "").getShortClassName()).isEqualTo("Class123"); } @Test public void shouldConvertEmptyFullyQualifiedClassNameToShortClassName() { assertThat(new Artefact("", "").getShortClassName()).isEqualTo(""); }