use of org.opensearch.common.io.stream.NamedWriteableAwareStreamInput in project anomaly-detection by opensearch-project.
the class AnomalyResultTests method testSerializeAnomalyResultWithoutUser.
public void testSerializeAnomalyResultWithoutUser() throws IOException {
AnomalyResult detectResult = TestHelpers.randomAnomalyDetectResult(0.8, randomAlphaOfLength(5), randomAlphaOfLength(5), false);
BytesStreamOutput output = new BytesStreamOutput();
detectResult.writeTo(output);
NamedWriteableAwareStreamInput input = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), writableRegistry());
AnomalyResult parsedDetectResult = new AnomalyResult(input);
assertTrue(parsedDetectResult.equals(detectResult));
}
use of org.opensearch.common.io.stream.NamedWriteableAwareStreamInput in project anomaly-detection by opensearch-project.
the class AnomalyResultTests method testSerializeAnomalyResult.
public void testSerializeAnomalyResult() throws IOException {
AnomalyResult detectResult = TestHelpers.randomAnomalyDetectResult(0.8, randomAlphaOfLength(5), randomAlphaOfLength(5));
BytesStreamOutput output = new BytesStreamOutput();
detectResult.writeTo(output);
NamedWriteableAwareStreamInput input = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), writableRegistry());
AnomalyResult parsedDetectResult = new AnomalyResult(input);
assertTrue(parsedDetectResult.equals(detectResult));
}
use of org.opensearch.common.io.stream.NamedWriteableAwareStreamInput in project anomaly-detection by opensearch-project.
the class AnomalyResultTests method testSerializeAnomalyResultWithEntity.
public void testSerializeAnomalyResultWithEntity() throws IOException {
AnomalyResult detectResult = TestHelpers.randomHCADAnomalyDetectResult(0.8, 0.5);
BytesStreamOutput output = new BytesStreamOutput();
detectResult.writeTo(output);
NamedWriteableAwareStreamInput input = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), writableRegistry());
AnomalyResult parsedDetectResult = new AnomalyResult(input);
assertTrue(parsedDetectResult.equals(detectResult));
}
use of org.opensearch.common.io.stream.NamedWriteableAwareStreamInput in project anomaly-detection by opensearch-project.
the class DetectionDateRangeTests method testSerializeDetectoinDateRange.
public void testSerializeDetectoinDateRange() throws IOException {
DetectionDateRange dateRange = TestHelpers.randomDetectionDateRange();
BytesStreamOutput output = new BytesStreamOutput();
dateRange.writeTo(output);
NamedWriteableAwareStreamInput input = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), writableRegistry());
DetectionDateRange parsedDateRange = new DetectionDateRange(input);
assertTrue(parsedDateRange.equals(dateRange));
}
use of org.opensearch.common.io.stream.NamedWriteableAwareStreamInput in project anomaly-detection by opensearch-project.
the class PreviewAnomalyDetectorActionTests method testPreviewResponse.
@Test
public void testPreviewResponse() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
AnomalyDetector detector = TestHelpers.randomAnomalyDetector(ImmutableMap.of("testKey", "testValue"), Instant.now());
AnomalyResult result = TestHelpers.randomHCADAnomalyDetectResult(0.8d, 0d);
PreviewAnomalyDetectorResponse response = new PreviewAnomalyDetectorResponse(ImmutableList.of(result), detector);
response.writeTo(out);
NamedWriteableAwareStreamInput input = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), writableRegistry());
PreviewAnomalyDetectorResponse newResponse = new PreviewAnomalyDetectorResponse(input);
Assert.assertNotNull(newResponse.toXContent(TestHelpers.builder(), ToXContent.EMPTY_PARAMS));
}
Aggregations