use of com.datastax.dse.driver.internal.core.insights.schema.SessionStateForNode in project java-driver by datastax.
the class InsightsClientTest method should_construct_json_event_status_message.
@Test
public void should_construct_json_event_status_message() throws IOException {
// given
InsightsClient insightsClient = new InsightsClient(mockDefaultDriverContext(), MOCK_TIME_SUPPLIER, INSIGHTS_CONFIGURATION, null, null, null, null, null, EMPTY_STACK_TRACE);
// when
String statusMessage = insightsClient.createStatusMessage();
// then
Insight<InsightsStatusData> insight = new ObjectMapper().readValue(statusMessage, new TypeReference<Insight<InsightsStatusData>>() {
});
assertThat(insight.getMetadata()).isEqualTo(new InsightMetadata("driver.status", 1L, ImmutableMap.of("language", "java"), InsightType.EVENT, "v1"));
InsightsStatusData insightData = insight.getInsightData();
assertThat(insightData.getClientId()).isEqualTo("client-id");
assertThat(insightData.getSessionId()).isNotNull();
assertThat(insightData.getControlConnection()).isEqualTo("127.0.0.1:10");
assertThat(insightData.getConnectedNodes()).isEqualTo(ImmutableMap.of("127.0.0.1:10", new SessionStateForNode(1, 10), "127.0.0.1:20", new SessionStateForNode(2, 20)));
}
Aggregations