summaryrefslogtreecommitdiffstats
path: root/examples/examples-adaptive/src
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2020-07-14 15:17:25 +0000
committerGerrit Code Review <gerrit@onap.org>2020-07-14 15:17:25 +0000
commit592e04f6301dd38ae48d38501cc251fc3d5ad2fb (patch)
treef2e2abc1a89a51ee348a3aee5fa2f87c9ffb4f5a /examples/examples-adaptive/src
parent9a306c4444ca86f409d40b2e032ab2a12f3031ff (diff)
parentaa987aab348f13d477c6cf32e61689d396ebfba5 (diff)
Merge "Fix assertTrue SONAR issues in apex-pdp/examples and apex-pdp/model"
Diffstat (limited to 'examples/examples-adaptive/src')
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java26
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java5
-rw-r--r--examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java5
3 files changed, 20 insertions, 16 deletions
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
index f1c8d7dca..d24733224 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionConceptTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (c) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ package org.onap.policy.apex.examples.adaptive;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
@@ -65,40 +67,40 @@ public class AnomalyDetectionConceptTest {
public void testEquals() {
AnomalyDetection anomalyDetection = new AnomalyDetection();
AnomalyDetection comparisonDetection = new AnomalyDetection();
- assertTrue(anomalyDetection.equals(comparisonDetection));
+ assertEquals(anomalyDetection, comparisonDetection);
//Compare object to itself
- assertTrue(anomalyDetection.equals(anomalyDetection));
+ assertEquals(anomalyDetection, anomalyDetection);
//Compare object to null
- assertFalse(anomalyDetection.equals(null));
+ assertNotNull(anomalyDetection);
//compare object to string
- assertFalse(anomalyDetection.equals("test"));
+ assertNotEquals(anomalyDetection, "test");
// Anomaly Scores comparison
anomalyDetection.setAnomalyScores(null);
- assertFalse(anomalyDetection.equals(comparisonDetection));
+ assertNotEquals(anomalyDetection, comparisonDetection);
comparisonDetection.setAnomalyScores(null);
- assertTrue(anomalyDetection.equals(comparisonDetection));
+ assertEquals(anomalyDetection, comparisonDetection);
List<Double> anomalyScores = new LinkedList<>();
anomalyScores.add((double) 20);
anomalyDetection.setAnomalyScores(anomalyScores);
- assertFalse(anomalyDetection.equals(comparisonDetection));
+ assertNotEquals(anomalyDetection, comparisonDetection);
comparisonDetection.setAnomalyScores(anomalyScores);
assertTrue(anomalyDetection.checkSetAnomalyScores());
//First Round Checks
anomalyDetection.setFirstRound(false);
- assertFalse(anomalyDetection.equals(comparisonDetection));
+ assertNotEquals(anomalyDetection, comparisonDetection);
anomalyDetection.setFirstRound(true);
//Frequency Checks
anomalyDetection.setFrequency(55);
- assertFalse(anomalyDetection.equals(comparisonDetection));
+ assertNotEquals(anomalyDetection, comparisonDetection);
anomalyDetection.setFrequency(0);
//FrequencyForecasted Checks
List<Double> comparisonFrequency = new LinkedList<>();
comparisonDetection.setFrequencyForecasted(comparisonFrequency);
- assertFalse(anomalyDetection.equals(comparisonDetection));
+ assertNotEquals(anomalyDetection, comparisonDetection);
anomalyDetection.setFrequencyForecasted(anomalyScores);
- assertFalse(anomalyDetection.equals(comparisonDetection));
+ assertNotEquals(anomalyDetection, comparisonDetection);
anomalyDetection.setFrequencyForecasted(comparisonFrequency);
- assertTrue(anomalyDetection.equals(comparisonDetection));
+ assertEquals(anomalyDetection, comparisonDetection);
}
@Test
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
index 5a36d4070..85cecbe8b 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +21,7 @@
package org.onap.policy.apex.examples.adaptive;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
@@ -44,7 +45,7 @@ public class AnomalyDetectionModelTest {
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
- assertTrue(result.toString().equals(VALID_MODEL_STRING));
+ assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
index 1823f9871..3479ccc9e 100644
--- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
+++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +21,7 @@
package org.onap.policy.apex.examples.adaptive;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
@@ -44,7 +45,7 @@ public class AutoLearnModelTest {
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
- assertTrue(result.toString().equals(VALID_MODEL_STRING));
+ assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test