-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f754ad
commit 89297af
Showing
1 changed file
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1053,7 +1053,7 @@ void updateDiscountDoesNotThrowExceptionTest() { | |
} | ||
|
||
@Test | ||
void updateFromUI_ShouldUpdatePlaceSuccessfully() { | ||
void updateFromUISucceedsForValidPlaceTest() { | ||
PlaceUpdateDto dto = new PlaceUpdateDto(); | ||
dto.setId(1L); | ||
dto.setName("Updated Place"); | ||
|
@@ -1096,7 +1096,7 @@ void updateFromUI_ShouldUpdatePlaceSuccessfully() { | |
} | ||
|
||
@Test | ||
void updateFromUI_ShouldThrowException_WhenUserNotFound() { | ||
void updateFromUIThrowsNotFoundExceptionForUserTest() { | ||
PlaceUpdateDto dto = getPlaceUpdateDto(); | ||
when(userRepo.findByEmail(anyString())).thenReturn(Optional.empty()); | ||
|
||
|
@@ -1105,7 +1105,7 @@ void updateFromUI_ShouldThrowException_WhenUserNotFound() { | |
} | ||
|
||
@Test | ||
void updateFromUI_ShouldThrowNotFoundException_WhenCategoryNotFound() { | ||
void updateFromUIThrowsNotFoundExceptionForCategoryTest() { | ||
PlaceUpdateDto dto = new PlaceUpdateDto(); | ||
dto.setId(1L); | ||
dto.setCategory(new CategoryDto("Nonexistent Category", "Nonexistent Category", 1L)); | ||
|
@@ -1115,4 +1115,16 @@ void updateFromUI_ShouldThrowNotFoundException_WhenCategoryNotFound() { | |
assertThrows(NotFoundException.class, () -> placeServiceImpl.updateFromUI(dto, null, "[email protected]")); | ||
} | ||
|
||
@Test | ||
void updateCategoryThrowsNotFoundExceptionTest() { | ||
PlaceUpdateDto dto = new PlaceUpdateDto(); | ||
dto.setId(1L); | ||
dto.setCategory(new CategoryDto("Non-existent Category", "Non-existent Category Ua", 2L)); | ||
when(placeRepo.findById(1L)).thenReturn(Optional.of(genericEntity1)); | ||
when(categoryService.findByName("Non-existent Category")).thenThrow(new NotFoundException("Category not found")); | ||
|
||
NotFoundException exception = assertThrows(NotFoundException.class, () -> placeServiceImpl.update(dto)); | ||
assertEquals("Category not found", exception.getMessage()); | ||
verify(placeRepo, never()).save(any(Place.class)); | ||
} | ||
} |