Здравствуйте, пожалуйста, я новичок в интеграционных тестах. Я сталкиваюсь с некоторыми трудностями с моим статусом утверждения.
вот ошибка
java.lang.AssertionError: Ожидаемый статус: 204 Фактический: 404
вот тестовый код
@Test
@Transactional
public void deleteCustomerTest() throws Exception{
//initialize database
customerRepository.saveAndFlush(customer);
int dataBaseSizeBeforeDelete = customerRepository.findAll().size();
//Get the customer to be deleted
restCustomerMockMvc.perform(delete( "/v1/customers/{uidpk}", customer.getUidpk())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isNoContent());
//Validate the database is empty
List<Customer> customers = customerRepository.findAll();
assertThat(customers).hasSize(dataBaseSizeBeforeDelete - 1);
}
вот запрос
@DeleteMapping(CUSTOMER_ID_ENDPOINT)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@ApiResponses(value = {
@ApiResponse(code = 204, message = "The Customer was deleted", response = CustomerDto.class),
@ApiResponse(code = 404, message = "The Customer with the given uidpk id was not found", response = ResponseError.class),
@ApiResponse(code = 500, message = "Unexpected error")
})
@Timed
public ResponseEntity deleteCustomer(@PathVariable Long uidpk){
log.debug("[CustomerResource] DELETE {} : Deleting customer ({})", CUSTOMER_ID_ENDPOINT, uidpk );
try {
customerService.delete(uidpk);
}catch (EmptyResultDataAccessException e){
//No Customer found with this uidpk ID
ResponseError error = new ResponseError(HttpStatus.NOT_FOUND.getReasonPhrase(), "The customer with id " + uidpk+ " was not found");
log.error("[CustomerResource] Customer ({}) does not exist", uidpk);
return new ResponseEntity<>(error,null,HttpStatus.NOT_FOUND);
}
log.debug("[CustomerResource] Customer ([]) deleted", uidpk);
return new ResponseEntity<>(null,null,HttpStatus.NOT_FOUND);
}
когда я нажимаю на имя функции, ее точка находится в этой строке: .andExpect(status().isNoContent());