use of com.datastax.dse.driver.internal.core.insights.schema.InsightsStatusData 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)));
}
use of com.datastax.dse.driver.internal.core.insights.schema.InsightsStatusData in project java-driver by datastax.
the class InsightsClient method createStatusMessage.
@VisibleForTesting
String createStatusMessage() {
InsightMetadata insightMetadata = createMetadata(STATUS_MESSAGE_NAME, STATUS_VERSION_1_ID);
InsightsStatusData data = createStatusData();
try {
return OBJECT_MAPPER.writeValueAsString(new Insight<>(insightMetadata, data));
} catch (JsonProcessingException e) {
throw new InsightEventFormatException("Problem when creating: " + STATUS_MESSAGE_NAME, e);
}
}
Aggregations