From 248a660d61fa03caa4710cf8cfe144eb245b807b Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 21 Jul 2020 09:55:38 -0400 Subject: Fix some sonars in policy-models Fixed the following sonar issues in some of the project directories: - use assertNull, assertEquals, etc. - swap assertEquals arguments - extract a constant - don't invoke toString() in logger calls - TODOs - generic types Issue-ID: POLICY-2714 Change-Id: Id8803f9bf617ea9fc173a67b8606600709b55bdc Signed-off-by: Jim Hahn --- .../org/onap/policy/aai/util/AaiException.java | 50 --------------- .../org/onap/policy/aai/util/Serialization.java | 4 +- .../org/onap/policy/aai/util/AaiExceptionTest.java | 42 ------------- .../org/onap/policy/appc/CommonHeaderTest.java | 73 +++++++++++----------- .../java/org/onap/policy/appc/RequestTest.java | 11 ++-- .../org/onap/policy/appc/ResponseStatusTest.java | 39 ++++++------ .../java/org/onap/policy/appc/ResponseTest.java | 39 ++++++------ .../policy/cds/client/CdsProcessorHandler.java | 14 ++--- .../controlloop/ControlLoopOperationTest.java | 13 ++-- .../onap/policy/guard/OperationsHistoryTest.java | 11 ++-- .../test/java/org/onap/policy/rest/RestTest.java | 63 ++++++++++--------- .../org/onap/policy/sdc/ResourceInstanceTest.java | 11 ++-- .../java/org/onap/policy/sdc/ResourceTest.java | 11 ++-- .../org/onap/policy/sdc/ServiceInstanceTest.java | 11 ++-- .../test/java/org/onap/policy/sdc/ServiceTest.java | 11 ++-- .../org/onap/policy/sdnr/PciCommonHeaderTest.java | 65 +++++++++---------- .../java/org/onap/policy/sdnr/PciRequestTest.java | 39 ++++++------ .../onap/policy/sdnr/PciRequestWrapperTest.java | 22 ++++--- .../java/org/onap/policy/sdnr/PciResponseTest.java | 45 ++++++------- .../onap/policy/sdnr/PciResponseWrapperTest.java | 22 ++++--- .../java/org/onap/policy/sdnr/PciStatusTest.java | 31 ++++----- .../java/org/onap/policy/sdnr/PciWrapperTest.java | 52 ++++++++------- .../onap/policy/so/SoAsyncRequestStatusTest.java | 18 +++--- .../onap/policy/so/SoCloudConfigurationTest.java | 8 +-- .../onap/policy/so/SoInstanceReferencesTest.java | 9 ++- .../java/org/onap/policy/so/SoModelInfoTest.java | 18 +++--- .../policy/so/SoPolicyExceptionHolderTest.java | 8 +-- .../so/SoRelatedInstanceListElementTest.java | 6 +- .../org/onap/policy/so/SoRelatedInstanceTest.java | 10 +-- .../org/onap/policy/so/SoRequestDetailsTest.java | 21 ++++--- .../org/onap/policy/so/SoRequestErrorTest.java | 8 +-- .../onap/policy/so/SoRequestParametersTest.java | 10 +-- .../onap/policy/so/SoRequestReferencesTest.java | 9 ++- .../org/onap/policy/so/SoRequestStatusTest.java | 8 +-- .../java/org/onap/policy/so/SoRequestTest.java | 19 +++--- .../java/org/onap/policy/so/SoResponseTest.java | 11 ++-- .../org/onap/policy/so/SoResponseWrapperTest.java | 15 +++-- .../policy/so/SoServiceExceptionHolderTest.java | 12 ++-- .../org/onap/policy/so/SoSubscriberInfoTest.java | 11 ++-- 39 files changed, 400 insertions(+), 480 deletions(-) delete mode 100644 models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java delete mode 100644 models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java (limited to 'models-interactions/model-impl') diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java deleted file mode 100644 index 83923f1bb..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai.util; - -public class AaiException extends Exception { - - // TODO remove this class - - private static final long serialVersionUID = 9220983727706207465L; - - public AaiException() { - super(); - } - - public AaiException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - - public AaiException(String message, Throwable cause) { - super(message, cause); - } - - public AaiException(String message) { - super(message); - } - - public AaiException(Throwable cause) { - super(cause); - } - -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java index 326294aab..7a14a854f 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * aai * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,8 +26,6 @@ import com.google.gson.GsonBuilder; public final class Serialization { - // TODO remove this class - public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); private Serialization() { diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java deleted file mode 100644 index caee19a87..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai.util; - -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import org.junit.Test; - -public class AaiExceptionTest { - - private static final String MESSAGE = "message"; - - @Test - public void test() { - assertNotNull(new AaiException()); - assertNotNull(new AaiException(MESSAGE)); - assertNotNull(new AaiException(MESSAGE, new IOException())); - assertNotNull(new AaiException(MESSAGE, new IOException(), true, false)); - assertNotNull(new AaiException(new IOException())); - } - -} diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java index 4854e2759..3e84a3df2 100644 --- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java +++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * appc * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,10 +22,8 @@ package org.onap.policy.appc; 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.time.Instant; import java.util.ArrayList; @@ -85,78 +83,81 @@ public class CommonHeaderTest { copiedCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); copiedCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); + /* + * Disabling sonar to test equals(). + */ + assertEquals(commonHeader, commonHeader); // NOSONAR + assertEquals(commonHeader, copiedCommonHeader); + assertNotEquals(commonHeader, null); + assertNotEquals(commonHeader, "Hello"); // NOSONAR CommonHeader clonedCommonHeader = new CommonHeader(commonHeader); clonedCommonHeader.setApiVer(commonHeader.getApiVer()); clonedCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - assertTrue(commonHeader.equals(clonedCommonHeader)); + assertEquals(commonHeader, clonedCommonHeader); commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setApiVer(KANSAS); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setApiVer(KANSAS); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setFlags(flagSet); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setFlags(flagSet); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setOriginatorId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setOriginatorId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setOriginatorId(DOROTHY); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setOriginatorId(DOROTHY); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setRequestTrack(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setRequestTrack(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setRequestTrack(requestTrackSet); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setRequestTrack(requestTrackSet); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setSubRequestId(CAN_I_GO_HOME); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setSubRequestId(CAN_I_GO_HOME); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedCommonHeader)); + assertNotEquals(commonHeader, copiedCommonHeader); copiedCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedCommonHeader)); + assertEquals(commonHeader, copiedCommonHeader); } } diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java index e6fb868b3..7d804c869 100644 --- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java +++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * appc * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -72,10 +72,13 @@ public class RequestTest { copiedRequest.setPayload(request.getPayload()); copiedRequest.setTargetId(request.getTargetId()); - assertEquals(request, request); + /* + * Disabling sonar to test equals(). + */ + assertEquals(request, request); // NOSONAR assertEquals(request, copiedRequest); - assertNotEquals(null, request); - assertNotEquals("Hello", request); + assertNotEquals(request, null); + assertNotEquals(request, "Hello"); // NOSONAR request.setCommonHeader(null); assertNotEquals(request, copiedRequest); diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java index 2541f9b0a..ce8b2148d 100644 --- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java +++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * appc * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,10 +22,8 @@ package org.onap.policy.appc; 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; @@ -57,36 +55,39 @@ public class ResponseStatusTest { copiedStatus.setDescription(status.getDescription()); copiedStatus.setValue(status.getValue()); - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); + /* + * Disabling sonar to test equals(). + */ + assertEquals(status, status); // NOSONAR + assertEquals(status, copiedStatus); + assertNotEquals(status, null); + assertNotEquals(status, "Hello"); // NOSONAR status.setCode(-1); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); status.setCode(1234); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); status.setDescription(null); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setDescription(null); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); status.setDescription(THE_WONDERFUL_LAND_OF_OZ); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setDescription(THE_WONDERFUL_LAND_OF_OZ); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); status.setValue(null); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setValue(null); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); status.setValue(THERE_S_NO_PLACE_LIKE_HOME); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setValue(THERE_S_NO_PLACE_LIKE_HOME); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); } } diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java index 72c203f98..14e14f0f9 100644 --- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java +++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * appc * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,10 +22,8 @@ package org.onap.policy.appc; 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.HashMap; import java.util.Map; @@ -69,36 +67,39 @@ public class ResponseTest { copiedResponse.setStatus(response.getStatus()); copiedResponse.setPayload(response.getPayload()); - assertTrue(response.equals(response)); - assertTrue(response.equals(copiedResponse)); - assertFalse(response.equals(null)); - assertFalse(response.equals("Hello")); + /* + * Disabling sonar to test equals(). + */ + assertEquals(response, response); // NOSONAR + assertEquals(response, copiedResponse); + assertNotEquals(response, null); + assertNotEquals(response, "Hello"); // NOSONAR response.setCommonHeader(null); - assertFalse(response.equals(copiedResponse)); + assertNotEquals(response, copiedResponse); copiedResponse.setCommonHeader(null); - assertTrue(response.equals(copiedResponse)); + assertEquals(response, copiedResponse); response.setCommonHeader(commonHeader); - assertFalse(response.equals(copiedResponse)); + assertNotEquals(response, copiedResponse); copiedResponse.setCommonHeader(commonHeader); - assertTrue(response.equals(copiedResponse)); + assertEquals(response, copiedResponse); response.setStatus(null); - assertFalse(response.equals(copiedResponse)); + assertNotEquals(response, copiedResponse); copiedResponse.setStatus(null); - assertTrue(response.equals(copiedResponse)); + assertEquals(response, copiedResponse); response.setStatus(status); - assertFalse(response.equals(copiedResponse)); + assertNotEquals(response, copiedResponse); copiedResponse.setStatus(status); - assertTrue(response.equals(copiedResponse)); + assertEquals(response, copiedResponse); response.setPayload(new HashMap()); - assertFalse(response.equals(copiedResponse)); + assertNotEquals(response, copiedResponse); copiedResponse.setPayload(new HashMap()); - assertTrue(response.equals(copiedResponse)); + assertEquals(response, copiedResponse); response.setPayload(payload); - assertFalse(response.equals(copiedResponse)); + assertNotEquals(response, copiedResponse); copiedResponse.setPayload(payload); - assertTrue(response.equals(copiedResponse)); + assertEquals(response, copiedResponse); } } diff --git a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorHandler.java b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorHandler.java index 84baecdf1..04b584081 100644 --- a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorHandler.java +++ b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/CdsProcessorHandler.java @@ -35,8 +35,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CdsProcessorHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(CdsProcessorHandler.class); + private static final String LOG_MSG = "[{}|{}|{}|]{}{}"; private CdsProcessorListener listener; private String url; @@ -56,8 +56,8 @@ public class CdsProcessorHandler { final StreamObserver responseObserver = new StreamObserver() { @Override public void onNext(ExecutionServiceOutput output) { - LOGGER.info("[{}|{}|{}|]{}{}", EventType.IN, CommInfrastructure.REST, url, NetLoggerUtil.SYSTEM_LS, - output.toString()); + LOGGER.info(LOG_MSG, EventType.IN, CommInfrastructure.REST, url, NetLoggerUtil.SYSTEM_LS, + output); NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, output.toString()); listener.onMessage(output); @@ -65,8 +65,8 @@ public class CdsProcessorHandler { @Override public void onError(Throwable throwable) { - LOGGER.info("[{}|{}|{}|]{}{}", EventType.IN, CommInfrastructure.REST, url, NetLoggerUtil.SYSTEM_LS, - throwable.toString()); + LOGGER.info(LOG_MSG, EventType.IN, CommInfrastructure.REST, url, NetLoggerUtil.SYSTEM_LS, + throwable); NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, throwable.toString()); listener.onError(throwable); finishLatch.countDown(); @@ -82,8 +82,8 @@ public class CdsProcessorHandler { final StreamObserver requestObserver = asyncStub.process(responseObserver); try { - LOGGER.info("[{}|{}|{}|]{}{}", EventType.OUT, CommInfrastructure.REST, url, NetLoggerUtil.SYSTEM_LS, - request.toString()); + LOGGER.info(LOG_MSG, EventType.OUT, CommInfrastructure.REST, url, NetLoggerUtil.SYSTEM_LS, + request); NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, request.toString()); // Send the message to CDS backend for processing diff --git a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java index eb1a351d1..54eec71b5 100644 --- a/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java +++ b/models-interactions/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * controlloop * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,11 +35,14 @@ public class ControlLoopOperationTest { public void test() { ControlLoopOperation operation = new ControlLoopOperation(); - assertEquals(operation, operation); - assertNotEquals(operation, new String()); + /* + * Disabling sonar to test equals(). + */ + assertEquals(operation, operation); // NOSONAR + assertNotEquals(operation, ""); // NOSONAR assertNotEquals(operation, null); - assertTrue(operation.hashCode() != 0); + assertNotEquals(0, operation.hashCode()); assertTrue(operation.toString().startsWith("ControlLoopOperation")); assertNotNull(operation); @@ -68,7 +71,7 @@ public class ControlLoopOperationTest { operation.setTarget("target"); assertEquals("target", operation.getTarget()); - assertTrue(operation.hashCode() != 0); + assertNotEquals(0, operation.hashCode()); ControlLoopOperation operation2 = new ControlLoopOperation(operation); assertEquals(now, operation2.getEnd()); diff --git a/models-interactions/model-impl/guard/src/test/java/org/onap/policy/guard/OperationsHistoryTest.java b/models-interactions/model-impl/guard/src/test/java/org/onap/policy/guard/OperationsHistoryTest.java index f25ab86aa..32827b04b 100644 --- a/models-interactions/model-impl/guard/src/test/java/org/onap/policy/guard/OperationsHistoryTest.java +++ b/models-interactions/model-impl/guard/src/test/java/org/onap/policy/guard/OperationsHistoryTest.java @@ -19,7 +19,7 @@ package org.onap.policy.guard; 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 java.util.Date; @@ -61,9 +61,12 @@ public class OperationsHistoryTest { int hc = dao.hashCode(); dao.setId(101L); - assertTrue(hc != dao.hashCode()); + assertNotEquals(hc, dao.hashCode()); - assertTrue(dao.equals(dao)); - assertFalse(dao.equals(new OperationsHistory())); + /* + * Disabling sonar to test equals(). + */ + assertEquals(dao, dao); // NOSONAR + assertNotEquals(dao, new OperationsHistory()); } } diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java index 52c0912e3..21df853f4 100644 --- a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java +++ b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * rest * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,6 +22,7 @@ package org.onap.policy.rest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.lang.annotation.Documented; @@ -146,55 +147,55 @@ public class RestTest { Pair result = mgr.get(getUri, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("GOT: " + EXPECT_STRING, result.getRight()); result = mgr.delete(deleteUri, null, null, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + EXPECT_STRING, result.getRight()); result = mgr.delete(deleteUri, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + EXPECT_STRING, result.getRight()); result = mgr.put(putUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.put(putUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.post(postUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.post(postUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.patch(patchUri, null, null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.patch(patchUriBlank, null, null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight()); @@ -207,49 +208,49 @@ public class RestTest { Pair result = mgr.get(getUri, "", null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("GOT: " + EXPECT_STRING, result.getRight()); result = mgr.delete(deleteUri, "", null, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + EXPECT_STRING, result.getRight()); result = mgr.put(putUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.put(putUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.post(postUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.post(postUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.patch(patchUri, "", null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.patch(patchUriBlank, "", null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight()); @@ -262,49 +263,49 @@ public class RestTest { Pair result = mgr.get(getUri, "user", null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("GOT: " + EXPECT_STRING, result.getRight()); result = mgr.delete(deleteUri, "user", null, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + EXPECT_STRING, result.getRight()); result = mgr.put(putUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.put(putUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.post(postUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.post(postUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight()); result = mgr.patch(patchUri, "user", null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight()); result = mgr.patch(patchUriBlank, "user", null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight()); @@ -339,33 +340,33 @@ public class RestTest { Pair result = mgr.get(baseUri + "RestTest/GetHello/" + NAME_PARAM, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("GOT: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); result = mgr.delete(baseUri + "RestTest/DeleteHello/" + NAME_PARAM, null, null, null, null, null); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); result = mgr.put(baseUri + "RestTest/PutHello/" + NAME_PARAM, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); result = mgr.post(baseUri + "RestTest/PostHello/" + NAME_PARAM, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); result = mgr.patch(baseUri + "RestTest/PatchHello/" + NAME_PARAM, null, null, null, PAYLOAD); assertEquals((Integer) 200, result.getLeft()); - assertTrue(result.getRight() != null); + assertNotNull(result.getRight()); assertTrue(result.getRight().length() > 0); assertEquals("PATCH: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight()); diff --git a/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java b/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java index 91ed1e432..fd05affb5 100644 --- a/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java +++ b/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * sdc * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.policy.sdc; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.util.UUID; import org.junit.Test; @@ -112,8 +111,8 @@ public class ResourceInstanceTest { public void testEquals() { ResourceInstance ri1 = new ResourceInstance(); ResourceInstance ri2 = new ResourceInstance(ri1); - assertTrue(ri1.equals(ri2)); - assertTrue(ri2.equals(ri1)); + assertEquals(ri1, ri2); + assertEquals(ri2, ri1); ri1.setResourceInstanceName(INSTANCE); ri1.setResourceName(RESOURCE); @@ -122,8 +121,8 @@ public class ResourceInstanceTest { ri1.setResourceVersion(VERSION_000); ri1.setResourceType(ResourceType.VL); ri2 = new ResourceInstance(ri1); - assertTrue(ri1.equals(ri2)); - assertTrue(ri2.equals(ri1)); + assertEquals(ri1, ri2); + assertEquals(ri2, ri1); } @Test diff --git a/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java b/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java index 7b76a9de7..10e26bd9c 100644 --- a/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java +++ b/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * sdc * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.policy.sdc; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.util.UUID; import org.junit.Test; @@ -119,14 +118,14 @@ public class ResourceTest { public void testEquals() { Resource r1 = new Resource(); Resource r2 = new Resource(r1); - assertTrue(r1.equals(r2)); - assertTrue(r2.equals(r1)); + assertEquals(r1, r2); + assertEquals(r2, r1); r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), EQUALS_TEST, VERSION_111, ResourceType.VFC); r2 = new Resource(r1); - assertTrue(r1.equals(r2)); - assertTrue(r2.equals(r1)); + assertEquals(r1, r2); + assertEquals(r2, r1); } @Test diff --git a/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java b/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java index 336370518..ecd0bb323 100644 --- a/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java +++ b/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * sdc * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.policy.sdc; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.util.UUID; import org.junit.Test; @@ -125,8 +124,8 @@ public class ServiceInstanceTest { public void testEquals() { ServiceInstance si1 = new ServiceInstance(); ServiceInstance si2 = new ServiceInstance(si1); - assertTrue(si1.equals(si2)); - assertTrue(si2.equals(si1)); + assertEquals(si1, si2); + assertEquals(si2, si1); si1.setServiceInstanceName(INSTANCE); si1.setServiceName(SERVICE); @@ -136,8 +135,8 @@ public class ServiceInstanceTest { si1.setWidgetModelUUID(UUID.randomUUID()); si1.setWidgetModelVersion(VERSION_333); si2 = new ServiceInstance(si1); - assertTrue(si1.equals(si2)); - assertTrue(si2.equals(si1)); + assertEquals(si1, si2); + assertEquals(si2, si1); } @Test diff --git a/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java b/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java index d7913624c..1e6c6f917 100644 --- a/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java +++ b/models-interactions/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * sdc * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.policy.sdc; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.util.UUID; import org.junit.Test; @@ -107,13 +106,13 @@ public class ServiceTest { public void testEquals() { Service s1 = new Service(); Service s2 = new Service(s1); - assertTrue(s1.equals(s2)); - assertTrue(s2.equals(s1)); + assertEquals(s1, s2); + assertEquals(s2, s1); s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), EQUALS_TEST, VERSION_111); s2 = new Service(s1); - assertTrue(s1.equals(s2)); - assertTrue(s2.equals(s1)); + assertEquals(s1, s2); + assertEquals(s2, s1); } @Test diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java index dfd89c0fe..8c7ee6d53 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,8 @@ package org.onap.policy.sdnr; 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.time.Instant; import java.util.HashMap; @@ -79,70 +77,73 @@ public class PciCommonHeaderTest { copiedPciCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); copiedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); + /* + * Disabling sonar to test equals(). + */ + assertEquals(commonHeader, commonHeader); // NOSONAR + assertEquals(commonHeader, copiedPciCommonHeader); + assertNotEquals(commonHeader, null); + assertNotEquals(commonHeader, "Hello"); // NOSONAR PciCommonHeader clonedPciCommonHeader = new PciCommonHeader(commonHeader); clonedPciCommonHeader.setApiVer(commonHeader.getApiVer()); clonedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - assertTrue(commonHeader.equals(clonedPciCommonHeader)); + assertEquals(commonHeader, clonedPciCommonHeader); commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setApiVer(KANSAS); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setApiVer(KANSAS); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setFlags(flagMap); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setFlags(flagMap); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setRequestTrack(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setRequestTrack(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setRequestTrack(requestMap); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setRequestTrack(requestMap); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setSubRequestId(CAN_I_GO_HOME); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setSubRequestId(CAN_I_GO_HOME); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); + assertNotEquals(commonHeader, copiedPciCommonHeader); copiedPciCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertEquals(commonHeader, copiedPciCommonHeader); } } diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java index 0009c2a5c..7719d0966 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,8 @@ package org.onap.policy.sdnr; 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; @@ -61,36 +59,39 @@ public class PciRequestTest { copiedPciRequest.setAction(request.getAction()); copiedPciRequest.setPayload(request.getPayload()); - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedPciRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); + /* + * Disabling sonar to test equals(). + */ + assertEquals(request, request); // NOSONAR + assertEquals(request, copiedPciRequest); + assertNotEquals(request, null); + assertNotEquals(request, "Hello"); // NOSONAR request.setCommonHeader(null); - assertFalse(request.equals(copiedPciRequest)); + assertNotEquals(request, copiedPciRequest); copiedPciRequest.setCommonHeader(null); - assertTrue(request.equals(copiedPciRequest)); + assertEquals(request, copiedPciRequest); request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedPciRequest)); + assertNotEquals(request, copiedPciRequest); copiedPciRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedPciRequest)); + assertEquals(request, copiedPciRequest); request.setAction(null); - assertFalse(request.equals(copiedPciRequest)); + assertNotEquals(request, copiedPciRequest); copiedPciRequest.setAction(null); - assertTrue(request.equals(copiedPciRequest)); + assertEquals(request, copiedPciRequest); request.setAction(MODIFY); - assertFalse(request.equals(copiedPciRequest)); + assertNotEquals(request, copiedPciRequest); copiedPciRequest.setAction(MODIFY); - assertTrue(request.equals(copiedPciRequest)); + assertEquals(request, copiedPciRequest); request.setPayload(null); - assertFalse(request.equals(copiedPciRequest)); + assertNotEquals(request, copiedPciRequest); copiedPciRequest.setPayload(null); - assertTrue(request.equals(copiedPciRequest)); + assertEquals(request, copiedPciRequest); request.setPayload(requestPayload); - assertFalse(request.equals(copiedPciRequest)); + assertNotEquals(request, copiedPciRequest); copiedPciRequest.setPayload(requestPayload); - assertTrue(request.equals(copiedPciRequest)); + assertEquals(request, copiedPciRequest); } } diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java index 897c57d8c..65f362378 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +23,8 @@ package org.onap.policy.sdnr; 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; @@ -50,18 +49,21 @@ public class PciRequestWrapperTest { PciRequestWrapper copiedPciRequestWrapper = new PciRequestWrapper(); copiedPciRequestWrapper.setBody(requestWrapper.getBody()); - assertTrue(requestWrapper.equals(requestWrapper)); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - assertFalse(requestWrapper.equals(null)); - assertFalse(requestWrapper.equals("Hello")); + /* + * Disabling sonar to test equals(). + */ + assertEquals(requestWrapper, requestWrapper); // NOSONAR + assertEquals(requestWrapper, copiedPciRequestWrapper); + assertNotEquals(requestWrapper, null); + assertNotEquals(requestWrapper, "Hello"); // NOSONAR requestWrapper.setBody(null); - assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); + assertNotEquals(requestWrapper, copiedPciRequestWrapper); copiedPciRequestWrapper.setBody(null); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); + assertEquals(requestWrapper, copiedPciRequestWrapper); requestWrapper.setBody(request); - assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); + assertNotEquals(requestWrapper, copiedPciRequestWrapper); copiedPciRequestWrapper.setBody(request); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); + assertEquals(requestWrapper, copiedPciRequestWrapper); } } diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseTest.java index 6e990ea12..bd96e8e4c 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseTest.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,11 @@ package org.onap.policy.sdnr; +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 org.junit.Test; @@ -40,13 +41,13 @@ public class PciResponseTest { @Test public void testHashCode() { PciResponse response = new PciResponse(); - assertTrue(response.hashCode() != 0); + assertNotEquals(0, response.hashCode()); response.setCommonHeader(new PciCommonHeader()); - assertTrue(response.hashCode() != 0); + assertNotEquals(0, response.hashCode()); response.setPayload(responsePayload); - assertTrue(response.hashCode() != 0); + assertNotEquals(0, response.hashCode()); response.setStatus(null); - assertTrue(response.hashCode() != 0); + assertNotEquals(0, response.hashCode()); } @Test @@ -66,43 +67,43 @@ public class PciResponseTest { @Test public void testEqualsObject() { PciResponse response = new PciResponse(); - assertTrue(response.equals(response)); - assertFalse(response.equals(null)); - assertFalse(response.equals(new Object())); + assertEquals(response, response); + assertNotEquals(response, null); + assertNotEquals(response, new Object()); PciResponse response2 = new PciResponse(); - assertTrue(response.equals(response2)); + assertEquals(response, response2); response.setCommonHeader(new PciCommonHeader()); - assertFalse(response.equals(response2)); + assertNotEquals(response, response2); response2.setCommonHeader(response.getCommonHeader()); - assertTrue(response.equals(response2)); + assertEquals(response, response2); response.setPayload(responsePayload); - assertFalse(response.equals(response2)); + assertNotEquals(response, response2); response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); + assertEquals(response, response2); response.setCommonHeader(null); - assertFalse(response.equals(response2)); + assertNotEquals(response, response2); response2.setCommonHeader(null); - assertTrue(response.equals(response2)); + assertEquals(response, response2); response.setPayload(null); - assertFalse(response.equals(response2)); + assertNotEquals(response, response2); response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); + assertEquals(response, response2); response.setStatus(null); - assertFalse(response.equals(response2)); + assertNotEquals(response, response2); response2.setStatus(response.getStatus()); - assertTrue(response.equals(response2)); + assertEquals(response, response2); Status stat = new Status(); stat.setCode(5); response.setStatus(stat); response2.setStatus(new Status()); - assertFalse(response.equals(response2)); + assertNotEquals(response, response2); } @Test @@ -113,7 +114,7 @@ public class PciResponseTest { PciResponse response = new PciResponse(request); - assertTrue(response.getCommonHeader().equals(request.getCommonHeader())); + assertEquals(response.getCommonHeader(), request.getCommonHeader()); } } diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java index 166c3aa61..cb12083f3 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +23,8 @@ package org.onap.policy.sdnr; 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; @@ -50,18 +49,21 @@ public class PciResponseWrapperTest { PciResponseWrapper copiedPciResponseWrapper = new PciResponseWrapper(); copiedPciResponseWrapper.setBody(responseWrapper.getBody()); - assertTrue(responseWrapper.equals(responseWrapper)); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("Hello")); + /* + * Disabling sonar to test equals(). + */ + assertEquals(responseWrapper, responseWrapper); // NOSONAR + //assertEquals(responseWrapper, copiedPciResponseWrapper); + assertNotEquals(responseWrapper, null); + assertNotEquals(responseWrapper, "Hello"); // NOSONAR responseWrapper.setBody(null); - assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); + assertNotEquals(responseWrapper, copiedPciResponseWrapper); copiedPciResponseWrapper.setBody(null); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); + //assertEquals(responseWrapper, copiedPciResponseWrapper); responseWrapper.setBody(response); - //assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); + //assertNotEquals(responseWrapper, copiedPciResponseWrapper); copiedPciResponseWrapper.setBody(response); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); + //assertEquals(responseWrapper, copiedPciResponseWrapper); } } diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java index 08ac56b85..2f6c7f8ba 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,8 @@ package org.onap.policy.sdnr; 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; @@ -52,27 +50,30 @@ public class PciStatusTest { copiedStatus.setCode(status.getCode()); copiedStatus.setValue(status.getValue()); - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); + /* + * Disabling sonar to test equals(). + */ + assertEquals(status, status); // NOSONAR + assertEquals(status, copiedStatus); + assertNotEquals(status, null); + assertNotEquals(status, "Hello"); // NOSONAR status.setCode(-1); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); status.setCode(1234); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); status.setValue(null); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setValue(null); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); status.setValue(THE_WONDERFUL_LAND_OF_OZ); - assertFalse(status.equals(copiedStatus)); + assertNotEquals(status, copiedStatus); copiedStatus.setValue(THE_WONDERFUL_LAND_OF_OZ); - assertTrue(status.equals(copiedStatus)); + assertEquals(status, copiedStatus); } } diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java index f05f50e67..d25be8340 100644 --- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java +++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,8 @@ package org.onap.policy.sdnr; 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; @@ -70,54 +68,54 @@ public class PciWrapperTest { copiedPciWrapper.setCorrelationId(wrapper.getCorrelationId()); copiedPciWrapper.setType(wrapper.getType()); - assertTrue(wrapper.equals(wrapper)); - assertTrue(wrapper.equals(copiedPciWrapper)); - assertFalse(wrapper.equals(null)); - assertFalse(wrapper.equals("Hello")); + assertEquals(wrapper, wrapper); + assertEquals(wrapper, copiedPciWrapper); + assertNotEquals(wrapper, null); + assertNotEquals(wrapper, "Hello"); wrapper.setVersion(null); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setVersion(null); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setVersion(VERSION_19); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setVersion(VERSION_19); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setCambriaPartition(null); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setCambriaPartition(null); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setCambriaPartition(THE_EMERALD_CITY); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setCambriaPartition(THE_EMERALD_CITY); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setRpcName(null); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setRpcName(null); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setRpcName(TORNADO); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setRpcName(TORNADO); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setCorrelationId(null); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setCorrelationId(null); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setCorrelationId(YELLOW_BRICK_ROAD); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setCorrelationId(YELLOW_BRICK_ROAD); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setType(null); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setType(null); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); wrapper.setType(MUNCHKIN); - assertFalse(wrapper.equals(copiedPciWrapper)); + assertNotEquals(wrapper, copiedPciWrapper); copiedPciWrapper.setType(MUNCHKIN); - assertTrue(wrapper.equals(copiedPciWrapper)); + assertEquals(wrapper, copiedPciWrapper); } } diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java index 8d0fdb24c..4aa2db37c 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java @@ -3,7 +3,7 @@ * so * ================================================================================ * - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import java.time.LocalDateTime; import org.junit.Test; @@ -34,13 +34,13 @@ public class SoAsyncRequestStatusTest { public void testConstructor() { SoAsyncRequestStatus obj = new SoAsyncRequestStatus(); - assertTrue(obj.getCorrelator() == null); - assertTrue(obj.getFinishTime() == null); - assertTrue(obj.getInstanceReferences() == null); - assertTrue(obj.getRequestId() == null); - assertTrue(obj.getRequestScope() == null); - assertTrue(obj.getRequestStatus() == null); - assertTrue(obj.getStartTime() == null); + assertNull(obj.getCorrelator()); + assertNull(obj.getFinishTime()); + assertNull(obj.getInstanceReferences()); + assertNull(obj.getRequestId()); + assertNull(obj.getRequestScope()); + assertNull(obj.getRequestStatus()); + assertNull(obj.getStartTime()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java index 58b3943e4..59626f45d 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java @@ -3,7 +3,7 @@ * so * ================================================================================ * - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,8 +33,8 @@ public class SoCloudConfigurationTest { public void testConstructor() { SoCloudConfiguration obj = new SoCloudConfiguration(); - assertTrue(obj.getLcpCloudRegionId() == null); - assertTrue(obj.getTenantId() == null); + assertNull(obj.getLcpCloudRegionId()); + assertNull(obj.getTenantId()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java index 0b0aa5f03..b8e01c6c1 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +22,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,8 +32,8 @@ public class SoInstanceReferencesTest { public void testConstructor() { SoInstanceReferences obj = new SoInstanceReferences(); - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getRequestId() == null); + assertNull(obj.getInstanceId()); + assertNull(obj.getRequestId()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java index 60b86bf01..a9f5baaba 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java @@ -3,7 +3,7 @@ * so * ================================================================================ * - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,13 +33,13 @@ public class SoModelInfoTest { public void testConstructor() { SoModelInfo obj = new SoModelInfo(); - assertTrue(obj.getModelCustomizationId() == null); - assertTrue(obj.getModelCustomizationName() == null); - assertTrue(obj.getModelInvariantId() == null); - assertTrue(obj.getModelName() == null); - assertTrue(obj.getModelType() == null); - assertTrue(obj.getModelVersion() == null); - assertTrue(obj.getModelVersionId() == null); + assertNull(obj.getModelCustomizationId()); + assertNull(obj.getModelCustomizationName()); + assertNull(obj.getModelInvariantId()); + assertNull(obj.getModelName()); + assertNull(obj.getModelType()); + assertNull(obj.getModelVersion()); + assertNull(obj.getModelVersionId()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java index 3511d1349..e6fc8fee9 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -32,8 +32,8 @@ public class SoPolicyExceptionHolderTest { public void testConstructor() { SoPolicyExceptionHolder obj = new SoPolicyExceptionHolder(); - assertTrue(obj.getMessageId() == null); - assertTrue(obj.getText() == null); + assertNull(obj.getMessageId()); + assertNull(obj.getText()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java index bad45ebc8..b6c2e0671 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java @@ -3,7 +3,7 @@ * so * ================================================================================ * - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,7 +33,7 @@ public class SoRelatedInstanceListElementTest { public void testConstructor() { SoRelatedInstanceListElement obj = new SoRelatedInstanceListElement(); - assertTrue(obj.getRelatedInstance() == null); + assertNull(obj.getRelatedInstance()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java index 72afdda3f..f215d0184 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -32,9 +32,9 @@ public class SoRelatedInstanceTest { public void testConstructor() { SoRelatedInstance obj = new SoRelatedInstance(); - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getInstanceName() == null); - assertTrue(obj.getModelInfo() == null); + assertNull(obj.getInstanceId()); + assertNull(obj.getInstanceName()); + assertNull(obj.getModelInfo()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java index 25a89e31e..2fea0f868 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. * ================================================================================ - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,6 +27,7 @@ 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 java.util.ArrayList; @@ -39,13 +40,13 @@ public class SoRequestDetailsTest { public void testConstructor() { SoRequestDetails obj = new SoRequestDetails(); - assertTrue(obj.getCloudConfiguration() == null); - assertTrue(obj.getModelInfo() == null); - assertTrue(obj.getRequestInfo() == null); - assertTrue(obj.getRequestParameters() == null); - assertTrue(obj.getSubscriberInfo() == null); + assertNull(obj.getCloudConfiguration()); + assertNull(obj.getModelInfo()); + assertNull(obj.getRequestInfo()); + assertNull(obj.getRequestParameters()); + assertNull(obj.getSubscriberInfo()); - assertTrue(obj.getRelatedInstanceList() != null); + assertNotNull(obj.getRelatedInstanceList()); assertEquals(0, obj.getRelatedInstanceList().size()); } @@ -73,7 +74,7 @@ public class SoRequestDetailsTest { obj.setSubscriberInfo(subscriberInfo); assertEquals(subscriberInfo, obj.getSubscriberInfo()); } - + @Test public void testSoMRequestDetailsMethods() { SoRequestDetails details = new SoRequestDetails(); @@ -118,7 +119,7 @@ public class SoRequestDetailsTest { assertTrue(details.equals(copiedDetails)); assertFalse(details.equals(null)); assertFalse(details.equals("Hello")); - + details.setCloudConfiguration(null); assertFalse(details.equals(copiedDetails)); copiedDetails.setCloudConfiguration(null); @@ -136,7 +137,7 @@ public class SoRequestDetailsTest { assertFalse(details.equals(copiedDetails)); copiedDetails.setModelInfo(modelInfo); assertTrue(details.equals(copiedDetails)); - + details.setRequestInfo(null); assertFalse(details.equals(copiedDetails)); copiedDetails.setRequestInfo(null); diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java index e0b819343..f70e598f2 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ @@ -23,7 +23,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,8 +33,8 @@ public class SoRequestErrorTest { public void testConstructor() { SoRequestError obj = new SoRequestError(); - assertTrue(obj.getPolicyException() == null); - assertTrue(obj.getServiceException() == null); + assertNull(obj.getPolicyException()); + assertNull(obj.getServiceException()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java index 92638f906..563e28d31 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +22,8 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,8 +33,8 @@ public class SoRequestParametersTest { public void testConstructor() { SoRequestParameters obj = new SoRequestParameters(); - assertTrue(obj.getSubscriptionServiceType() == null); - assertTrue(obj.getUserParams() != null); + assertNull(obj.getSubscriptionServiceType()); + assertNotNull(obj.getUserParams()); assertEquals(0, obj.getUserParams().size()); } diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java index 42481996a..83172dee2 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +22,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,8 +32,8 @@ public class SoRequestReferencesTest { public void testConstructor() { SoRequestReferences obj = new SoRequestReferences(); - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getRequestId() == null); + assertNull(obj.getInstanceId()); + assertNull(obj.getRequestId()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java index b83cb00dc..2b0c572ce 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,6 +23,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -35,8 +35,8 @@ public class SoRequestStatusTest { SoRequestStatus obj = new SoRequestStatus(); assertEquals(0, obj.getPercentProgress()); - assertTrue(obj.getRequestState() == null); - assertTrue(obj.getTimestamp() == null); + assertNull(obj.getRequestState()); + assertNull(obj.getTimestamp()); assertFalse(obj.isWasRolledBack()); } diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java index 4dba63511..959016445 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +22,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import java.time.LocalDateTime; import java.util.UUID; @@ -35,13 +34,13 @@ public class SoRequestTest { public void testConstructor() { SoRequest obj = new SoRequest(); - assertTrue(obj.getFinishTime() == null); - assertTrue(obj.getRequestDetails() == null); - assertTrue(obj.getRequestId() == null); - assertTrue(obj.getRequestScope() == null); - assertTrue(obj.getRequestStatus() == null); - assertTrue(obj.getRequestType() == null); - assertTrue(obj.getStartTime() == null); + assertNull(obj.getFinishTime()); + assertNull(obj.getRequestDetails()); + assertNull(obj.getRequestId()); + assertNull(obj.getRequestScope()); + assertNull(obj.getRequestStatus()); + assertNull(obj.getRequestType()); + assertNull(obj.getStartTime()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java index eb1b0ef6d..c75aa9ec9 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +22,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -34,9 +33,9 @@ public class SoResponseTest { SoResponse obj = new SoResponse(); assertEquals(0, obj.getHttpResponseCode()); - assertTrue(obj.getRequest() == null); - assertTrue(obj.getRequestError() == null); - assertTrue(obj.getRequestReferences() == null); + assertNull(obj.getRequest()); + assertNull(obj.getRequestError()); + assertNull(obj.getRequestReferences()); } @Test diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java index 635e7dd16..e508c44f8 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; @@ -73,12 +72,16 @@ public class SoResponseWrapperTest { SoResponseWrapper identicalResponseWrapper = new SoResponseWrapper(response, requestId); - assertEquals(responseWrapper, responseWrapper); + /* + * Disabling sonar because we are purposely checking various branches of the + * equals() method. + */ + assertEquals(responseWrapper, responseWrapper); // NOSONAR assertEquals(responseWrapper, identicalResponseWrapper); assertNotEquals(null, responseWrapper); - assertNotEquals("Hello", responseWrapper); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("AString")); + assertNotEquals("Hello", responseWrapper); // NOSONAR + assertNotEquals(responseWrapper, null); + assertNotEquals(responseWrapper, "AString"); // NOSONAR assertEquals(new SoResponseWrapper(null, null), new SoResponseWrapper(null, null)); assertNotEquals(new SoResponseWrapper(null, null), identicalResponseWrapper); diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java index b5f31e595..981db650d 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +22,8 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,9 +33,9 @@ public class SoServiceExceptionHolderTest { public void testConstructor() { SoServiceExceptionHolder obj = new SoServiceExceptionHolder(); - assertTrue(obj.getMessageId() == null); - assertTrue(obj.getText() == null); - assertTrue(obj.getVariables() != null); + assertNull(obj.getMessageId()); + assertNull(obj.getText()); + assertNotNull(obj.getVariables()); assertEquals(0, obj.getVariables().size()); } diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java index 4d5bc7504..56278b0a9 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * so * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +22,7 @@ package org.onap.policy.so; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -33,9 +32,9 @@ public class SoSubscriberInfoTest { public void testConstructor() { SoSubscriberInfo obj = new SoSubscriberInfo(); - assertTrue(obj.getGlobalSubscriberId() == null); - assertTrue(obj.getSubscriberCommonSiteId() == null); - assertTrue(obj.getSubscriberName() == null); + assertNull(obj.getGlobalSubscriberId()); + assertNull(obj.getSubscriberCommonSiteId()); + assertNull(obj.getSubscriberName()); } @Test -- cgit 1.2.3-korg