summaryrefslogtreecommitdiffstats
path: root/core/core-protocols/src
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2020-07-07 13:18:20 +0100
committerJvD_Ericsson <jeff.van.dam@est.tech>2020-07-10 13:32:26 +0100
commitd879346e830b810eeccf8283fa16e04a9cfafbc8 (patch)
treedc297a302dcaf59695b2096523721e48f9ecd2dd /core/core-protocols/src
parentfb826f241cb78b70910f842bbed0bb507b1236ca (diff)
Fix assertTrue SONAR issues in apex-pdp/contex and apex-pdp/core
Replace assertTrue with assertEquals and assertFalse with assertNotEquals in apex-pdp/client apex-pdp/context and apex-pdp/core Issue-ID: POLICY-2690 Change-Id: Ic1e69c75e5f8f887cac135b6728b007faf4b19a6 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Diffstat (limited to 'core/core-protocols/src')
-rw-r--r--core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java44
-rw-r--r--core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java61
-rw-r--r--core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java33
-rw-r--r--core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java32
4 files changed, 87 insertions, 83 deletions
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java
index 233a1c2ac..925884534 100644
--- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java
+++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* 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=========================================================
*/
@@ -21,9 +22,8 @@
package org.onap.policy.apex.core.protocols;
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 org.junit.Test;
import org.onap.policy.apex.core.protocols.engdep.messages.StartEngine;
@@ -58,44 +58,44 @@ public class SupportMessageTester {
assertEquals(new AxArtifactKey("Target:0.0.1"), dummyMessage.getTarget());
assertEquals("Target", dummyMessage.getTargetName());
- assertTrue(dummyMessage.hashCode() != 0);
+ assertNotEquals(0, dummyMessage.hashCode());
dummyMessage.setMessageData(null);
- assertTrue(dummyMessage.hashCode() != 0);
+ assertNotEquals(0, dummyMessage.hashCode());
dummyMessage = new DummyMessage(null, null, null);
assertEquals(0, dummyMessage.hashCode());
- assertTrue(dummyMessage.equals(dummyMessage));
- assertFalse(dummyMessage.equals(null));
- assertFalse(dummyMessage.equals(new StartEngine(new AxArtifactKey())));
+ assertEquals(dummyMessage, dummyMessage);
+ assertNotNull(dummyMessage);
+ assertNotEquals(dummyMessage, new StartEngine(new AxArtifactKey()));
dummyMessage = new DummyMessage(new DummyAction(null), null, null);
DummyMessage otherDummyMessage = new DummyMessage(null, null, null);
- assertFalse(dummyMessage.equals(otherDummyMessage));
+ assertNotEquals(dummyMessage, otherDummyMessage);
otherDummyMessage = new DummyMessage(new DummyAction(null), null, null);
- assertTrue(dummyMessage.equals(otherDummyMessage));
+ assertEquals(dummyMessage, otherDummyMessage);
dummyMessage = new DummyMessage(null, null, null);
- assertFalse(dummyMessage.equals(otherDummyMessage));
+ assertNotEquals(dummyMessage, otherDummyMessage);
otherDummyMessage = new DummyMessage(null, null, null);
- assertTrue(dummyMessage.equals(otherDummyMessage));
+ assertEquals(dummyMessage, otherDummyMessage);
dummyMessage = new DummyMessage(null, new AxArtifactKey(), null);
otherDummyMessage = new DummyMessage(null, null, null);
- assertFalse(dummyMessage.equals(otherDummyMessage));
+ assertNotEquals(dummyMessage, otherDummyMessage);
otherDummyMessage = new DummyMessage(null, new AxArtifactKey(), null);
- assertTrue(dummyMessage.equals(otherDummyMessage));
+ assertEquals(dummyMessage, otherDummyMessage);
dummyMessage = new DummyMessage(null, null, null);
- assertFalse(dummyMessage.equals(otherDummyMessage));
+ assertNotEquals(dummyMessage, otherDummyMessage);
otherDummyMessage = new DummyMessage(null, null, null);
- assertTrue(dummyMessage.equals(otherDummyMessage));
+ assertEquals(dummyMessage, otherDummyMessage);
dummyMessage = new DummyMessage(null, null, "Message");
otherDummyMessage = new DummyMessage(null, null, null);
- assertFalse(dummyMessage.equals(otherDummyMessage));
+ assertNotEquals(dummyMessage, otherDummyMessage);
otherDummyMessage = new DummyMessage(null, null, "Message");
- assertTrue(dummyMessage.equals(otherDummyMessage));
+ assertEquals(dummyMessage, otherDummyMessage);
dummyMessage = new DummyMessage(null, null, null);
- assertFalse(dummyMessage.equals(otherDummyMessage));
+ assertNotEquals(dummyMessage, otherDummyMessage);
otherDummyMessage = new DummyMessage(null, null, null);
- assertTrue(dummyMessage.equals(otherDummyMessage));
+ assertEquals(dummyMessage, otherDummyMessage);
}
}
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java
index c240704e9..87fe44aae 100644
--- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java
+++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/EngineServiceInfoResponseTest.java
@@ -1,20 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 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,9 +22,8 @@
package org.onap.policy.apex.core.protocols.engdep.messages;
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.ArrayList;
import java.util.List;
@@ -40,72 +39,72 @@ public class EngineServiceInfoResponseTest {
public void test() {
AxArtifactKey targetKey = new AxArtifactKey("Target:0.0.1");
GetEngineServiceInfo request = new GetEngineServiceInfo(targetKey);
-
+
EngineServiceInfoResponse response = new EngineServiceInfoResponse(targetKey, true, request);
assertNotNull(response);
response = new EngineServiceInfoResponse(targetKey, true, "Response Data", request);
assertNotNull(response);
assertEquals("Response Data", response.getMessageData());
-
+
AxArtifactKey apexModelKey = new AxArtifactKey("Model:0.0.1");
response.setApexModelKey(apexModelKey);
assertEquals(apexModelKey, response.getApexModelKey());
-
+
AxArtifactKey engineServiceKey = new AxArtifactKey("EngineService:0.0.1");
response.setEngineServiceKey(engineServiceKey);;
assertEquals(engineServiceKey, response.getEngineServiceKey());
-
+
List<AxArtifactKey> engineKeyArrayList = new ArrayList<>();
AxArtifactKey engineKey = new AxArtifactKey("Engine:0.0.1");
engineKeyArrayList.add(engineKey);
response.setEngineKeyArray(engineKeyArrayList);
assertEquals(engineKeyArrayList.get(0), response.getEngineKeyArray()[0]);
-
+
response = new EngineServiceInfoResponse(null, false, null);
- assertTrue(response.hashCode() != 0);
+ assertNotEquals(0, response.hashCode());
response.setApexModelKey(apexModelKey);
- assertTrue(response.hashCode() != 0);
+ assertNotEquals(0, response.hashCode());
response.setApexModelKey(null);
response.setEngineServiceKey(engineServiceKey);;
- assertTrue(response.hashCode() != 0);
+ assertNotEquals(0, response.hashCode());
response.setEngineServiceKey(null);
response.setEngineKeyArray(engineKeyArrayList);
- assertTrue(response.hashCode() != 0);
+ assertNotEquals(0, response.hashCode());
response.setEngineKeyArray(null);
-
- assertTrue(response.equals(response));
- assertFalse(response.equals(null));
- assertFalse(response.equals((Object) new StartEngine(new AxArtifactKey())));
+
+ assertEquals(response, response);
+ assertNotNull(response);
+ assertNotEquals(response, (Object) new StartEngine(new AxArtifactKey()));
response = new EngineServiceInfoResponse(null, false, null);
EngineServiceInfoResponse otherResponse = new EngineServiceInfoResponse(null, false, null);
response.setApexModelKey(apexModelKey);
- assertFalse(response.equals(otherResponse));
+ assertNotEquals(response, otherResponse);
otherResponse.setApexModelKey(apexModelKey);
- assertTrue(response.equals(otherResponse));
+ assertEquals(response, otherResponse);
response.setApexModelKey(null);
- assertFalse(response.equals(otherResponse));
+ assertNotEquals(response, otherResponse);
otherResponse.setApexModelKey(null);
- assertTrue(response.equals(otherResponse));
+ assertEquals(response, otherResponse);
response.setEngineServiceKey(engineServiceKey);
- assertFalse(response.equals(otherResponse));
+ assertNotEquals(response, otherResponse);
otherResponse.setEngineServiceKey(engineServiceKey);
- assertTrue(response.equals(otherResponse));
+ assertEquals(response, otherResponse);
response.setEngineServiceKey(null);
- assertFalse(response.equals(otherResponse));
+ assertNotEquals(response, otherResponse);
otherResponse.setEngineServiceKey(null);
- assertTrue(response.equals(otherResponse));
+ assertEquals(response, otherResponse);
response.setEngineKeyArray(engineKeyArrayList);
- assertFalse(response.equals(otherResponse));
+ assertNotEquals(response, otherResponse);
otherResponse.setEngineKeyArray(engineKeyArrayList);
- assertTrue(response.equals(otherResponse));
+ assertEquals(response, otherResponse);
response.setEngineKeyArray(null);
- assertFalse(response.equals(otherResponse));
+ assertNotEquals(response, otherResponse);
otherResponse.setEngineKeyArray(null);
- assertTrue(response.equals(otherResponse));
+ assertEquals(response, otherResponse);
}
}
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java
index 2c1f658b3..b28993a41 100644
--- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java
+++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/ResponseTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * 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.
@@ -22,6 +23,8 @@ package org.onap.policy.apex.core.protocols.engdep.messages;
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.net.UnknownHostException;
@@ -63,32 +66,32 @@ public class ResponseTest {
assertEquals(responseTo, message.getResponseTo());
message = new Response(null, false, null);
- assertTrue(message.hashCode() != 0);
+ assertNotEquals(0, message.hashCode());
message = new Response(responseKey, false, null);
- assertTrue(message.hashCode() != 0);
+ assertNotEquals(0, message.hashCode());
message = new Response(responseKey, true, null);
- assertTrue(message.hashCode() != 0);
+ assertNotEquals(0, message.hashCode());
message = new Response(responseKey, true, new UpdateModel(null));
- assertTrue(message.hashCode() != 0);
-
- assertTrue(message.equals(message));
- assertFalse(message.equals(null));
- assertFalse(message.equals(new StartEngine(new AxArtifactKey())));
+ assertNotEquals(0, message.hashCode());
+
+ assertEquals(message, message);
+ assertNotNull(message);
+ assertNotEquals(message, new StartEngine(new AxArtifactKey()));
message = new Response(null, false, responseTo);
Response otherMessage = new Response(null, false, null);
- assertFalse(message.equals(otherMessage));
+ assertNotEquals(message, otherMessage);
otherMessage = new Response(null, false, responseTo);
- assertTrue(message.equals(otherMessage));
+ assertEquals(message, otherMessage);
message = new Response(null, false, null);
- assertFalse(message.equals(otherMessage));
+ assertNotEquals(message, otherMessage);
otherMessage = new Response(null, false, null);
- assertTrue(message.equals(otherMessage));
-
+ assertEquals(message, (otherMessage));
+
message = new Response(null, false, null);
otherMessage = new Response(null, true, null);
- assertFalse(message.equals(otherMessage));
+ assertNotEquals(message, otherMessage);
otherMessage = new Response(null, false, null);
- assertTrue(message.equals(otherMessage));
+ assertEquals(message, otherMessage);
}
}
diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java
index 9f954b5a5..0839a43b8 100644
--- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java
+++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/messages/UpdateModelTest.java
@@ -20,7 +20,9 @@
package org.onap.policy.apex.core.protocols.engdep.messages;
+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;
@@ -57,30 +59,30 @@ public class UpdateModelTest {
assertTrue((message.toString()).contains("Placeholder for Apex model XML"));
assertFalse(message.isIgnoreConflicts());
assertFalse(message.isForceInstall());
-
+
message = new UpdateModel(null, null, false, false);
- assertTrue(message.hashCode() != 0);
+ assertNotEquals(0, message.hashCode());
message = new UpdateModel(null, null, true, false);
- assertTrue(message.hashCode() != 0);
+ assertNotEquals(0, message.hashCode());
message = new UpdateModel(null, null, true, true);
- assertTrue(message.hashCode() != 0);
+ assertNotEquals(0, message.hashCode());
message = new UpdateModel(null, null, false, true);
- assertTrue(message.hashCode() != 0);
-
- assertTrue(message.equals(message));
- assertFalse(message.equals(null));
- assertFalse(message.equals(new StartEngine(new AxArtifactKey())));
-
+ assertNotEquals(0, message.hashCode());
+
+ assertEquals(message, message);
+ assertNotNull(message);
+ assertNotEquals(message, new StartEngine(new AxArtifactKey()));
+
message = new UpdateModel(null, null, false, false);
UpdateModel otherMessage = new UpdateModel(null, null, false, false);
- assertTrue(message.equals(otherMessage));
+ assertEquals(message, otherMessage);
message = new UpdateModel(null, null, true, false);
- assertFalse(message.equals(otherMessage));
+ assertNotEquals(message, otherMessage);
otherMessage = new UpdateModel(null, null, true, false);
- assertTrue(message.equals(otherMessage));
+ assertEquals(message, otherMessage);
message = new UpdateModel(null, null, false, true);
- assertFalse(message.equals(otherMessage));
+ assertNotEquals(message, otherMessage);
otherMessage = new UpdateModel(null, null, false, true);
- assertTrue(message.equals(otherMessage));
+ assertEquals(message, otherMessage);
}
}