aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-10 16:17:10 -0500
committerJim Hahn <jrh3@att.com>2021-02-10 17:17:34 -0500
commitb7097d21c25a48c9d209548ac8afdc09b1679457 (patch)
treeee7a911622c333818a9ac30f2cae68aee7eb6601 /models-interactions
parentf04d89c55ab4dfa94dfed1cc9b65471d1d3140c5 (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')
-rw-r--r--models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java4
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java4
-rw-r--r--models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java6
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java7
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java6
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java8
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java8
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java5
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java78
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java60
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java4
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java4
-rw-r--r--models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java159
-rw-r--r--models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java69
-rw-r--r--models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java60
-rw-r--r--models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java69
22 files changed, 173 insertions, 402 deletions
diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
index 89d5c4f2f..31b4aec6e 100644
--- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -65,7 +65,7 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
* @param config configuration for this operation
* @param propertyNames names of properties required by this operation
*/
- public AppcOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
+ protected AppcOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
List<String> propertyNames) {
super(params, config, Response.class, propertyNames);
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
index d235fb2c8..f3d6f1daf 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -47,7 +47,7 @@ public abstract class SdncOperation extends HttpOperation<SdncResponse> {
* @param config configuration for this operation
* @param propertyNames names of properties required by this operation
*/
- public SdncOperation(ControlLoopOperationParams params, HttpConfig config, List<String> propertyNames) {
+ protected SdncOperation(ControlLoopOperationParams params, HttpConfig config, List<String> propertyNames) {
super(params, config, SdncResponse.class, propertyNames);
}
diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
index fc4545966..f30802c32 100644
--- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -81,7 +81,7 @@ public abstract class BasicBidirectionalTopicOperation<Q> extends BasicOperation
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicBidirectionalTopicOperation() {
+ protected BasicBidirectionalTopicOperation() {
super();
}
@@ -91,7 +91,7 @@ public abstract class BasicBidirectionalTopicOperation<Q> extends BasicOperation
* @param actor actor name
* @param operation operation name
*/
- public BasicBidirectionalTopicOperation(String actor, String operation) {
+ protected BasicBidirectionalTopicOperation(String actor, String operation) {
super(actor, operation);
}
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
index ef9b37ba6..65ab0bbb3 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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,6 +23,7 @@ package org.onap.policy.controlloop.actor.test;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import java.io.FileNotFoundException;
import org.junit.Test;
public class BasicActorTest extends BasicActor {
@@ -42,6 +43,8 @@ public class BasicActorTest extends BasicActor {
.isThrownBy(() -> verifyActorService(DummyActor.NAME, "serviceMissingActors.yaml"));
// config file not found
- assertThatThrownBy(() -> verifyActorService(DummyActor.NAME, "file-not-found.yaml"));
+ assertThatThrownBy(() -> verifyActorService(DummyActor.NAME, "file-not-found.yaml"))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasCauseInstanceOf(FileNotFoundException.class);
}
}
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
index 65c7318ff..2d6dc5802 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -64,7 +64,7 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
* @param params operation parameters
* @param config configuration for this operation
*/
- public VfcOperation(ControlLoopOperationParams params, HttpConfig config) {
+ protected VfcOperation(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, VfcResponse.class, PROPERTY_NAMES);
setUsePolling();
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
index e02e59239..b0ad38eff 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -78,7 +78,7 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
* @param clazz response class
* @param propertyNames names of properties required by this operation
*/
- public BidirectionalTopicOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
+ protected BidirectionalTopicOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
Class<S> clazz, List<String> propertyNames) {
super(params, config, propertyNames);
this.config = config;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
index c75ca1d4f..a4b48d432 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -93,7 +93,7 @@ public abstract class HttpOperation<T> extends OperationPartial {
* @param clazz response class
* @param propertyNames names of properties required by this operation
*/
- public HttpOperation(ControlLoopOperationParams params, HttpConfig config, Class<T> clazz,
+ protected HttpOperation(ControlLoopOperationParams params, HttpConfig config, Class<T> clazz,
List<String> propertyNames) {
super(params, config, propertyNames);
this.config = config;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
index 6874c5edd..7ad0cd82e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -118,7 +118,7 @@ public abstract class OperationPartial implements Operation {
* @param config configuration for this operation
* @param propertyNames names of properties required by this operation
*/
- public OperationPartial(ControlLoopOperationParams params, OperatorConfig config, List<String> propertyNames) {
+ protected OperationPartial(ControlLoopOperationParams params, OperatorConfig config, List<String> propertyNames) {
this.params = params;
this.config = config;
this.fullName = params.getActor() + "." + params.getOperation();
@@ -518,7 +518,7 @@ public abstract class OperationPartial implements Operation {
return futures[0];
}
- CompletableFuture.anyOf(futures).thenApply(outcome -> (OperationOutcome) outcome)
+ CompletableFuture.anyOf(futures).thenApply(OperationOutcome.class::cast)
.whenCompleteAsync(controller.delayedComplete(), params.getExecutor());
return controller;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
index 8007c24f9..e75e99eaa 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -55,7 +55,7 @@ public abstract class OperatorPartial extends StartConfigPartial<Map<String, Obj
* @param actorName name of the actor with which this operator is associated
* @param name operation name
*/
- public OperatorPartial(String actorName, String name) {
+ protected OperatorPartial(String actorName, String name) {
super(actorName + "." + name);
this.actorName = actorName;
this.name = name;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
index 6c883f1b5..1cf611a61 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -51,7 +51,7 @@ public abstract class StartConfigPartial<T> implements Startable, Configurable<T
*
* @param fullName full name of this object, used for logging and exception purposes
*/
- public StartConfigPartial(String fullName) {
+ protected StartConfigPartial(String fullName) {
this.fullName = fullName;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
index 937776926..55bdab9ad 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -62,7 +62,7 @@ public abstract class TypedOperator<C, T extends Operation> extends OperatorPart
* @param name operation name
* @param operationMaker function to make an operation
*/
- public TypedOperator(String actorName, String name, OperationMaker<C, T> operationMaker) {
+ protected TypedOperator(String actorName, String name, OperationMaker<C, T> operationMaker) {
super(actorName, name);
this.operationMaker = operationMaker;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
index 605a7330c..6f667bb76 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -112,10 +112,10 @@ public class OperationOutcomeTest {
outcome.setOperation(OPERATION);
// null actor argument
- assertThatThrownBy(() -> outcome.isFor(null, OPERATION));
+ assertThatThrownBy(() -> outcome.isFor(null, OPERATION)).isInstanceOf(NullPointerException.class);
// null operation argument
- assertThatThrownBy(() -> outcome.isFor(ACTOR, null));
+ assertThatThrownBy(() -> outcome.isFor(ACTOR, null)).isInstanceOf(NullPointerException.class);
// true case
assertTrue(OperationOutcome.isFor(outcome, ACTOR, OPERATION));
@@ -126,7 +126,7 @@ public class OperationOutcomeTest {
outcome.setResult(OperationResult.FAILURE_EXCEPTION);
assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult());
- assertThatThrownBy(() -> outcome.setResult(null));
+ assertThatThrownBy(() -> outcome.setResult(null)).isInstanceOf(NullPointerException.class);
}
private void setAll() {
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
index 08d4adfd2..95799b7d2 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -166,7 +166,7 @@ public class BidirectionalTopicOperationTest {
assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals(response, outcome.getResponse());
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
/**
@@ -194,7 +194,7 @@ public class BidirectionalTopicOperationTest {
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(future.isCompletedExceptionally());
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
/**
@@ -210,7 +210,7 @@ public class BidirectionalTopicOperationTest {
verify(forwarder).register(eq(Arrays.asList(REQ_ID)), listenerCaptor.capture());
// must still unregister
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
@Test
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
index 54d56de53..7f2f6770e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -26,7 +26,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -68,7 +67,7 @@ public class BidirectionalTopicHandlerTest {
MockitoAnnotations.initMocks(this);
when(mgr.getTopicSinks(MY_SINK)).thenReturn(Arrays.asList(publisher));
- when(mgr.getTopicSources(eq(Arrays.asList(MY_SOURCE)))).thenReturn(Arrays.asList(subscriber));
+ when(mgr.getTopicSources(Arrays.asList(MY_SOURCE))).thenReturn(Arrays.asList(subscriber));
when(publisher.getTopicCommInfrastructure()).thenReturn(CommInfrastructure.NOOP);
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 30d4ed910..686e6a416 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-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class CommonHeaderTest {
@@ -94,67 +95,28 @@ public class CommonHeaderTest {
assertEquals(commonHeader, clonedCommonHeader);
- commonHeader.setApiVer(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setApiVer(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setApiVer(KANSAS);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setApiVer(KANSAS);
- assertEquals(commonHeader, copiedCommonHeader);
+ checkField(KANSAS, CommonHeader::setApiVer);
+ checkField(flagSet, CommonHeader::setFlags);
+ checkField(DOROTHY, CommonHeader::setOriginatorId);
+ checkField(requestId, CommonHeader::setRequestId);
+ checkField(requestTrackSet, CommonHeader::setRequestTrack);
+ checkField(CAN_I_GO_HOME, CommonHeader::setSubRequestId);
+ checkField(timestamp, CommonHeader::setTimeStamp);
+ }
- commonHeader.setFlags(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setFlags(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setFlags(flagSet);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setFlags(flagSet);
- assertEquals(commonHeader, copiedCommonHeader);
+ private <T> void checkField(T value, BiConsumer<CommonHeader, T> setter) {
+ CommonHeader header1 = new CommonHeader();
+ CommonHeader header2 = new CommonHeader(header1);
- commonHeader.setOriginatorId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setOriginatorId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setOriginatorId(DOROTHY);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setOriginatorId(DOROTHY);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header2, null);
- commonHeader.setRequestId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setRequestId(requestId);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestId(requestId);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header1, value);
+ assertNotEquals(header1, header2);
- commonHeader.setRequestTrack(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestTrack(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setRequestTrack(requestTrackSet);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestTrack(requestTrackSet);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header2, value);
+ assertEquals(header1, header2);
- commonHeader.setSubRequestId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setSubRequestId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertEquals(commonHeader, copiedCommonHeader);
-
- commonHeader.setTimeStamp(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setTimeStamp(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setTimeStamp(timestamp);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setTimeStamp(timestamp);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header1, null);
+ assertNotEquals(header1, header2);
}
}
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 43686a747..5bff56b78 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-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 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.assertNotNull;
import java.util.HashMap;
import java.util.Map;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class RequestTest {
@@ -77,49 +78,26 @@ public class RequestTest {
assertNotEquals(request, null);
assertNotEquals(request, (Object) "Hello");
- request.setCommonHeader(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setCommonHeader(null);
- assertEquals(request, copiedRequest);
- request.setCommonHeader(commonHeader);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setCommonHeader(commonHeader);
- assertEquals(request, copiedRequest);
+ checkField(commonHeader, Request::setCommonHeader);
+ checkField(GO_TO_OZ, Request::setAction);
+ checkField(WIZARD, Request::setObjectId);
+ checkField("Oz", Request::setTargetId);
+ checkField(payload, Request::setPayload);
+ }
- request.setAction(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setAction(null);
- assertEquals(request, copiedRequest);
- request.setAction(GO_TO_OZ);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setAction(GO_TO_OZ);
- assertEquals(request, copiedRequest);
+ private <T> void checkField(T value, BiConsumer<Request, T> setter) {
+ Request request1 = new Request();
+ Request request2 = new Request();
- request.setObjectId(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setObjectId(null);
- assertEquals(request, copiedRequest);
- request.setObjectId(WIZARD);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setObjectId(WIZARD);
- assertEquals(request, copiedRequest);
+ setter.accept(request2, null);
- request.setTargetId(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setTargetId(null);
- assertEquals(request, copiedRequest);
- request.setTargetId("Oz");
- assertNotEquals(request, copiedRequest);
- copiedRequest.setTargetId("Oz");
- assertEquals(request, copiedRequest);
+ setter.accept(request1, value);
+ assertNotEquals(request1, request2);
- request.setPayload(new HashMap<>());
- assertNotEquals(request, copiedRequest);
- copiedRequest.setPayload(new HashMap<>());
- assertEquals(request, copiedRequest);
- request.setPayload(payload);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setPayload(payload);
- assertEquals(request, copiedRequest);
+ setter.accept(request2, value);
+ assertEquals(request1, request2);
+
+ setter.accept(request1, null);
+ assertNotEquals(request1, request2);
}
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
index 3106e3909..4f0dbf730 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,7 +54,7 @@ public abstract class ControlLoopEvent implements Serializable {
*
* @param event the existing instance
*/
- public ControlLoopEvent(ControlLoopEvent event) {
+ protected ControlLoopEvent(ControlLoopEvent event) {
if (event == null) {
return;
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
index c4c46d30a..890fb083a 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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");
@@ -57,7 +57,7 @@ public abstract class ControlLoopNotification implements Serializable {
*
* @param event the event
*/
- public ControlLoopNotification(ControlLoopEvent event) {
+ protected ControlLoopNotification(ControlLoopEvent event) {
if (event == null) {
return;
}
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 21df853f4..e5a887429 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-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -145,60 +145,39 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, null, null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, null, null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.delete(deleteUri, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, null, null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, null, null, null, PAYLOAD);
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
+
+ }
+
+ private void checkResult(Pair<Integer, String> result, String expectedText) {
assertEquals((Integer) 200, result.getLeft());
assertNotNull(result.getRight());
assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
-
+ assertEquals(expectedText, result.getRight());
}
@Test
@@ -206,53 +185,28 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, "", null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, "", null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, "", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, "", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
}
@@ -261,53 +215,28 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, "user", null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, "user", null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, "user", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, "user", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
}
@@ -338,37 +267,21 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(baseUri + "RestTest/GetHello/" + NAME_PARAM, null, null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "GOT: " + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.delete(baseUri + "RestTest/DeleteHello/" + NAME_PARAM, null, null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.put(baseUri + "RestTest/PutHello/" + NAME_PARAM, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.post(baseUri + "RestTest/PostHello/" + NAME_PARAM, null, null,
null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.patch(baseUri + "RestTest/PatchHello/" + NAME_PARAM, null, null,
null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
}
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 f4c0bf32d..9d497602f 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-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 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.
@@ -30,6 +30,7 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class PciCommonHeaderTest {
@@ -88,59 +89,27 @@ public class PciCommonHeaderTest {
assertEquals(commonHeader, clonedPciCommonHeader);
- commonHeader.setApiVer(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setApiVer(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setApiVer(KANSAS);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setApiVer(KANSAS);
- assertEquals(commonHeader, copiedPciCommonHeader);
-
- commonHeader.setFlags(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setFlags(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setFlags(flagMap);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setFlags(flagMap);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ checkField(KANSAS, PciCommonHeader::setApiVer);
+ checkField(flagMap, PciCommonHeader::setFlags);
+ checkField(requestMap, PciCommonHeader::setRequestTrack);
+ checkField(requestId, PciCommonHeader::setRequestId);
+ checkField(CAN_I_GO_HOME, PciCommonHeader::setSubRequestId);
+ checkField(timestamp, PciCommonHeader::setTimeStamp);
+ }
- commonHeader.setRequestTrack(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestTrack(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setRequestTrack(requestMap);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestTrack(requestMap);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ private <T> void checkField(T value, BiConsumer<PciCommonHeader, T> setter) {
+ PciCommonHeader details1 = new PciCommonHeader();
+ PciCommonHeader details2 = new PciCommonHeader(details1);
+ setter.accept(details2, null);
- commonHeader.setRequestId(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestId(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setRequestId(requestId);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestId(requestId);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details1, value);
+ assertNotEquals(details1, details2);
- commonHeader.setSubRequestId(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setSubRequestId(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details2, value);
+ assertEquals(details1, details2);
- commonHeader.setTimeStamp(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setTimeStamp(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setTimeStamp(timestamp);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setTimeStamp(timestamp);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details1, null);
+ assertNotEquals(details1, details2);
}
}
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 914974691..91d42a3bf 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-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 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.
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class PciWrapperTest {
@@ -73,49 +74,26 @@ public class PciWrapperTest {
assertNotEquals(wrapper, null);
assertNotEquals(wrapper, (Object) "Hello");
- wrapper.setVersion(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setVersion(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setVersion(VERSION_19);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setVersion(VERSION_19);
- assertEquals(wrapper, copiedPciWrapper);
+ checkField(VERSION_19, PciWrapper::setVersion);
+ checkField(THE_EMERALD_CITY, PciWrapper::setCambriaPartition);
+ checkField(TORNADO, PciWrapper::setRpcName);
+ checkField(YELLOW_BRICK_ROAD, PciWrapper::setCorrelationId);
+ checkField(MUNCHKIN, PciWrapper::setType);
+ }
- wrapper.setCambriaPartition(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCambriaPartition(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setCambriaPartition(THE_EMERALD_CITY);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCambriaPartition(THE_EMERALD_CITY);
- assertEquals(wrapper, copiedPciWrapper);
+ private <T> void checkField(T value, BiConsumer<PciWrapper, T> setter) {
+ PciWrapper details1 = new PciWrapper();
+ PciWrapper details2 = new PciWrapper();
- wrapper.setRpcName(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setRpcName(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setRpcName(TORNADO);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setRpcName(TORNADO);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details2, null);
- wrapper.setCorrelationId(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCorrelationId(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCorrelationId(YELLOW_BRICK_ROAD);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details1, value);
+ assertNotEquals(details1, details2);
- wrapper.setType(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setType(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setType(MUNCHKIN);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setType(MUNCHKIN);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details2, value);
+ assertEquals(details1, details2);
+
+ setter.accept(details1, null);
+ assertNotEquals(details1, details2);
}
}
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);
}
}