Skip to content

Commit

Permalink
Merge pull request #677 from Onlineberatung/OB-7112-improve-error-log…
Browse files Browse the repository at this point in the history
…ging-rocketchat

Ob 7112 improve error logging rocketchat
  • Loading branch information
tkuzynow authored Dec 6, 2023
2 parents 73f6779 + c6068a4 commit 274d04d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void logInternalServerError(Exception exception) {
* @param ex the exception
*/
public static void logRocketChatError(Exception ex) {
LOGGER.error("{}{})", ROCKET_CHAT_ERROR_TEXT, getStackTrace(ex));
LOGGER.error("{}{}{}", ROCKET_CHAT_ERROR_TEXT, ex.getMessage(), getStackTrace(ex));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ void assignEnquiry_Should_LogError_When_RCRemoveGroupMembersFails() {
verify(sessionService, times(1))
.updateConsultantAndStatusForSession(
U25_SESSION_WITHOUT_CONSULTANT, CONSULTANT_WITH_AGENCY, SessionStatus.IN_PROGRESS);
verifyAsync((a) -> verify(logger, times(1)).error(anyString(), anyString(), anyString()));
verifyAsync(
(a) -> verify(logger, times(1)).error(anyString(), anyString(), anyString(), anyString()));
}

@Test
Expand Down Expand Up @@ -294,7 +295,8 @@ void assignEnquiry_Should_LogError_WhenAddPeerConsultantToFeedbackGroupFails() {

verifyConsultantAndSessionHaveBeenChecked(
U25_SESSION_WITHOUT_CONSULTANT, CONSULTANT_WITH_AGENCY);
verifyAsync((a) -> verify(logger, times(1)).error(anyString(), anyString(), anyString()));
verifyAsync(
(a) -> verify(logger, times(1)).error(anyString(), anyString(), anyString(), anyString()));
verify(sessionService, times(1))
.updateConsultantAndStatusForSession(
U25_SESSION_WITHOUT_CONSULTANT, CONSULTANT_WITH_AGENCY, IN_PROGRESS);
Expand All @@ -311,7 +313,8 @@ void assignEnquiry_Should_LogError_WhenRemoveSystemMessagesFromGroupFails() {

verifyConsultantAndSessionHaveBeenChecked(
U25_SESSION_WITHOUT_CONSULTANT, CONSULTANT_WITH_AGENCY);
verifyAsync((a) -> verify(logger, times(1)).error(anyString(), anyString(), anyString()));
verifyAsync(
(a) -> verify(logger, times(1)).error(anyString(), anyString(), anyString(), anyString()));
verify(sessionService, times(1))
.updateConsultantAndStatusForSession(
U25_SESSION_WITHOUT_CONSULTANT, CONSULTANT_WITH_AGENCY, IN_PROGRESS);
Expand All @@ -328,7 +331,8 @@ void assignEnquiry_Should_LogError_When_RemoveSystemMessagesFromFeedbackChatFail

verifyConsultantAndSessionHaveBeenChecked(
U25_SESSION_WITHOUT_CONSULTANT, CONSULTANT_WITH_AGENCY);
verifyAsync((a) -> verify(logger, times(1)).error(anyString(), anyString(), anyString()));
verifyAsync(
(a) -> verify(logger, times(1)).error(anyString(), anyString(), anyString(), anyString()));
verify(sessionService, times(1))
.updateConsultantAndStatusForSession(
U25_SESSION_WITHOUT_CONSULTANT, CONSULTANT_WITH_AGENCY, IN_PROGRESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,10 @@ public void logForbidden_Should_LogExceptionStackTrace() {
LogService.logForbidden(exception);
verify(exception, atLeastOnce()).printStackTrace(any(PrintWriter.class));
}

@Test
public void logRocketChatError_Should_LogExceptionMessage() {
LogService.logRocketChatError(exception);
verify(exception, atLeastOnce()).getMessage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void retrieveUserWithInactiveGroupsMap_ShouldLogError_WhenFetchOfInactive

inactivePrivateGroupsProvider.retrieveUserWithInactiveGroupsMap();

verify(this.logger, times(1)).error(anyString(), anyString(), anyString());
verify(this.logger, times(1)).error(anyString(), anyString(), anyString(), anyString());
}

@Test
Expand Down

0 comments on commit 274d04d

Please sign in to comment.