diff options
author | Jim Hahn <jrh3@att.com> | 2021-02-10 16:17:10 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-02-10 17:17:34 -0500 |
commit | b7097d21c25a48c9d209548ac8afdc09b1679457 (patch) | |
tree | ee7a911622c333818a9ac30f2cae68aee7eb6601 /models-interactions/model-impl/so/src | |
parent | f04d89c55ab4dfa94dfed1cc9b65471d1d3140c5 (diff) |
More sonars in models
Addressed the following:
- make constructors protected
- check exception type
- too many assertions
- remove annotation lists
- use "<>"
- reduce cognitive complexity
- extract constant
- multiple method calls in one assert
- don't use eq() in verify()
- indentation
Issue-ID: POLICY-2905
Change-Id: I25bb3951f781250e9cdfe8f5f3b80cb63e129184
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-impl/so/src')
-rw-r--r-- | models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java | 69 |
1 files changed, 19 insertions, 50 deletions
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 43d5cd38a..66de1b2cd 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 @@ -3,8 +3,7 @@ * so * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved + * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +29,7 @@ import static org.junit.Assert.assertNull; import java.util.ArrayList; import java.util.List; +import java.util.function.BiConsumer; import org.junit.Test; public class SoRequestDetailsTest { @@ -118,58 +118,27 @@ public class SoRequestDetailsTest { assertNotEquals(details, null); assertNotEquals(details, (Object) "Hello"); - details.setCloudConfiguration(null); - assertNotEquals(details, copiedDetails); - copiedDetails.setCloudConfiguration(null); - assertEquals(details, copiedDetails); - details.setCloudConfiguration(cloudConfiguration); - assertNotEquals(details, copiedDetails); - copiedDetails.setCloudConfiguration(cloudConfiguration); - assertEquals(details, copiedDetails); + checkField(cloudConfiguration, SoRequestDetails::setCloudConfiguration); + checkField(modelInfo, SoRequestDetails::setModelInfo); + checkField(requestInfo, SoRequestDetails::setRequestInfo); + checkField(requestParameters, SoRequestDetails::setRequestParameters); + checkField(subscriberInfo, SoRequestDetails::setSubscriberInfo); + checkField(relatedInstanceList, SoRequestDetails::setRelatedInstanceList); + } - details.setModelInfo(null); - assertNotEquals(details, copiedDetails); - copiedDetails.setModelInfo(null); - assertEquals(details, copiedDetails); - details.setModelInfo(modelInfo); - assertNotEquals(details, copiedDetails); - copiedDetails.setModelInfo(modelInfo); - assertEquals(details, copiedDetails); + private <T> void checkField(T value, BiConsumer<SoRequestDetails, T> setter) { + SoRequestDetails details1 = new SoRequestDetails(); + SoRequestDetails details2 = new SoRequestDetails(details1); - details.setRequestInfo(null); - assertNotEquals(details, copiedDetails); - copiedDetails.setRequestInfo(null); - assertEquals(details, copiedDetails); - details.setRequestInfo(requestInfo); - assertNotEquals(details, copiedDetails); - copiedDetails.setRequestInfo(requestInfo); - assertEquals(details, copiedDetails); + setter.accept(details2, null); - details.setRequestParameters(null); - assertNotEquals(details, copiedDetails); - copiedDetails.setRequestParameters(null); - assertEquals(details, copiedDetails); - details.setRequestParameters(requestParameters); - assertNotEquals(details, copiedDetails); - copiedDetails.setRequestParameters(requestParameters); - assertEquals(details, copiedDetails); + setter.accept(details1, value); + assertNotEquals(details1, details2); - details.setSubscriberInfo(null); - assertNotEquals(details, copiedDetails); - copiedDetails.setSubscriberInfo(null); - assertEquals(details, copiedDetails); - details.setSubscriberInfo(subscriberInfo); - assertNotEquals(details, copiedDetails); - copiedDetails.setSubscriberInfo(subscriberInfo); - assertEquals(details, copiedDetails); + setter.accept(details2, value); + assertEquals(details1, details2); - details.setRelatedInstanceList(null); - assertNotEquals(details, copiedDetails); - copiedDetails.setRelatedInstanceList(null); - assertEquals(details, copiedDetails); - details.setRelatedInstanceList(relatedInstanceList); - assertNotEquals(details, copiedDetails); - copiedDetails.setRelatedInstanceList(relatedInstanceList); - assertEquals(details, copiedDetails); + setter.accept(details1, null); + assertNotEquals(details1, details2); } } |