From d879346e830b810eeccf8283fa16e04a9cfafbc8 Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Tue, 7 Jul 2020 13:18:20 +0100 Subject: 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 --- .../apex/client/editor/rest/RestInterfaceTest.java | 2 +- .../client/monitoring/rest/RestResourceTest.java | 32 ++++++------ .../apex/context/impl/ContextAlbumImplTest.java | 17 +++--- .../policy/apex/core/engine/event/EnEventTest.java | 20 +++---- .../apex/core/protocols/SupportMessageTester.java | 44 ++++++++-------- .../messages/EngineServiceInfoResponseTest.java | 61 +++++++++++----------- .../protocols/engdep/messages/ResponseTest.java | 33 ++++++------ .../protocols/engdep/messages/UpdateModelTest.java | 32 ++++++------ 8 files changed, 125 insertions(+), 116 deletions(-) diff --git a/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/RestInterfaceTest.java b/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/RestInterfaceTest.java index a1d0a7b3f..a5ba0f44b 100644 --- a/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/RestInterfaceTest.java +++ b/client/client-editor/src/test/java/org/onap/policy/apex/client/editor/rest/RestInterfaceTest.java @@ -140,7 +140,7 @@ public class RestInterfaceTest { private static int createNewSession() { final ApexApiResult responseMsg = target.path("editor/-1/Session/Create").request().get(ApexApiResult.class); assertEquals(ApexApiResult.Result.SUCCESS, responseMsg.getResult()); - assertTrue(responseMsg.getMessages().size() == 1); + assertEquals(1, responseMsg.getMessages().size()); return Integer.parseInt(responseMsg.getMessages().get(0)); } diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java index a63224590..469f09586 100644 --- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java +++ b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.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,7 +22,8 @@ package org.onap.policy.apex.client.monitoring.rest; 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 javax.ws.rs.core.Response; @@ -46,7 +48,7 @@ public class RestResourceTest { /** * Set up mocking of the engine service facade. - * + * * @throws ApexException on engine service facade setup errors */ @Before @@ -228,30 +230,30 @@ public class RestResourceTest { ApexMonitoringRestResource.SlidingWindowList slidingWindowList0 = restResource.new SlidingWindowList<>( 2); - assertFalse(slidingWindowList0.hashCode() == 0); - + assertNotEquals(0, slidingWindowList0.hashCode()); + assertTrue(slidingWindowList0.add("Hello")); assertTrue(slidingWindowList0.add("Hi")); assertTrue(slidingWindowList0.add("Howdy")); - - assertFalse(slidingWindowList0.equals(null)); - assertTrue(slidingWindowList0.equals(slidingWindowList0)); + + assertNotNull(slidingWindowList0); + assertEquals(slidingWindowList0, slidingWindowList0); ApexMonitoringRestResource.SlidingWindowList slidingWindowList1 = restResource.new SlidingWindowList<>( 2); ApexMonitoringRestResource.SlidingWindowList slidingWindowList2 = restResource.new SlidingWindowList<>( 2); - assertFalse(slidingWindowList0.equals(slidingWindowList1)); - assertFalse(slidingWindowList0.equals(slidingWindowList2)); - assertTrue(slidingWindowList1.equals(slidingWindowList2)); + assertNotEquals(slidingWindowList0, slidingWindowList1); + assertNotEquals(slidingWindowList0, slidingWindowList2); + assertEquals(slidingWindowList1, slidingWindowList2); ApexMonitoringRestResource.SlidingWindowList slidingWindowList3 = restResource.new SlidingWindowList<>( 3); - assertFalse(slidingWindowList1.equals(slidingWindowList3)); + assertNotEquals(slidingWindowList1, slidingWindowList3); ApexMonitoringRestResource.SlidingWindowList slidingWindowList4 = restResource.new SlidingWindowList<>( 3); assertTrue(slidingWindowList3.add("Hello")); assertTrue(slidingWindowList4.add(10)); - assertFalse(slidingWindowList3.equals(slidingWindowList4)); + assertNotEquals(slidingWindowList3, slidingWindowList4); } @Test diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java index ad165c3c5..51802919c 100644 --- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java +++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java @@ -1,6 +1,7 @@ /*- * ============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. @@ -21,7 +22,7 @@ package org.onap.policy.apex.context.impl; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -337,20 +338,20 @@ public class ContextAlbumImplTest { distributor.init(axContextAlbum.getKey()); ContextAlbumImpl album = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap()); - assertTrue(album.hashCode() != 0); + assertNotEquals(0, album.hashCode()); assertEquals(0, album.compareTo(album)); assertEquals(1, album.compareTo(null)); - assertTrue(album.equals(album)); - assertFalse(album.equals(new DummyContextAlbumImpl())); + assertEquals(album, album); + assertNotEquals(album, new DummyContextAlbumImpl()); ContextAlbumImpl otherAlbum = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap()); - assertTrue(album.equals(otherAlbum)); + assertEquals(album, otherAlbum); otherAlbum.put("Key", 123); - assertFalse(album.equals(otherAlbum)); + assertNotEquals(album, otherAlbum); try { otherAlbum.put("Key", "BadValue"); @@ -366,7 +367,7 @@ public class ContextAlbumImplTest { otherAxContextAlbum.setItemSchema(simpleStringSchema.getKey()); otherAlbum = new ContextAlbumImpl(otherAxContextAlbum, distributor, new LinkedHashMap()); - assertFalse(album.equals(otherAlbum)); + assertNotEquals(album, otherAlbum); try { album.flush(); @@ -379,7 +380,7 @@ public class ContextAlbumImplTest { ModelService.registerModel(AxContextAlbums.class, albums); albums.getAlbumsMap().put(axContextAlbum.getKey(), axContextAlbum); distributor.createContextAlbum(album.getKey()); - + album.flush(); ModelService.clear(); diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java index e3d0b32b8..225e1853f 100644 --- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java +++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.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,7 +22,8 @@ package org.onap.policy.apex.core.engine.event; 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.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -195,14 +197,14 @@ public class EnEventTest { event.clear(); assertNull(event.get("MyField")); - assertTrue(event.hashCode() != 0); + assertNotEquals(0, event.hashCode()); - assertTrue(event.equals(event)); - assertFalse(event.equals(null)); + assertEquals(event, event); + assertNotNull(event); Map hashMap = new HashMap<>(); - assertFalse(event.equals(hashMap)); + assertNotEquals(event, hashMap); EnEvent otherEvent = new EnEvent(eventKey); - assertTrue(event.equals(otherEvent)); + assertEquals(event, otherEvent); } } 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 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); } } -- cgit 1.2.3-korg