Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
injectives committed Jan 26, 2023
1 parent bf170a5 commit 0af36b2
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.neo4j.driver.Values.value;
Expand Down Expand Up @@ -365,24 +366,41 @@ void shouldCreateChannelActivityLoggerAndLogDebugMessageOnMessageHandling(Class<
InboundMessageDispatcher dispatcher = new InboundMessageDispatcher(channel, logging);
ResponseHandler handler = mock(ResponseHandler.class);
dispatcher.enqueue(handler);
Runnable loggerVerification = () -> {};

// WHEN
if (SuccessMessage.class.isAssignableFrom(message)) {
dispatcher.handleSuccessMessage(new HashMap<>());
loggerVerification = () -> {
verify(logger).isDebugEnabled();
verify(logger).debug(anyString(), any(Map.class));
};
} else if (FailureMessage.class.isAssignableFrom(message)) {
dispatcher.handleFailureMessage(FAILURE_CODE, FAILURE_MESSAGE);
loggerVerification = () -> {
verify(logger).isDebugEnabled();
verify(logger).debug(anyString(), anyString(), anyString());
};
} else if (RecordMessage.class.isAssignableFrom(message)) {
dispatcher.handleRecordMessage(Values.values());
loggerVerification = () -> {
verify(logger, times(2)).isDebugEnabled();
verify(logger).debug(anyString(), anyString());
};
} else if (IgnoredMessage.class.isAssignableFrom(message)) {
dispatcher.handleIgnoredMessage();
loggerVerification = () -> {
verify(logger).isDebugEnabled();
verify(logger).debug(anyString());
};
} else {
fail("Unexpected message type parameter provided");
}

// THEN
assertTrue(dispatcher.getLog() instanceof ChannelActivityLogger);
assertTrue(dispatcher.getErrorLog() instanceof ChannelErrorLogger);
verify(logger).debug(anyString(), any(Object.class));
loggerVerification.run();
}

@Test
Expand Down

0 comments on commit 0af36b2

Please sign in to comment.