public void init() { senderStats = new GatewaySenderStats(system, "test"); sender = Mockito.mock(AbstractGatewaySender.class); Mockito.when(sender.getStatistics()).thenReturn(senderStats); bridge = new GatewaySenderMBeanBridge(sender); bridge.addGatewaySenderStats(senderStats); }
@Test public void testSenderStats() throws InterruptedException { senderStats.incBatchesRedistributed(); senderStats.incEventsReceived(); Mockito.when(sender.getEventQueueSize()).thenReturn(10); senderStats.endPut(testStartTime); senderStats.endBatch(testStartTime, 100); senderStats.incEventsNotQueuedConflated(); senderStats.incEventsExceedingAlertThreshold(); sample(); assertEquals(1, getTotalBatchesRedistributed()); assertEquals(1, getTotalEventsConflated()); assertEquals(10, getEventQueueSize()); assertTrue(getEventsQueuedRate() > 0); assertTrue(getEventsReceivedRate() > 0); assertTrue(getBatchesDispatchedRate() > 0); assertTrue(getAverageDistributionTimePerBatch() > 0); assertTrue(getEventsExceedingAlertThreshold() > 0); }