forked from Onlineberatung/onlineBeratung-messageService
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
118 additions
and
14 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
30 changes: 30 additions & 0 deletions
30
src/main/java/de/caritas/cob/messageservice/api/service/LiveEventNotificationService.java
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package de.caritas.cob.messageservice.api.service; | ||
|
||
import static org.apache.commons.lang3.StringUtils.isNotBlank; | ||
|
||
import de.caritas.cob.messageservice.userservice.generated.web.LiveproxyControllerApi; | ||
import lombok.NonNull; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Service class to provide live event triggers to the live proxy endpoint in user service. | ||
*/ | ||
@Service | ||
@RequiredArgsConstructor | ||
public class LiveEventNotificationService { | ||
|
||
private final @NonNull LiveproxyControllerApi liveproxyControllerApi; | ||
|
||
/** | ||
* Triggers a live event to proxy endpoint of user service. | ||
* | ||
* @param rcGroupId the rocket chat group id | ||
*/ | ||
public void sendLiveEvent(String rcGroupId) { | ||
if (isNotBlank(rcGroupId)) { | ||
this.liveproxyControllerApi.sendLiveEvent(rcGroupId); | ||
} | ||
} | ||
|
||
} |
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
45 changes: 45 additions & 0 deletions
45
...test/java/de/caritas/cob/messageservice/api/service/LiveEventNotificationServiceTest.java
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package de.caritas.cob.messageservice.api.service; | ||
|
||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyZeroInteractions; | ||
|
||
import de.caritas.cob.messageservice.userservice.generated.web.LiveproxyControllerApi; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class LiveEventNotificationServiceTest { | ||
|
||
@InjectMocks | ||
private LiveEventNotificationService liveEventNotificationService; | ||
|
||
@Mock | ||
private LiveproxyControllerApi liveproxyControllerApi; | ||
|
||
@Test | ||
public void sendLiveEvent_Should_notTriggerLiveEvent_When_rcGroupIdIsNull() { | ||
this.liveEventNotificationService.sendLiveEvent(null); | ||
|
||
verifyZeroInteractions(this.liveproxyControllerApi); | ||
} | ||
|
||
@Test | ||
public void sendLiveEvent_Should_notTriggerLiveEvent_When_rcGroupIdIsEmpty() { | ||
this.liveEventNotificationService.sendLiveEvent(""); | ||
|
||
verifyZeroInteractions(this.liveproxyControllerApi); | ||
} | ||
|
||
@Test | ||
public void sendLiveEvent_Should_triggerLiveEvent_When_rcGroupIdIsValid() { | ||
this.liveEventNotificationService.sendLiveEvent("valid"); | ||
|
||
verify(this.liveproxyControllerApi, times(1)).sendLiveEvent(eq("valid")); | ||
} | ||
|
||
} |