-
Notifications
You must be signed in to change notification settings - Fork 80
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
1809259
commit 74d0c29
Showing
2 changed files
with
26 additions
and
11 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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import static greencity.TestConst.USER_ID; | ||
import static greencity.constant.AppConstant.AUTHORIZATION; | ||
import greencity.dto.econews.InterestingEcoNewsDto; | ||
import greencity.dto.place.UpdatePlaceStatusWithUserEmailDto; | ||
import greencity.dto.user.UserStatusDto; | ||
import greencity.dto.user.UserVO; | ||
import greencity.dto.user.UserManagementDto; | ||
|
@@ -22,6 +23,7 @@ | |
import greencity.dto.PageableAdvancedDto; | ||
import greencity.dto.achievement.UserVOAchievement; | ||
import greencity.enums.EmailNotification; | ||
import greencity.enums.PlaceStatus; | ||
import greencity.enums.Role; | ||
import greencity.enums.UserStatus; | ||
import greencity.message.ScheduledEmailMessage; | ||
|
@@ -55,11 +57,8 @@ | |
import org.springframework.web.context.request.RequestContextHolder; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.Mockito.any; | ||
import static org.mockito.Mockito.anyString; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.*; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class RestClientTest { | ||
|
@@ -679,4 +678,22 @@ void sendEmailNotificationPlacesTest() { | |
verify(restTemplate).exchange(GREEN_CITY_USER_ADDRESS | ||
+ RestTemplateLinks.SEND_SCHEDULED_NOTIFICATION, HttpMethod.POST, entity, Object.class); | ||
} | ||
|
||
@Test | ||
void sendEmailNotificationChangesPlaceStatusTest() { | ||
UpdatePlaceStatusWithUserEmailDto message = new UpdatePlaceStatusWithUserEmailDto(); | ||
message.setPlaceName("TestPlace"); | ||
message.setNewStatus(PlaceStatus.APPROVED); | ||
message.setUserName("TestUser"); | ||
message.setEmail("[email protected]"); | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.APPLICATION_JSON); | ||
HttpEntity<UpdatePlaceStatusWithUserEmailDto> entity = new HttpEntity<>(message, headers); | ||
String expectedUrl = GREEN_CITY_USER_ADDRESS + RestTemplateLinks.SEND_NOTIFICATION_STATUS_PLACE; | ||
when(restTemplate.exchange(eq(expectedUrl), eq(HttpMethod.POST), any(HttpEntity.class), eq(Object.class))) | ||
.thenReturn(ResponseEntity.ok().build()); | ||
restClient.sendEmailNotificationChangesPlaceStatus(message); | ||
verify(restTemplate, times(1)).exchange(eq(expectedUrl), eq(HttpMethod.POST), any(HttpEntity.class), | ||
eq(Object.class)); | ||
} | ||
} |