Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
VasylyshynDmytro committed Dec 13, 2024
1 parent 6b2f093 commit d402120
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion core/src/test/java/greencity/controller/PlaceControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ void updateStatusWithApprovedStatusDECLINED() throws Exception {
}

@Test
void updateStatusDoesNotSendNotificationButSavesDataWhenStatusIsOther() throws Exception {
void updateStatusDoesNotSendNotificationButSavesDataWhenStatusIsPROPOSED() throws Exception {
UpdatePlaceStatusWithUserEmailDto dto = new UpdatePlaceStatusWithUserEmailDto();
dto.setPlaceName("testPlace");
dto.setNewStatus(PlaceStatus.PROPOSED);
Expand Down Expand Up @@ -674,4 +674,34 @@ void updateStatusDoesNotSendNotificationButSavesDataWhenStatusIsOther() throws E
.sendEmailNotificationChangesPlaceStatus(any(UpdatePlaceStatusWithUserEmailDto.class));
}

@Test
void updateStatusDoesNotSendNotificationButSavesDataWhenStatusIsDELETED() throws Exception {
UpdatePlaceStatusWithUserEmailDto dto = new UpdatePlaceStatusWithUserEmailDto();
dto.setPlaceName("testPlace");
dto.setNewStatus(PlaceStatus.DELETED);
dto.setUserName("testUser");
dto.setEmail("[email protected]");
Place place = new Place();
place.setId(1L);
place.setName("testPlace");
place.setStatus(PlaceStatus.PROPOSED);
when(placeService.updatePlaceStatus(any(UpdatePlaceStatusWithUserEmailDto.class))).thenReturn(dto);
String json = """
{
"placeName": "testPlace",
"newStatus": "PROPOSED",
"userName": "testUser",
"email": "[email protected]"
}
""";

mockMvc.perform(patch(placeLink + "/status")
.contentType(MediaType.APPLICATION_JSON)
.content(json))
.andExpect(status().isOk())
.andExpect(content().string("Status updated successfully for place: testPlace"));
verify(placeService, times(1)).updatePlaceStatus(any(UpdatePlaceStatusWithUserEmailDto.class));
verify(restClient, times(0))
.sendEmailNotificationChangesPlaceStatus(any(UpdatePlaceStatusWithUserEmailDto.class));
}
}

0 comments on commit d402120

Please sign in to comment.