summaryrefslogtreecommitdiffstats
path: root/examples/examples-adaptive/src/test/java
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2020-07-08 13:21:57 +0100
committerJvD_Ericsson <jeff.van.dam@est.tech>2020-07-13 08:53:28 +0100
commitaa987aab348f13d477c6cf32e61689d396ebfba5 (patch)
tree3899017a20693b275d62f7e944393fb64f37d654 /examples/examples-adaptive/src/test/java
parent871421fb99f7e6221b2c084e43a9388f618f882d (diff)
Fix assertTrue SONAR issues in apex-pdp/examples and apex-pdp/model
Replace assertTrue with assertEquals and assertFalse with assertNotEquals in apex-pdp/examples and apex-pdp/model Issue-ID: POLICY-2690 Change-Id: Ie863dd95ccead62268689a4a8388f9b6e8821649 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Diffstat (limited to 'examples/examples-adaptive/src/test/java')
-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