@Test public void testValidCtor() throws InterruptedException { TransmitterImpl transmitter = null; try { TransmissionDispatcher mockDispatcher = Mockito.mock(TransmissionDispatcher.class); TelemetrySerializer mockSerializer = Mockito.mock(TelemetrySerializer.class); TransmissionsLoader mockLoader = Mockito.mock(TransmissionsLoader.class); transmitter = new TransmitterImpl(mockDispatcher, mockSerializer, mockLoader); Mockito.verify(mockLoader, Mockito.times(1)).load(anyBoolean()); } finally { if (transmitter != null) { transmitter.shutdown(1L, TimeUnit.SECONDS); } } }
@Override public void shutdown(long timeout, TimeUnit timeUnit) throws InterruptedException { Stopwatch stopwatch = Stopwatch.createStarted(); transmissionsLoader.shutdown(); threadPool.shutdown(); threadPool.awaitTermination(timeout, timeUnit); long remaining = timeout - stopwatch.elapsed(timeUnit); if (remaining > 0) { transmissionDispatcher.shutdown(remaining, timeUnit); } }
TransmitterImpl implements TelemetriesTransmitter<Telemetry> { @Override public void shutdown(long timeout, TimeUnit timeUnit) throws InterruptedException { Stopwatch stopwatch = Stopwatch.createStarted(); transmissionsLoader.shutdown(); threadPool.shutdown(); threadPool.awaitTermination(timeout, timeUnit); long remaining = timeout - stopwatch.elapsed(timeUnit); if (remaining > 0) { transmissionDispatcher.shutdown(remaining, timeUnit); } } }
TransmitterImpl implements TelemetriesTransmitter<Telemetry> { @Override public void shutdown(long timeout, TimeUnit timeUnit) throws InterruptedException { Stopwatch stopwatch = Stopwatch.createStarted(); transmissionsLoader.shutdown(); threadPool.shutdown(); threadPool.awaitTermination(timeout, timeUnit); long remaining = timeout - stopwatch.elapsed(timeUnit); if (remaining > 0) { transmissionDispatcher.shutdown(remaining, timeUnit); } } TransmitterImpl(TransmissionDispatcher transmissionDispatcher, TelemetrySerializer serializer, TransmissionsLoader transmissionsLoader); }
TransmitterImpl implements TelemetriesTransmitter<Telemetry> { @Override public void shutdown(long timeout, TimeUnit timeUnit) throws InterruptedException { Stopwatch stopwatch = Stopwatch.createStarted(); transmissionsLoader.shutdown(); threadPool.shutdown(); threadPool.awaitTermination(timeout, timeUnit); long remaining = timeout - stopwatch.elapsed(timeUnit); if (remaining > 0) { transmissionDispatcher.shutdown(remaining, timeUnit); } } TransmitterImpl(TransmissionDispatcher transmissionDispatcher, TelemetrySerializer serializer, TransmissionsLoader transmissionsLoader); @Override boolean scheduleSend(TelemetriesFetcher telemetriesFetcher, long value, TimeUnit timeUnit); @Override boolean sendNow(Collection<Telemetry> telemetries); @Override void shutdown(long timeout, TimeUnit timeUnit); }
TransmitterImpl implements TelemetriesTransmitter<Telemetry> { @Override public void shutdown(long timeout, TimeUnit timeUnit) throws InterruptedException { Stopwatch stopwatch = Stopwatch.createStarted(); transmissionsLoader.shutdown(); threadPool.shutdown(); threadPool.awaitTermination(timeout, timeUnit); long remaining = timeout - stopwatch.elapsed(timeUnit); if (remaining > 0) { transmissionDispatcher.shutdown(remaining, timeUnit); } } TransmitterImpl(TransmissionDispatcher transmissionDispatcher, TelemetrySerializer serializer, TransmissionsLoader transmissionsLoader); @Override boolean scheduleSend(TelemetriesFetcher telemetriesFetcher, long value, TimeUnit timeUnit); @Override boolean sendNow(Collection<Telemetry> telemetries); @Override void shutdown(long timeout, TimeUnit timeUnit);  }