MessagingUtils { @Async public void burstUsersMessages(long sessionId) { for (final long LATENCY_DURATION : LATENCIES) { sendUsersMessage(sessionId); clock.pause(LATENCY_DURATION); } } @Autowired  MessagingUtils(SessionManager sessionManager, Clock clock, SimpMessagingTemplate template); @Contract(pure = true) static String getTopic(String topicRoot, long sessionId); void sendResultsMessage(long sessionId); void sendUsersMessage(long sessionId); @Async void burstResultsMessages(long sessionId); @Async void burstUsersMessages(long sessionId); static final String TOPIC_RESULTS; static final String TOPIC_USERS; static final String TOPIC_ITEM; }
@Test public void testBurstUsersMessages() throws Exception { when(sessionManager.getSessionUsers(SESSION_ID)).thenReturn(USERS); messagingUtils.burstUsersMessages(SESSION_ID); for (long latency : LATENCIES) { verify(clock, times(1)).pause(latency); } verifyMessageSent(LATENCIES.length, getTopic(TOPIC_USERS, SESSION_ID), messagingUtils.usersMessage(USERS)); }