use of com.datastax.oss.driver.internal.core.context.EventBus in project java-driver by datastax.
the class NodeStateManagerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
// Disable debouncing by default, tests that need it will override
when(defaultProfile.getDuration(DefaultDriverOption.METADATA_TOPOLOGY_WINDOW)).thenReturn(Duration.ofSeconds(0));
when(defaultProfile.getInt(DefaultDriverOption.METADATA_TOPOLOGY_MAX_EVENTS)).thenReturn(1);
when(config.getDefaultProfile()).thenReturn(defaultProfile);
when(context.getConfig()).thenReturn(config);
this.eventBus = spy(new EventBus("test"));
when(context.getEventBus()).thenReturn(eventBus);
adminEventLoopGroup = new DefaultEventLoopGroup(1, new BlockingOperation.SafeThreadFactory());
when(nettyOptions.adminEventExecutorGroup()).thenReturn(adminEventLoopGroup);
when(context.getNettyOptions()).thenReturn(nettyOptions);
when(context.getMetricsFactory()).thenReturn(metricsFactory);
node1 = TestNodeFactory.newNode(1, context);
node2 = TestNodeFactory.newNode(2, context);
ImmutableMap<UUID, Node> nodes = ImmutableMap.<UUID, Node>builder().put(node1.getHostId(), node1).put(node2.getHostId(), node2).build();
Metadata metadata = new DefaultMetadata(nodes, Collections.emptyMap(), null, null);
when(metadataManager.getMetadata()).thenReturn(metadata);
when(metadataManager.refreshNode(any(Node.class))).thenReturn(CompletableFuture.completedFuture(null));
when(context.getMetadataManager()).thenReturn(metadataManager);
}
Aggregations