Search in sources :

Example 1 with SessionStateForNode

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)));
}
Also used : InsightsStatusData(com.datastax.dse.driver.internal.core.insights.schema.InsightsStatusData) SessionStateForNode(com.datastax.dse.driver.internal.core.insights.schema.SessionStateForNode) Insight(com.datastax.dse.driver.internal.core.insights.schema.Insight) InsightMetadata(com.datastax.dse.driver.internal.core.insights.schema.InsightMetadata) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

Insight (com.datastax.dse.driver.internal.core.insights.schema.Insight)1 InsightMetadata (com.datastax.dse.driver.internal.core.insights.schema.InsightMetadata)1 InsightsStatusData (com.datastax.dse.driver.internal.core.insights.schema.InsightsStatusData)1 SessionStateForNode (com.datastax.dse.driver.internal.core.insights.schema.SessionStateForNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Test (org.junit.Test)1