use of io.lettuce.core.metrics.CommandLatencyCollector in project lettuce-core by lettuce-io.
the class DefaultClientResourcesUnitTests method testProvidedResources.
@Test
void testProvidedResources() {
EventExecutorGroup executorMock = mock(EventExecutorGroup.class);
EventLoopGroupProvider groupProviderMock = mock(EventLoopGroupProvider.class);
Timer timerMock = mock(Timer.class);
EventBus eventBusMock = mock(EventBus.class);
CommandLatencyCollector latencyCollectorMock = mock(CommandLatencyCollector.class);
NettyCustomizer nettyCustomizer = mock(NettyCustomizer.class);
AddressResolverGroup<?> addressResolverGroup = mock(AddressResolverGroup.class);
DefaultClientResources sut = DefaultClientResources.builder().eventExecutorGroup(executorMock).eventLoopGroupProvider(groupProviderMock).timer(timerMock).eventBus(eventBusMock).commandLatencyRecorder(latencyCollectorMock).nettyCustomizer(nettyCustomizer).addressResolverGroup(addressResolverGroup).build();
assertThat(sut.eventExecutorGroup()).isSameAs(executorMock);
assertThat(sut.eventLoopGroupProvider()).isSameAs(groupProviderMock);
assertThat(sut.timer()).isSameAs(timerMock);
assertThat(sut.eventBus()).isSameAs(eventBusMock);
assertThat(sut.nettyCustomizer()).isSameAs(nettyCustomizer);
assertThat(sut.addressResolverGroup()).isSameAs(addressResolverGroup);
assertThat(TestFutures.getOrTimeout(sut.shutdown())).isTrue();
verifyNoMoreInteractions(executorMock);
verifyNoMoreInteractions(groupProviderMock);
verifyNoMoreInteractions(timerMock);
verify(latencyCollectorMock).isEnabled();
verifyNoMoreInteractions(latencyCollectorMock);
}
use of io.lettuce.core.metrics.CommandLatencyCollector in project lettuce-core by lettuce-io.
the class DefaultClientResourcesUnitTests method mutateResources.
@Test
void mutateResources() {
EventExecutorGroup executorMock = mock(EventExecutorGroup.class);
EventLoopGroupProvider groupProviderMock = mock(EventLoopGroupProvider.class);
Timer timerMock = mock(Timer.class);
Timer timerMock2 = mock(Timer.class);
EventBus eventBusMock = mock(EventBus.class);
CommandLatencyCollector latencyCollectorMock = mock(CommandLatencyCollector.class);
AddressResolverGroup<?> addressResolverGroupMock = mock(AddressResolverGroup.class);
ClientResources sut = ClientResources.builder().eventExecutorGroup(executorMock).eventLoopGroupProvider(groupProviderMock).timer(timerMock).eventBus(eventBusMock).commandLatencyRecorder(latencyCollectorMock).addressResolverGroup(addressResolverGroupMock).build();
ClientResources copy = sut.mutate().timer(timerMock2).build();
assertThat(sut.eventExecutorGroup()).isSameAs(executorMock);
assertThat(sut.eventLoopGroupProvider()).isSameAs(groupProviderMock);
assertThat(sut.timer()).isSameAs(timerMock);
assertThat(copy.timer()).isSameAs(timerMock2).isNotSameAs(timerMock);
assertThat(sut.eventBus()).isSameAs(eventBusMock);
assertThat(sut.addressResolverGroup()).isSameAs(addressResolverGroupMock);
assertThat(TestFutures.getOrTimeout(sut.shutdown())).isTrue();
assertThat(sut).hasFieldOrPropertyWithValue("shutdownCheck", false);
assertThat(copy).hasFieldOrPropertyWithValue("shutdownCheck", true);
verifyNoMoreInteractions(executorMock);
verifyNoMoreInteractions(groupProviderMock);
verifyNoMoreInteractions(timerMock);
}
Aggregations