aboutsummaryrefslogtreecommitdiffstats
path: root/model/engine-model/src/test/java
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2020-07-17 13:18:37 +0100
committerJvD_Ericsson <jeff.van.dam@est.tech>2020-07-17 16:19:28 +0100
commit025d5085d56bd1afc60ea8ad0c339655ca373f28 (patch)
treec36896502a7e0e9d182770a0d94afc8e216a0f17 /model/engine-model/src/test/java
parent28eced32d2acdf731f7782e14f37bf2ea8c98019 (diff)
Fix assertTrue SONAR issues in apex-pdp/model
Replace assertTrue with assertEquals and assertFalse with assertNotEquals in apex-pdp/model Issue-ID: POLICY-2690 Change-Id: Id37989ea8a6ad7b3156e13851cc072ce6c53c03e Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Diffstat (limited to 'model/engine-model/src/test/java')
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java55
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java39
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java9
3 files changed, 51 insertions, 52 deletions
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
index d0694ec30..6e4fbbf05 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
@@ -1,20 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -22,7 +22,6 @@
package org.onap.policy.apex.model.enginemodel.concepts;
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;
@@ -112,36 +111,36 @@ public class EngineModelTest {
final AxEngineModel clonedModel = new AxEngineModel(model);
- assertFalse(model.hashCode() == 0);
-
- assertTrue(model.equals(model));
- assertTrue(model.equals(clonedModel));
- assertFalse(model.equals((Object) "Hello"));
- assertFalse(model.equals(new AxEngineModel(new AxArtifactKey())));
- assertFalse(model.equals(new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
- assertFalse(model.equals(new AxEngineModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey),
- new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
- assertFalse(model.equals(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(),
- new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
- assertFalse(model.equals(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(), AxEngineState.READY, stats)));
- assertFalse(model.equals(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.STOPPED, stats)));
- assertFalse(model.equals(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, otherStats)));
+ assertNotEquals(0, model.hashCode());
+
+ assertEquals(model, model);
+ assertEquals(model, clonedModel);
+ assertNotEquals(model, (Object) "Hello");
+ assertNotEquals(model, new AxEngineModel(new AxArtifactKey()));
+ assertNotEquals(model, new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey),
+ new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(),
+ new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(), AxEngineState.READY, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.STOPPED, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, otherStats));
model.setTimestamp(timestamp);
- assertFalse(model.equals(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
model.setTimestamp(0);
- assertTrue(model.equals(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
+ assertEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
model.setTimestamp(-1);
assertEquals(0, model.compareTo(model));
assertEquals(0, model.compareTo(clonedModel));
assertNotEquals(0, model.compareTo(new AxArtifactKey()));
- assertFalse(model.equals(new AxEngineModel(new AxArtifactKey())));
+ assertNotEquals(model, new AxEngineModel(new AxArtifactKey()));
assertNotEquals(0, model.compareTo(new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(schemasKey),
new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(),
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
index 9e603f491..9f48d1da5 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
@@ -22,7 +22,6 @@
package org.onap.policy.apex.model.enginemodel.concepts;
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;
@@ -137,15 +136,15 @@ public class EngineStatsTest {
assertNotNull(stats.getKeys());
- assertFalse(stats.hashCode() == 0);
+ assertNotEquals(0, stats.hashCode());
- assertTrue(stats.equals(stats));
- assertTrue(stats.equals(clonedStats));
- assertFalse(stats.equals(null));
+ assertEquals(stats, stats);
+ assertEquals(stats, clonedStats);
+ assertNotNull(stats);
Object helloObject = "Hello";
- assertFalse(stats.equals(helloObject));
- assertFalse(stats.equals(new AxEngineStats(new AxReferenceKey())));
+ assertNotEquals(stats, helloObject);
+ assertNotEquals(stats, new AxEngineStats(new AxReferenceKey()));
assertEquals(0, stats.compareTo(stats));
assertEquals(0, stats.compareTo(clonedStats));
@@ -154,51 +153,51 @@ public class EngineStatsTest {
assertNotEquals(0, stats.compareTo(new AxEngineStats(new AxReferenceKey())));
stats.setTimeStamp(1);
- assertFalse(stats.equals(new AxEngineStats(statsKey)));
+ assertNotEquals(stats, new AxEngineStats(statsKey));
assertNotEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setTimeStamp(0);
- assertTrue(stats.equals(new AxEngineStats(statsKey)));
+ assertEquals(stats, new AxEngineStats(statsKey));
assertEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setEventCount(1);
- assertFalse(stats.equals(new AxEngineStats(statsKey)));
+ assertNotEquals(stats, new AxEngineStats(statsKey));
assertNotEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setEventCount(0);
- assertTrue(stats.equals(new AxEngineStats(statsKey)));
+ assertEquals(stats, new AxEngineStats(statsKey));
assertEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setLastExecutionTime(1);
- assertFalse(stats.equals(new AxEngineStats(statsKey)));
+ assertNotEquals(stats, new AxEngineStats(statsKey));
assertNotEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setLastExecutionTime(0);
- assertTrue(stats.equals(new AxEngineStats(statsKey)));
+ assertEquals(stats, new AxEngineStats(statsKey));
assertEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setAverageExecutionTime(1);
- assertFalse(stats.equals(new AxEngineStats(statsKey)));
+ assertNotEquals(stats, new AxEngineStats(statsKey));
assertNotEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setAverageExecutionTime(0);
- assertTrue(stats.equals(new AxEngineStats(statsKey)));
+ assertEquals(stats, new AxEngineStats(statsKey));
assertEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setUpTime(1);
- assertFalse(stats.equals(new AxEngineStats(statsKey)));
+ assertNotEquals(stats, new AxEngineStats(statsKey));
assertNotEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
stats.setUpTime(0);
- assertTrue(stats.equals(new AxEngineStats(statsKey)));
+ assertEquals(stats, new AxEngineStats(statsKey));
assertEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
assertEquals(-1, stats.compareTo(new AxEngineStats(statsKey, 0, 0, 0, 0.0, 0, 1)));
stats.engineStart();
- assertFalse(stats.equals(new AxEngineStats(statsKey)));
+ assertNotEquals(stats, new AxEngineStats(statsKey));
final AxEngineStats newStats = new AxEngineStats(statsKey);
newStats.setTimeStamp(stats.getTimeStamp());
- assertFalse(stats.equals(newStats));
+ assertNotEquals(stats, newStats);
assertNotEquals(0, stats.compareTo(newStats));
stats.engineStop();
stats.reset();
- assertTrue(stats.equals(new AxEngineStats(statsKey)));
+ assertEquals(stats, new AxEngineStats(statsKey));
assertEquals(0, stats.compareTo(new AxEngineStats(statsKey)));
}
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
index 770c29a93..063424b3d 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.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.model.enginemodel.handling;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
@@ -45,19 +46,19 @@ public class ApexEngineModelTest {
@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
public void testModelVaidateInvalidModel() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertTrue(result.toString().equals(INVALID_MODEL_STRING));
+ assertEquals(INVALID_MODEL_STRING, result.toString());
}
@Test
public void testModelVaidateMalstructured() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertTrue(result.toString().equals(INVALID_MODEL_MALSTRUCTURED_STRING));
+ assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
}
@Test