BrokerConnectionMetrics implements ConnectionMetrics { @Override public void reset() { this.requestCount = 0L; this.responseCount = 0L; this.minBytesPerRequest = Long.MAX_VALUE; this.maxBytesPerRequest = 0L; this.meanBytesPerRequest = 0L; this.minBytesPerResponse = Long.MAX_VALUE; this.maxBytesPerResponse = 0L; this.meanBytesPerResponse = 0L; this.minElapsedMillis = Long.MAX_VALUE; this.maxElapsedMillis = 0L; this.meanElapsedMillis = 0L; this.minSendThroughputBitsPerSecond = Long.MAX_VALUE; this.meanSendThroughputBitsPerSecond = 0L; this.maxSendThroughputBitsPerSecond = 0L; this.minReceiveThroughputBitsPerSecond = Long.MAX_VALUE; this.meanReceiveThroughputBitsPerSecond = 0L; this.maxReceiveThroughputBitsPerSecond = 0L; if (inTransportMetrics != null) { inTransportMetrics.reset(); } if (outTransportMetrics != null) { outTransportMetrics.reset(); } } BrokerConnectionMetrics(TransportMetrics inTransportMetrics, TransportMetrics outTransportMetrics); @Override long getRequestCount(); @Override long getResponseCount(); @Override long getSentBytesCount(); @Override long getReceivedBytesCount(); @Override long getMinBytesPerRequest(); @Override long getMaxBytesPerRequest(); @Override long getMeanBytesPerRequest(); @Override long getMinBytesPerResponse(); @Override long getMaxBytesPerResponse(); @Override long getMeanBytesPerResponse(); @Override long getMinElapsedMilliseconds(); @Override long getMaxElapsedMilliseconds(); @Override long getMeanElapsedMilliseconds(); @Override long getMinSendThroughputBitsPerSecond(); @Override long getMaxSendThroughputBitsPerSecond(); @Override long getMeanSendThroughputBitsPerSecond(); @Override long getMinReceiveThroughputBitsPerSecond(); @Override long getMaxReceiveThroughputBitsPerSecond(); @Override long getMeanReceiveThroughputBitsPerSecond(); void incrementRequestCount(long sendMilliseconds); void incrementResponseCount(long waitAndReceiveMilliseconds); @Override void reset();  }
@Test public void testReset() throws Exception { long requestBytes = 123L; long responseBytes = 45678L; when(mockOutMetrics.getBytesTransferred()).thenReturn(requestBytes); when(mockInMetrics.getBytesTransferred()).thenReturn(responseBytes); metrics.incrementRequestCount(TimeUnit.SECONDS.toMillis(1)); assertThat(metrics.getRequestCount(), is(1L)); metrics.incrementResponseCount(TimeUnit.SECONDS.toMillis(3)); assertThat(metrics.getResponseCount(), is(1L)); assertThat(metrics.getMinBytesPerRequest(), is(requestBytes)); assertThat(metrics.getMaxBytesPerRequest(), is(requestBytes)); assertThat(metrics.getMeanBytesPerRequest(), is(requestBytes)); assertThat(metrics.getMinBytesPerResponse(), is(responseBytes)); assertThat(metrics.getMaxBytesPerResponse(), is(responseBytes)); assertThat(metrics.getMeanBytesPerResponse(), is(responseBytes)); assertThat(metrics.getMinElapsedMilliseconds(), is(3000L)); assertThat(metrics.getMaxElapsedMilliseconds(), is(3000L)); assertThat(metrics.getMeanElapsedMilliseconds(), is(3000L)); long sendThroughput = (requestBytes * Byte.SIZE) / 1L; assertThat(metrics.getMinSendThroughputBitsPerSecond(), is(sendThroughput)); assertThat(metrics.getMaxSendThroughputBitsPerSecond(), is(sendThroughput)); assertThat(metrics.getMeanSendThroughputBitsPerSecond(), is(sendThroughput)); long receiveThroughput = (responseBytes * Byte.SIZE) / 3L; assertThat(metrics.getMinReceiveThroughputBitsPerSecond(), is(receiveThroughput)); assertThat(metrics.getMaxReceiveThroughputBitsPerSecond(), is(receiveThroughput)); assertThat(metrics.getMeanReceiveThroughputBitsPerSecond(), is(receiveThroughput)); metrics.reset(); assertThat(metrics.getRequestCount(), is(0L)); assertThat(metrics.getMinBytesPerRequest(), is(0L)); assertThat(metrics.getMaxBytesPerRequest(), is(0L)); assertThat(metrics.getMeanBytesPerRequest(), is(0L)); assertThat(metrics.getResponseCount(), is(0L)); assertThat(metrics.getMinBytesPerResponse(), is(0L)); assertThat(metrics.getMaxBytesPerResponse(), is(0L)); assertThat(metrics.getMeanBytesPerResponse(), is(0L)); assertThat(metrics.getMinElapsedMilliseconds(), is(0L)); assertThat(metrics.getMaxElapsedMilliseconds(), is(0L)); assertThat(metrics.getMeanElapsedMilliseconds(), is(0L)); assertThat(metrics.getMinSendThroughputBitsPerSecond(), is(0L)); assertThat(metrics.getMaxSendThroughputBitsPerSecond(), is(0L)); assertThat(metrics.getMeanSendThroughputBitsPerSecond(), is(0L)); assertThat(metrics.getMinReceiveThroughputBitsPerSecond(), is(0L)); assertThat(metrics.getMaxReceiveThroughputBitsPerSecond(), is(0L)); assertThat(metrics.getMeanReceiveThroughputBitsPerSecond(), is(0L)); }