@Override public ExtendedStorableDetectionResult create(final IValueDeserializer deserializer) { return new ExtendedStorableDetectionResult(deserializer); }
@Override public ExtendedStorableDetectionResult create(final IValueDeserializer deserializer) throws RecordInstantiationException { return new ExtendedStorableDetectionResult(deserializer); }
@Override @Deprecated public ExtendedStorableDetectionResult create(final Object[] values) { return new ExtendedStorableDetectionResult(values); }
@Test public void testUnequality() { int i = 0; final ExtendedStorableDetectionResult oneRecord = new ExtendedStorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); i = 2; final ExtendedStorableDetectionResult anotherRecord = new ExtendedStorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); Assert.assertNotEquals(oneRecord, anotherRecord); } }
@Test public void testEquality() { int i = 0; final ExtendedStorableDetectionResult oneRecord = new ExtendedStorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); i = 0; final ExtendedStorableDetectionResult copiedRecord = new ExtendedStorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); Assert.assertEquals(oneRecord, copiedRecord); }
@InputPort(eventTypes = { StorableDetectionResult.class }, name = AnomalyDetectionFilter.INPUT_PORT_ANOMALY_SCORE) public void inputForecastAndMeasurement( final StorableDetectionResult anomalyScore) { if (anomalyScore.getScore() >= this.threshold.get()) { super.deliver(OUTPUT_PORT_ANOMALY_SCORE_IF_ANOMALY, anomalyScore); } else { super.deliver(OUTPUT_PORT_ANOMALY_SCORE_ELSE, anomalyScore); } final ExtendedStorableDetectionResult extAnomalyScore = new ExtendedStorableDetectionResult(anomalyScore.getApplicationName(), anomalyScore.getValue(), anomalyScore.getTimestamp(), anomalyScore.getForecast(), anomalyScore.getScore(), this.threshold.get().doubleValue()); super.deliver(OUTPUT_PORT_ALL, extAnomalyScore); }
@InputPort(eventTypes = { StorableDetectionResult.class }, name = AnomalyDetectionFilter.INPUT_PORT_ANOMALY_SCORE) public void inputForecastAndMeasurement( final StorableDetectionResult anomalyScore) { if (anomalyScore.getScore() >= this.threshold.get()) { super.deliver(OUTPUT_PORT_ANOMALY_SCORE_IF_ANOMALY, anomalyScore); } else { super.deliver(OUTPUT_PORT_ANOMALY_SCORE_ELSE, anomalyScore); } final ExtendedStorableDetectionResult extAnomalyScore = new ExtendedStorableDetectionResult(anomalyScore.getApplicationName(), anomalyScore.getValue(), anomalyScore.getTimestamp(), anomalyScore.getForecast(), anomalyScore.getScore(), this.threshold.get().doubleValue()); super.deliver(OUTPUT_PORT_ALL, extAnomalyScore); }
/** * Tests {@link ExtendedStorableDetectionResult#TestExtendedStorableDetectionResult(string, double, long, double, double, double)}. */ @Test public void testParameterConstruction() { // NOPMD (assert missing) for (int i = 0; i < ARRAY_LENGTH; i++) { // initialize final ExtendedStorableDetectionResult record = new ExtendedStorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); // check values Assert.assertEquals("ExtendedStorableDetectionResult.applicationName values are not equal.", STRING_VALUES.get(i % STRING_VALUES.size()) == null ? "" : STRING_VALUES.get(i % STRING_VALUES.size()), record.getApplicationName()); Assert.assertEquals("ExtendedStorableDetectionResult.value values are not equal.", DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), record.getValue(), 0.0000001); Assert.assertEquals("ExtendedStorableDetectionResult.timestamp values are not equal.", (long) LONG_VALUES.get(i % LONG_VALUES.size()), record.getTimestamp()); Assert.assertEquals("ExtendedStorableDetectionResult.forecast values are not equal.", DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), record.getForecast(), 0.0000001); Assert.assertEquals("ExtendedStorableDetectionResult.score values are not equal.", DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), record.getScore(), 0.0000001); Assert.assertEquals("ExtendedStorableDetectionResult.anomalyThreshold values are not equal.", DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), record.getAnomalyThreshold(), 0.0000001); } }
/** * Tests {@link ExtendedStorableDetectionResult#TestExtendedStorableDetectionResult(string, double, long, double, double, double)}. */ @Test public void testBuffer() { // NOPMD (assert missing) for (int i = 0; i < ARRAY_LENGTH; i++) { // initialize final ExtendedStorableDetectionResult record = new ExtendedStorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); // check values Assert.assertEquals("ExtendedStorableDetectionResult.applicationName values are not equal.", STRING_VALUES.get(i % STRING_VALUES.size()) == null ? "" : STRING_VALUES.get(i % STRING_VALUES.size()), record.getApplicationName()); Assert.assertEquals("ExtendedStorableDetectionResult.value values are not equal.", DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), record.getValue(), 0.0000001); Assert.assertEquals("ExtendedStorableDetectionResult.timestamp values are not equal.", (long) LONG_VALUES.get(i % LONG_VALUES.size()), record.getTimestamp()); Assert.assertEquals("ExtendedStorableDetectionResult.forecast values are not equal.", DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), record.getForecast(), 0.0000001); Assert.assertEquals("ExtendedStorableDetectionResult.score values are not equal.", DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), record.getScore(), 0.0000001); Assert.assertEquals("ExtendedStorableDetectionResult.anomalyThreshold values are not equal.", DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), record.getAnomalyThreshold(), 0.0000001); } }