Skip to content

Commit

Permalink
Merge pull request #32 from virtualidentityag/DIAKONIE-389-fix-removi…
Browse files Browse the repository at this point in the history
…ng-consultants-from-rocketchat

fix: tests
  • Loading branch information
tkuzynow authored Aug 30, 2024
2 parents 5354c9b + 1b1883c commit 10d2119
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public class RocketChatService implements MessageClient {
"Could not get users list from Rocket.Chat";
private static final String USER_LIST_GET_FIELD_SELECTION = "{\"_id\":1}";
private static final Integer PAGE_SIZE = 100;
private static final String ERROR_ROOM_NOT_FOUND = "error-room-not-found";
private final LocalDateTime localDateTime1900 = LocalDateTime.of(1900, 1, 1, 0, 0);

private final LocalDateTime localDateTimeFuture = nowInUtc().plusYears(1L);
Expand Down Expand Up @@ -1355,7 +1356,7 @@ public void removeUserFromGroupIgnoreGroupNotFound(String rcUserId, String rcGro
try {
response = tryRemoveUserFromGroup(rcUserId, rcGroupId);
} catch (Exception ex) {
if (ex.getMessage().contains("error-group-not-found")) {
if (ex.getMessage().contains(ERROR_ROOM_NOT_FOUND)) {
return;
}
log.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ public void removeFromGroupAndIgnoreGroupNotFound() {
session.getGroupId(), consultants)));
}

public void removeFromGroup() {
this.consultantsToRemoveFromSessions.forEach(
((session, consultants) ->
removeConsultantsFromSessionGroup(session.getGroupId(), consultants)));
}

/**
* Removes the given consultant from Rocket.Chat group of given session with rollback on error.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void removeUnauthorizedMembers(
.onSessionConsultants(Map.of(session, consultantsToRemoveFromRocketChat));

if (rcGroupId.equalsIgnoreCase(session.getGroupId())) {
rocketChatRemoveFromGroupOperationService.removeFromGroup();
rocketChatRemoveFromGroupOperationService.removeFromGroupAndIgnoreGroupNotFound();
}
if (rcGroupId.equalsIgnoreCase(session.getFeedbackGroupId())) {
rocketChatRemoveFromGroupOperationService.removeFromFeedbackGroup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ void assignEnquiry_Should_removeAllUnauthorizedMembers_When_sessionIsNotATeamSes
verifyAsync(
(a) ->
verify(this.rocketChatFacade, times(1))
.removeUserFromGroup(consultantToRemove.getRocketChatId(), session.getGroupId()));
.removeUserFromGroupIgnoreGroupNotFound(
consultantToRemove.getRocketChatId(), session.getGroupId()));
verifyAsync(
(a) ->
verify(this.rocketChatFacade, times(1))
Expand Down Expand Up @@ -424,7 +425,8 @@ void assignEnquiry_ShouldNot_removeTeamMembers_When_sessionIsTeamSession() {
verifyAsync(
(a) ->
verify(this.rocketChatFacade, atLeastOnce())
.removeUserFromGroup(consultantToRemove.getRocketChatId(), session.getGroupId()));
.removeUserFromGroupIgnoreGroupNotFound(
consultantToRemove.getRocketChatId(), session.getGroupId()));
verifyAsync(
(a) ->
verify(this.rocketChatFacade, atLeastOnce())
Expand Down

0 comments on commit 10d2119

Please sign in to comment.