TS13: Remove duplicate tests and fix wording
This commit is contained in:
parent
19b5e71f6c
commit
c10bbb59af
@ -146,41 +146,6 @@ public class HorseEndpointTest {
|
||||
assertEquals(newHorse.getOwner(), response.getBody().getOwner());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Updating a horse with the correct parameters will return 200 and the new HorseDto")
|
||||
public void updatingNewHorse_correctParameters_shouldReturnStatus200AndHorse() {
|
||||
HorseDto newHorse = new HorseDto("Zephyr", "Nice horse", (short) 4, Date.valueOf("2020-01-01"), ERace.APPALOOSA, "files/test.png", null);
|
||||
|
||||
// Create a new horse
|
||||
HttpEntity<HorseDto> request = new HttpEntity<>(newHorse);
|
||||
ResponseEntity<HorseDto> response = REST_TEMPLATE
|
||||
.exchange(BASE_URL + port + HORSE_URL, HttpMethod.POST, request, HorseDto.class);
|
||||
|
||||
// Update the horse
|
||||
newHorse.setId(response.getBody().getId());
|
||||
newHorse.setName("Katrina");
|
||||
newHorse.setDescription("Fast horse");
|
||||
newHorse.setScore((short) 3);
|
||||
newHorse.setBirthday(Date.valueOf("2005-01-01"));
|
||||
newHorse.setRace(ERace.MORGAN);
|
||||
newHorse.setImagePath("files/katrina.png");
|
||||
newHorse.setOwner(null);
|
||||
|
||||
request = new HttpEntity<>(newHorse);
|
||||
response = REST_TEMPLATE
|
||||
.exchange(BASE_URL + port + HORSE_URL + '/' + newHorse.getId(), HttpMethod.PUT, request, HorseDto.class);
|
||||
|
||||
// Compare everything except timestamps
|
||||
assertEquals(response.getStatusCode(), HttpStatus.OK);
|
||||
assertEquals(newHorse.getId(), response.getBody().getId());
|
||||
assertEquals(newHorse.getName(), response.getBody().getName());
|
||||
assertEquals(newHorse.getDescription(), response.getBody().getDescription());
|
||||
assertEquals(newHorse.getScore(), response.getBody().getScore());
|
||||
assertEquals(newHorse.getBirthday().toString(), response.getBody().getBirthday().toString());
|
||||
assertEquals(newHorse.getImagePath(), response.getBody().getImagePath());
|
||||
assertEquals(newHorse.getOwner(), response.getBody().getOwner());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Uploading an image in the correct format will return HTTP 201")
|
||||
public void addingNewImage_correctFormat_shouldReturnStatus201() {
|
||||
|
@ -195,24 +195,7 @@ public class OwnerEndpointTest {
|
||||
assertEquals(newOwner.getId(), response.getBody().getId());
|
||||
assertEquals(newOwner.getName(), response.getBody().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Deleting an existing owner without horses will return HTTP 204")
|
||||
public void deletingOwner_existingNoOwnersOwned_shouldReturnStatus204() {
|
||||
// Create the owner
|
||||
OwnerDto newOwner = new OwnerDto("Chad");
|
||||
|
||||
HttpEntity<OwnerDto> request = new HttpEntity<>(newOwner);
|
||||
ResponseEntity<OwnerDto> response = REST_TEMPLATE
|
||||
.exchange(BASE_URL + port + OWNER_URL, HttpMethod.POST, request, OwnerDto.class);
|
||||
|
||||
// Delete and test if deleted
|
||||
ResponseEntity res = REST_TEMPLATE
|
||||
.exchange(BASE_URL + port + OWNER_URL + '/' + response.getBody().getId(), HttpMethod.DELETE, null, new ParameterizedTypeReference<OwnerDto>() {});
|
||||
|
||||
assertEquals(res.getStatusCode(), HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@DisplayName("Deleting an existing owner without horses will return HTTP 204")
|
||||
public void deletingOwner_existingNoHorsesOwned_shouldReturnStatus204() {
|
||||
|
Reference in New Issue
Block a user