@Test public void testFlushWithZero() throws Exception { TelemetriesTransmitter mockSender = Mockito.mock(TelemetriesTransmitter.class); LimitsEnforcer maxEnforcer = createEnforcerWithCurrentValue(10); LimitsEnforcer sendEnforcer = createEnforcerWithCurrentValue(3); TelemetryBuffer testedBuffer = new TelemetryBuffer(mockSender, maxEnforcer, sendEnforcer); testedBuffer.flush(); Mockito.verify(mockSender, Mockito.never()).sendNow(anyCollectionOf(String.class)); }
public void flush() { synchronized (lock) { if (telemetries.size() != 0) { if (!sender.sendNow(prepareTelemetriesForSend())) { logger.error("Failed to flush buffer data to network"); } } } }
TelemetryBuffer { public void flush() { synchronized (lock) { if (telemetries.size() != 0) { if (!sender.sendNow(prepareTelemetriesForSend())) { logger.error("Failed to flush buffer data to network"); } } } } }
TelemetryBuffer { public void flush() { synchronized (lock) { if (telemetries.size() != 0) { if (!sender.sendNow(prepareTelemetriesForSend())) { logger.error("Failed to flush buffer data to network"); } } } } TelemetryBuffer(TelemetriesTransmitter<T> sender, LimitsEnforcer maxTelemetriesInBatchEnforcer, LimitsEnforcer transmitBufferTimeoutInSecondsEnforcer); }
TelemetryBuffer { public void flush() { synchronized (lock) { if (telemetries.size() != 0) { if (!sender.sendNow(prepareTelemetriesForSend())) { logger.error("Failed to flush buffer data to network"); } } } } TelemetryBuffer(TelemetriesTransmitter<T> sender, LimitsEnforcer maxTelemetriesInBatchEnforcer, LimitsEnforcer transmitBufferTimeoutInSecondsEnforcer); void setMaxTelemetriesInBatch(int value); int getMaxTelemetriesInBatch(); void setTransmitBufferTimeoutInSeconds(int value); int getTransmitBufferTimeoutInSeconds(); void add(T telemetry); void flush(); }
TelemetryBuffer { public void flush() { synchronized (lock) { if (telemetries.size() != 0) { if (!sender.sendNow(prepareTelemetriesForSend())) { logger.error("Failed to flush buffer data to network"); } } } } TelemetryBuffer(TelemetriesTransmitter<T> sender, LimitsEnforcer maxTelemetriesInBatchEnforcer, LimitsEnforcer transmitBufferTimeoutInSecondsEnforcer); void setMaxTelemetriesInBatch(int value); int getMaxTelemetriesInBatch(); void setTransmitBufferTimeoutInSeconds(int value); int getTransmitBufferTimeoutInSeconds(); void add(T telemetry); void flush();  }