Merge "Alter PDP_UPDATE message to store lists of delpoyed/undeployed policies"
authorRam Krishna Verma <ram_krishna.verma@bell.ca>
Fri, 12 Feb 2021 14:37:42 +0000 (14:37 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 12 Feb 2021 14:37:42 +0000 (14:37 +0000)
66 files changed:
models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
models-base/src/main/java/org/onap/policy/models/base/PfKey.java
models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
models-base/src/main/java/org/onap/policy/models/base/PfModel.java
models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java
models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java
models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperatorTest.java
models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardConfigTest.java
models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java
models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperatorTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicConfigTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpConfigTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/FutureManagerTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/ListenerManagerTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java
models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java
models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java
models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLegacyTopicServerTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SdnrTopicServerTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/TopicServerTest.java
models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java
models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilter.java
models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilter.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java

index 394eb89..2357ec0 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  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.
@@ -36,7 +36,7 @@ public abstract class PfConcept extends Validated implements Serializable, Compa
     /**
      * Default constructor.
      */
-    public PfConcept() {
+    protected PfConcept() {
         // Default Constructor
     }
 
@@ -45,7 +45,7 @@ public abstract class PfConcept extends Validated implements Serializable, Compa
      *
      * @param copyConcept the concept to copy from
      */
-    public PfConcept(@NonNull final PfConcept copyConcept) {
+    protected PfConcept(@NonNull final PfConcept copyConcept) {
         // nothing else to do (other than @NonNull check)
     }
 
index d2015eb..e7cab46 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2020 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.
@@ -72,6 +72,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
         implements PfConceptGetter<C>, PfAuthorative<List<Map<String, A>>> {
     private static final long serialVersionUID = -324211738823208318L;
 
+    private static final String VALUE_FIELD = "value";
     private static final Pattern KEY_ID_PATTERN = Pattern.compile(PfKey.KEY_ID_REGEXP);
 
     @EmbeddedId
@@ -268,14 +269,14 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
                 addResult(result, "key on concept entry", conceptEntry.getKey(), IS_A_NULL_KEY);
             } else if (conceptEntry.getValue() == null) {
                 result2 = new BeanValidationResult(conceptEntry.getKey().getId(), conceptEntry.getKey());
-                addResult(result2, "value", conceptEntry.getValue(), IS_NULL);
+                addResult(result2, VALUE_FIELD, conceptEntry.getValue(), IS_NULL);
             } else if (!conceptEntry.getKey().equals(conceptEntry.getValue().getKey())) {
                 result2 = new BeanValidationResult(conceptEntry.getKey().getId(), conceptEntry.getKey());
-                addResult(result2, "value", conceptEntry.getValue(), "does not equal concept key");
-                result2.addResult(conceptEntry.getValue().validate("value"));
+                addResult(result2, VALUE_FIELD, conceptEntry.getValue(), "does not equal concept key");
+                result2.addResult(conceptEntry.getValue().validate(VALUE_FIELD));
             } else {
                 result2 = new BeanValidationResult(conceptEntry.getKey().getId(), conceptEntry.getKey());
-                result2.addResult(conceptEntry.getValue().validate("value"));
+                result2.addResult(conceptEntry.getValue().validate(VALUE_FIELD));
             }
 
             result.addResult(result2);
index f38689a..4b7f8cf 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 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.
@@ -69,7 +70,7 @@ public abstract class PfKey extends PfConcept {
     /**
      * Default constructor.
      */
-    public PfKey() {
+    protected PfKey() {
         super();
     }
 
@@ -78,7 +79,7 @@ public abstract class PfKey extends PfConcept {
      *
      * @param copyConcept the concept to copy from
      */
-    public PfKey(final PfKey copyConcept) {
+    protected PfKey(final PfKey copyConcept) {
         super(copyConcept);
     }
 
index bfeb870..b6d1219 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2020 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.
@@ -42,7 +42,7 @@ public abstract class PfKeyImpl extends PfKey {
     /**
      * The default constructor creates a null concept key.
      */
-    public PfKeyImpl() {
+    protected PfKeyImpl() {
         this(NULL_KEY_NAME, NULL_KEY_VERSION);
     }
 
@@ -51,7 +51,7 @@ public abstract class PfKeyImpl extends PfKey {
      *
      * @param copyConcept the concept to copy from
      */
-    public PfKeyImpl(final PfKeyImpl copyConcept) {
+    protected PfKeyImpl(final PfKeyImpl copyConcept) {
         super(copyConcept);
         setName(copyConcept.getName());
         setVersion(copyConcept.getVersion());
@@ -63,7 +63,7 @@ public abstract class PfKeyImpl extends PfKey {
      * @param name the key name
      * @param version the key version
      */
-    public PfKeyImpl(@NonNull final String name, @NonNull final String version) {
+    protected PfKeyImpl(@NonNull final String name, @NonNull final String version) {
         super();
         setName(name);
         setVersion(version);
@@ -74,7 +74,7 @@ public abstract class PfKeyImpl extends PfKey {
      *
      * @param id the key ID in a format that respects the KEY_ID_REGEXP
      */
-    public PfKeyImpl(@NonNull final String id) {
+    protected PfKeyImpl(@NonNull final String id) {
         // Check the incoming ID is valid
         Assertions.validateStringParameter("id", id, getKeyIdRegEx());
 
index bdd652a..8cdcb90 100644 (file)
@@ -72,7 +72,7 @@ public abstract class PfModel extends PfConcept {
     /**
      * The Default Constructor creates this concept with a NULL artifact key.
      */
-    public PfModel() {
+    protected PfModel() {
         this(new PfConceptKey());
     }
 
@@ -81,7 +81,7 @@ public abstract class PfModel extends PfConcept {
      *
      * @param key the key of this concept
      */
-    public PfModel(@NonNull final PfConceptKey key) {
+    protected PfModel(@NonNull final PfConceptKey key) {
         super();
         Assertions.argumentNotNull(key, "key may not be null");
 
@@ -93,7 +93,7 @@ public abstract class PfModel extends PfConcept {
      *
      * @param copyConcept the concept to copy from
      */
-    public PfModel(@NonNull final PfModel copyConcept) {
+    protected PfModel(@NonNull final PfModel copyConcept) {
         super(copyConcept);
         this.key = new PfConceptKey(copyConcept.key);
     }
index 91fa301..8fa757a 100644 (file)
@@ -110,7 +110,8 @@ public class ValidatedTest {
         BeanValidationResult result2 = new BeanValidationResult("", this);
 
         // null parameter tests
-        assertThatThrownBy(() -> Validated.validateKeyNotNull(result2, null, new PfConceptKey()))
+        PfConceptKey conceptKey = new PfConceptKey();
+        assertThatThrownBy(() -> Validated.validateKeyNotNull(result2, null, conceptKey))
                         .isInstanceOf(NullPointerException.class);
 
         assertThatCode(() -> Validated.validateKeyNotNull(result2, MY_FIELD, null)).doesNotThrowAnyException();
@@ -131,7 +132,8 @@ public class ValidatedTest {
         assertThat(result.getResult()).contains(MY_FIELD).contains("version").contains(Validated.IS_NULL);
 
         BeanValidationResult result2 = new BeanValidationResult("", this);
-        assertThatThrownBy(() -> Validated.validateKeyVersionNotNull(result2, null, new PfConceptKey()))
+        PfConceptKey conceptKey = new PfConceptKey();
+        assertThatThrownBy(() -> Validated.validateKeyVersionNotNull(result2, null, conceptKey))
                         .isInstanceOf(NullPointerException.class);
 
         assertThatCode(() -> Validated.validateKeyVersionNotNull(result2, MY_FIELD, null)).doesNotThrowAnyException();
index 89d5c4f..31b4aec 100644 (file)
@@ -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);
     }
index 07a05e6..456b10f 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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.
@@ -31,13 +31,15 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.MockitoAnnotations;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
 import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
 import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
 
+@RunWith(MockitoJUnitRunner.class)
 public class GrpcActorServiceManagerTest {
 
     CdsActorServiceManager manager;
@@ -49,7 +51,6 @@ public class GrpcActorServiceManagerTest {
      */
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
         future = new CompletableFuture<>();
         manager = new CdsActorServiceManager(new OperationOutcome(), future);
     }
index 9291a3a..0809291 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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.
@@ -24,9 +24,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -34,17 +31,16 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
 import org.onap.policy.cds.client.CdsProcessorGrpcClient;
 import org.onap.policy.cds.properties.CdsServerProperties;
@@ -63,6 +59,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
 import org.onap.policy.simulators.CdsSimulator;
 import org.onap.policy.simulators.Util;
 
+@RunWith(MockitoJUnitRunner.class)
 public class GrpcOperationTest {
     private static final String MY_VNF = "my-vnf";
     private static final String MY_SVC_ID = "my-service-instance-id";
@@ -104,8 +101,6 @@ public class GrpcOperationTest {
      */
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
         // Setup the CDS properties
         cdsProps = new CdsServerProperties();
         cdsProps.setHost("10.10.10.10");
@@ -114,9 +109,6 @@ public class GrpcOperationTest {
         cdsProps.setPassword("testPassword");
         cdsProps.setTimeout(1);
 
-        // Setup cdsClient
-        when(cdsClient.sendRequest(any(ExecutionServiceInput.class))).thenReturn(mock(CountDownLatch.class));
-
         // Setup executor
         executor = new PseudoExecutor();
 
index 3e3b1f5..aa11d7e 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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.
@@ -28,7 +28,8 @@ import java.util.Map;
 import java.util.UUID;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.MockitoAnnotations;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.cds.properties.CdsServerProperties;
 import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
 import org.onap.policy.controlloop.actorserviceprovider.Operation;
@@ -36,6 +37,7 @@ import org.onap.policy.controlloop.actorserviceprovider.Util;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
 
+@RunWith(MockitoJUnitRunner.class)
 public class GrpcOperatorTest {
 
     GrpcOperator operation;
@@ -47,7 +49,6 @@ public class GrpcOperatorTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         operation = new GrpcOperator(CdsActorConstants.CDS_ACTOR, GrpcOperation.NAME, GrpcOperation::new);
 
         CdsServerProperties props = new CdsServerProperties();
index 170bcdf..76b7841 100644 (file)
@@ -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.
@@ -28,13 +28,15 @@ import static org.mockito.Mockito.when;
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
 import org.onap.policy.controlloop.actorserviceprovider.Util;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
 
+@RunWith(MockitoJUnitRunner.class)
 public class DecisionOperatorTest {
     private static final String ACTOR = "my-actor";
     private static final String OPERATION = "my-name";
@@ -61,8 +63,6 @@ public class DecisionOperatorTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(factory.get(CLIENT)).thenReturn(client);
 
         oper = new MyOperator();
index d30c711..2d929d5 100644 (file)
@@ -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.
@@ -29,12 +29,14 @@ import static org.mockito.Mockito.when;
 import java.util.concurrent.Executor;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
 
+@RunWith(MockitoJUnitRunner.class)
 public class GuardConfigTest {
     private static final String MY_CLIENT = "my-client";
     private static final String PATH = "my-path";
@@ -59,8 +61,6 @@ public class GuardConfigTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(factory.get(MY_CLIENT)).thenReturn(client);
 
         params = GuardParams.builder().onapName(ONAP_NAME).onapComponent(ONAP_COMP).onapInstance(ONAP_INST)
index d235fb2..f3d6f1d 100644 (file)
@@ -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);
     }
 
index fc45459..f30802c 100644 (file)
@@ -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);
     }
 
index 539202c..766e0fb 100644 (file)
@@ -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 class BasicOperation {
      * Initializes mocks and sets up.
      */
     public void setUpBasic() {
-        MockitoAnnotations.initMocks(this);
+        MockitoAnnotations.openMocks(this);
 
         future = new CompletableFuture<>();
 
index ef9b37b..65ab0bb 100644 (file)
@@ -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);
     }
 }
index 6cccc5c..c708a17 100644 (file)
@@ -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.
@@ -33,14 +33,16 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 import org.onap.policy.common.utils.coder.StandardCoderObject;
 import org.onap.policy.simulators.TopicServer;
 
+@RunWith(MockitoJUnitRunner.class)
 public class BasicBidirectionalTopicOperationTest {
     private static final String ACTOR = "my-actor";
     private static final String OPERATION = "my-operation";
@@ -66,8 +68,6 @@ public class BasicBidirectionalTopicOperationTest {
      */
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
         oper = new MyOperation(ACTOR, OPERATION);
         oper.setUpBasic();
     }
index 65c7318..2d6dc58 100644 (file)
@@ -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();
index e02e592..b0ad38e 100644 (file)
@@ -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;
index c75ca1d..a4b48d4 100644 (file)
@@ -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;
index 6874c5e..7ad0cd8 100644 (file)
@@ -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;
index 8007c24..e75e99e 100644 (file)
@@ -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;
index 6c883f1..1cf611a 100644 (file)
@@ -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;
     }
 
index 9377769..55bdab9 100644 (file)
@@ -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;
     }
index 605a733..6f667bb 100644 (file)
@@ -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() {
index 6a8813c..64d530d 100644 (file)
@@ -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.
@@ -38,8 +38,9 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
 import org.onap.policy.controlloop.actorserviceprovider.Util;
@@ -47,6 +48,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.Bidirectional
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
 
+@RunWith(MockitoJUnitRunner.class)
 public class BidirectionalTopicActorTest {
 
     private static final String ACTOR = "my-actor";
@@ -90,8 +92,6 @@ public class BidirectionalTopicActorTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         actor = new MyActor();
         actor.configure(Util.translateToMap(ACTOR, makeParams()));
     }
index 08d4adf..662f864 100644 (file)
@@ -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.
@@ -44,10 +44,11 @@ import lombok.Getter;
 import lombok.Setter;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.CoderException;
@@ -61,6 +62,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
 import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
 
+@RunWith(MockitoJUnitRunner.class)
 public class BidirectionalTopicOperationTest {
     private static final CommInfrastructure SINK_INFRA = CommInfrastructure.NOOP;
     private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
@@ -98,8 +100,6 @@ public class BidirectionalTopicOperationTest {
      */
     @Before
     public void setUp() throws CoderException {
-        MockitoAnnotations.initMocks(this);
-
         when(config.getTopicHandler()).thenReturn(handler);
         when(config.getForwarder()).thenReturn(forwarder);
         when(config.getTimeoutMs()).thenReturn(TIMEOUT_MS);
@@ -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
index d0dc0a7..4d19782 100644 (file)
@@ -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.
@@ -33,8 +33,9 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.controlloop.actorserviceprovider.Util;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
@@ -45,6 +46,7 @@ import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopic
 import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
 import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
 
+@RunWith(MockitoJUnitRunner.class)
 public class BidirectionalTopicOperatorTest {
     private static final String ACTOR = "my-actor";
     private static final String OPERATION = "my-operation";
@@ -70,8 +72,6 @@ public class BidirectionalTopicOperatorTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         keys = List.of(new SelectorKey(""));
 
         when(mgr.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(handler);
index 82aa091..117b409 100644 (file)
@@ -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,8 +62,9 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder;
@@ -83,6 +84,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
 
+@RunWith(MockitoJUnitRunner.class)
 public class HttpOperationTest {
 
     private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
@@ -169,8 +171,6 @@ public class HttpOperationTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         rejectRequest = false;
         nget = 0;
         npost = 0;
index af8f1aa..35cf082 100644 (file)
@@ -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.
@@ -34,8 +34,9 @@ import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
 import org.onap.policy.controlloop.actorserviceprovider.Operation;
@@ -46,6 +47,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
 
+@RunWith(MockitoJUnitRunner.class)
 public class HttpOperatorTest {
 
     private static final String ACTOR = "my-actor";
@@ -68,8 +70,6 @@ public class HttpOperatorTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(factory.get(HTTP_CLIENT)).thenReturn(client);
 
         oper = new MyOperator();
index 45ef293..bd44663 100644 (file)
@@ -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.
@@ -39,8 +39,9 @@ import javax.ws.rs.client.InvocationCallback;
 import javax.ws.rs.core.Response;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.mockito.stubbing.Answer;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
@@ -52,6 +53,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingCo
 /**
  * Tests HttpOperation when polling is enabled.
  */
+@RunWith(MockitoJUnitRunner.class)
 public class HttpPollingOperationTest {
     private static final String BASE_URI = "http://my-host:6969/base-uri/";
     private static final String MY_PATH = "my-path";
@@ -84,12 +86,9 @@ public class HttpPollingOperationTest {
      */
     @Before
     public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
         when(client.getBaseUrl()).thenReturn(BASE_URI);
 
         when(config.getClient()).thenReturn(client);
-        when(config.getPath()).thenReturn(MY_PATH);
         when(config.getMaxPolls()).thenReturn(MAX_POLLS);
         when(config.getPollPath()).thenReturn(POLL_PATH);
         when(config.getPollWaitSec()).thenReturn(POLL_WAIT_SEC);
@@ -120,8 +119,6 @@ public class HttpPollingOperationTest {
 
         // should throw an exception if we pass a plain HttpConfig
         HttpConfig config2 = mock(HttpConfig.class);
-        when(config2.getClient()).thenReturn(client);
-        when(config2.getPath()).thenReturn(MY_PATH);
 
         assertThatIllegalStateException().isThrownBy(() -> new MyOper(params, config2).setUsePolling());
     }
index 413667b..f340f19 100644 (file)
@@ -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.
@@ -30,8 +30,9 @@ import java.util.Collections;
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
 import org.onap.policy.controlloop.actorserviceprovider.Util;
@@ -41,6 +42,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingCo
 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
 
+@RunWith(MockitoJUnitRunner.class)
 public class HttpPollingOperatorTest {
     private static final String ACTOR = "my-actor";
     private static final String OPERATION = "my-name";
@@ -64,8 +66,6 @@ public class HttpPollingOperatorTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(factory.get(CLIENT)).thenReturn(client);
 
         oper = new MyOperator();
index f6dbcd8..d617a72 100644 (file)
@@ -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.
@@ -28,8 +28,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
 
 import ch.qos.logback.classic.Logger;
 import java.time.Instant;
@@ -59,8 +57,9 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
 import org.onap.policy.common.utils.coder.Coder;
@@ -80,6 +79,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.OperatorConfi
 import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
 import org.slf4j.LoggerFactory;
 
+@RunWith(MockitoJUnitRunner.class)
 public class OperationPartialTest {
     private static final CommInfrastructure SINK_INFRA = CommInfrastructure.NOOP;
     private static final CommInfrastructure SOURCE_INFRA = CommInfrastructure.UEB;
@@ -160,18 +160,12 @@ public class OperationPartialTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         executor = new PseudoExecutor();
 
         params = ControlLoopOperationParams.builder().completeCallback(this::completer).requestId(REQ_ID)
                         .executor(executor).actorService(service).actor(ACTOR).operation(OPERATION).timeoutSec(TIMEOUT)
                         .startCallback(this::starter).build();
 
-        when(service.getActor(OperationPartial.GUARD_ACTOR_NAME)).thenReturn(guardActor);
-        when(guardActor.getOperator(OperationPartial.GUARD_OPERATION_NAME)).thenReturn(guardOperator);
-        when(guardOperator.buildOperation(any())).thenReturn(guardOperation);
-        when(guardOperation.start()).thenReturn(CompletableFuture.completedFuture(makeSuccess()));
-
         config = new OperatorConfig(executor);
 
         oper = new MyOper();
@@ -1048,13 +1042,6 @@ public class OperationPartialTest {
         };
     }
 
-    private OperationOutcome makeSuccess() {
-        OperationOutcome outcome = params.makeOutcome();
-        outcome.setResult(OperationResult.SUCCESS);
-
-        return outcome;
-    }
-
     /**
      * Verifies a run.
      *
index 7c6a98f..7b44333 100644 (file)
@@ -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.
@@ -29,13 +29,15 @@ import java.util.List;
 import java.util.concurrent.Executor;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicManager;
 import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
 import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
 
+@RunWith(MockitoJUnitRunner.class)
 public class BidirectionalTopicConfigTest {
     private static final String MY_SINK = "my-sink";
     private static final String MY_SOURCE = "my-source";
@@ -57,8 +59,6 @@ public class BidirectionalTopicConfigTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         List<SelectorKey> keys = Arrays.asList(new SelectorKey(""));
 
         when(topicManager.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(topicHandler);
index 3390451..bdf6b30 100644 (file)
@@ -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.
@@ -46,8 +46,9 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.parameters.BeanValidationResult;
 import org.onap.policy.controlloop.actorserviceprovider.ActorService;
 import org.onap.policy.controlloop.actorserviceprovider.Operation;
@@ -56,6 +57,7 @@ import org.onap.policy.controlloop.actorserviceprovider.Operator;
 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams.ControlLoopOperationParamsBuilder;
 import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
 
+@RunWith(MockitoJUnitRunner.class)
 public class ControlLoopOperationParamsTest {
     private static final String NULL_MSG = "null";
     private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -100,8 +102,6 @@ public class ControlLoopOperationParamsTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(actorService.getActor(ACTOR)).thenReturn(actor);
         when(actor.getOperator(OPERATION)).thenReturn(operator);
         when(operator.buildOperation(any())).thenReturn(operation);
index 309b30f..181e0ba 100644 (file)
@@ -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.
@@ -27,11 +27,13 @@ import static org.mockito.Mockito.when;
 import java.util.concurrent.Executor;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
 
+@RunWith(MockitoJUnitRunner.class)
 public class HttpConfigTest {
     private static final String MY_CLIENT = "my-client";
     private static final String MY_PATH = "my-path";
@@ -51,8 +53,6 @@ public class HttpConfigTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(factory.get(MY_CLIENT)).thenReturn(client);
 
         HttpParams params = HttpParams.builder().clientName(MY_CLIENT).path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
index 53be6c7..65fd308 100644 (file)
@@ -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.
@@ -27,11 +27,13 @@ import static org.mockito.Mockito.when;
 import java.util.concurrent.Executor;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.http.client.HttpClient;
 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
 
+@RunWith(MockitoJUnitRunner.class)
 public class HttpPollingConfigTest {
     private static final String MY_CLIENT = "my-client";
     private static final String MY_PATH = "my-path";
@@ -55,8 +57,6 @@ public class HttpPollingConfigTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(factory.get(MY_CLIENT)).thenReturn(client);
 
         params = HttpPollingParams.builder().maxPolls(MAX_POLLS).pollPath(POLL_PATH).pollWaitSec(WAIT_SEC)
index de1cf0f..eff3dbb 100644 (file)
@@ -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.
@@ -30,9 +30,11 @@ import static org.mockito.Mockito.when;
 import java.util.concurrent.Future;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 
+@RunWith(MockitoJUnitRunner.class)
 public class FutureManagerTest {
 
     private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -53,8 +55,6 @@ public class FutureManagerTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         mgr = new FutureManager();
     }
 
index 4a882d4..bbd82cb 100644 (file)
@@ -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.
@@ -28,9 +28,11 @@ import static org.mockito.Mockito.verify;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 
+@RunWith(MockitoJUnitRunner.class)
 public class ListenerManagerTest {
 
     private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -51,8 +53,6 @@ public class ListenerManagerTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         mgr = new ListenerManager();
     }
 
index 4a00c06..44c9e20 100644 (file)
@@ -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.
@@ -43,10 +43,12 @@ import java.util.function.BiConsumer;
 import java.util.function.Function;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 
+@RunWith(MockitoJUnitRunner.class)
 public class PipelineControllerFutureTest {
     private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
     private static final String TEXT = "some text";
@@ -77,8 +79,6 @@ public class PipelineControllerFutureTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         compFuture = spy(new CompletableFuture<>());
 
         controller = new PipelineControllerFuture<>();
index 54d56de..f96fc0f 100644 (file)
@@ -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,21 +26,22 @@ 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;
 
 import java.util.Arrays;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
 
+@RunWith(MockitoJUnitRunner.class)
 public class BidirectionalTopicHandlerTest {
     private static final String UNKNOWN = "unknown";
     private static final String MY_SOURCE = "my-source";
@@ -65,10 +66,8 @@ public class BidirectionalTopicHandlerTest {
      */
     @Before
     public void setUp() throws BidirectionalTopicClientException {
-        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);
 
index a01159b..3b368e2 100644 (file)
@@ -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.
@@ -32,11 +32,13 @@ import java.util.Map;
 import java.util.function.BiConsumer;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.utils.coder.StandardCoderObject;
 import org.onap.policy.controlloop.actorserviceprovider.Util;
 
+@RunWith(MockitoJUnitRunner.class)
 public class ForwarderTest {
     private static final String TEXT = "some text";
 
@@ -75,7 +77,6 @@ public class ForwarderTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
         forwarder = new Forwarder(Arrays.asList(new SelectorKey(KEY1), new SelectorKey(KEY2, SUBKEY)));
 
         forwarder.register(Arrays.asList(VALUEA_REQID, VALUEA_SUBREQID), listener1);
@@ -159,9 +160,6 @@ public class ForwarderTest {
         verify(listener1b, times(2)).accept(any(), any());
         verify(listener2).accept(any(), any());
         verify(listener3).accept(any(), any());
-
-        // listener throws an exception
-        doThrow(new IllegalStateException("expected exception")).when(listener1).accept(any(), any());
     }
 
     /*
index 3012ff6..9e3b476 100644 (file)
@@ -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.
@@ -33,13 +33,15 @@ import java.util.Map;
 import java.util.function.BiConsumer;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.coder.StandardCoderObject;
 
+@RunWith(MockitoJUnitRunner.class)
 public class TopicListenerImplTest {
     private static final StandardCoder coder = new StandardCoder();
     private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
@@ -72,8 +74,6 @@ public class TopicListenerImplTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         topic = new TopicListenerImpl();
 
         forwarder1 = topic.addForwarder(new SelectorKey(KEY1));
index 30d4ed9..686e6a4 100644 (file)
@@ -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);
     }
 }
index 43686a7..5bff56b 100644 (file)
@@ -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);
     }
 }
index 3106e39..4f0dbf7 100644 (file)
@@ -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;
         }
index c4c46d3..890fb08 100644 (file)
@@ -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;
         }
index 21df853..e5a8874 100644 (file)
@@ -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");
 
     }
 
index f4c0bf3..9d49760 100644 (file)
@@ -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);
     }
 }
index 9149746..91d42a3 100644 (file)
@@ -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);
     }
 }
index 43d5cd3..66de1b2 100644 (file)
@@ -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);
     }
 }
index f3f546a..9560658 100644 (file)
@@ -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.
@@ -28,14 +28,16 @@ import static org.mockito.Mockito.verify;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 
+@RunWith(MockitoJUnitRunner.class)
 public class AppcLcmTopicServerTest {
     private static final String MY_TOPIC = "my-topic";
 
@@ -51,8 +53,6 @@ public class AppcLcmTopicServerTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         server = new AppcLcmTopicServer(sink, source);
     }
 
index c3c3195..25cba30 100644 (file)
@@ -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.
@@ -28,14 +28,16 @@ import static org.mockito.Mockito.verify;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 
+@RunWith(MockitoJUnitRunner.class)
 public class AppcLegacyTopicServerTest {
     private static final String MY_TOPIC = "my-topic";
 
@@ -51,8 +53,6 @@ public class AppcLegacyTopicServerTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         server = new AppcLegacyTopicServer(sink, source);
     }
 
index d8f6d11..96ea9fb 100644 (file)
@@ -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.
@@ -28,14 +28,16 @@ import static org.mockito.Mockito.verify;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 
+@RunWith(MockitoJUnitRunner.class)
 public class SdnrTopicServerTest {
     private static final String MY_TOPIC = "my-topic";
 
@@ -51,8 +53,6 @@ public class SdnrTopicServerTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         server = new SdnrTopicServer(sink, source);
     }
 
index 11a5e3f..972769d 100644 (file)
@@ -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.
@@ -28,13 +28,15 @@ import static org.mockito.Mockito.verify;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
 import org.onap.policy.common.utils.coder.StandardCoder;
 
+@RunWith(MockitoJUnitRunner.class)
 public class TopicServerTest {
     private static final String MY_TOPIC = "my-topic";
     private static final String TEXT = "hello";
@@ -52,8 +54,6 @@ public class TopicServerTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         server = new MyServer();
     }
 
index 596f9fa..4f57490 100644 (file)
@@ -299,7 +299,7 @@ public class DatabasePolicyModelsProviderTest {
         assertTrue(databaseProvider.getPolicyTypeList(NAME, VERSION_100).isEmpty());
 
         assertThatThrownBy(
-                () -> databaseProvider.getFilteredPolicyTypes(ToscaEntityFilter.<ToscaPolicyType>builder().build()))
+            () -> databaseProvider.getFilteredPolicyTypes(ToscaEntityFilter.<ToscaPolicyType>builder().build()))
                         .hasMessage("service template not found in database");
 
         assertTrue(databaseProvider.getFilteredPolicyTypeList(ToscaEntityFilter.<ToscaPolicyType>builder().build())
@@ -322,7 +322,7 @@ public class DatabasePolicyModelsProviderTest {
         assertTrue(databaseProvider.getPolicyList(NAME, VERSION_100).isEmpty());
 
         assertThatThrownBy(
-                () -> databaseProvider.getFilteredPolicies(ToscaTypedEntityFilter.<ToscaPolicy>builder().build()))
+            () -> databaseProvider.getFilteredPolicies(ToscaTypedEntityFilter.<ToscaPolicy>builder().build()))
                         .hasMessage("service template not found in database");
 
         assertTrue(databaseProvider.getFilteredPolicyList(ToscaTypedEntityFilter.<ToscaPolicy>builder().build())
index 6c79ce9..3d72f2e 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -44,15 +44,17 @@ import javax.ws.rs.core.Response.Status;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.coder.StandardCoderObject;
 import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
 
+@RunWith(MockitoJUnitRunner.class)
 public class DmaapSimProviderTest {
     private static final String EXPECTED_EXCEPTION = "expected exception";
     private static final long SWEEP_SEC = 10L;
@@ -86,8 +88,6 @@ public class DmaapSimProviderTest {
      */
     @Before
     public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
         when(params.getTopicSweepSec()).thenReturn(SWEEP_SEC);
 
         prov = new MyProvider(params);
index ef0b6b1..d6f3a68 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2021 Nordix Foundation.
+ *  Modifications Copyright (C) 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 +56,7 @@ public class ToscaEntityFilter<T extends ToscaEntity> implements PfObjectFilter<
         // @formatter:off
 
         if (LATEST_VERSION.equals(version)) {
-            return this.latestVersionFilter(returnList, new ToscaEntityComparator<T>());
+            return this.latestVersionFilter(returnList, new ToscaEntityComparator<>());
         } else  {
             return returnList;
         }
index b6ff86b..749873a 100644 (file)
@@ -67,7 +67,7 @@ public class ToscaTypedEntityFilter<T extends ToscaEntity> implements PfObjectFi
         // @formatter:off
 
         if (LATEST_VERSION.equals(version)) {
-            return this.latestVersionFilter(returnList, new ToscaEntityComparator<T>());
+            return this.latestVersionFilter(returnList, new ToscaEntityComparator<>());
         } else  {
             return returnList;
         }
index 4dfbae7..f3dbeb0 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Model
  * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * 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");
@@ -46,7 +46,7 @@ public abstract class JpaToscaConstraint
      *
      * @param authorativeConcept the authorative concept to copy from
      */
-    public JpaToscaConstraint(final ToscaConstraint authorativeConcept) {
+    protected JpaToscaConstraint(final ToscaConstraint authorativeConcept) {
         this.fromAuthorative(authorativeConcept);
     }
 
index 893cdbe..2416bab 100644 (file)
@@ -26,7 +26,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
 import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
 import javax.persistence.Column;
 import javax.persistence.ElementCollection;
 import javax.persistence.EmbeddedId;
@@ -61,12 +60,8 @@ public class JpaToscaEntityType<T extends ToscaEntity> extends PfConcept impleme
 
     // @formatter:off
     @Column
-    @AttributeOverrides({
-        @AttributeOverride(name = "name",
-                           column = @Column(name = "derived_from_name")),
-        @AttributeOverride(name = "version",
-                           column = @Column(name = "derived_from_version"))
-        })
+    @AttributeOverride(name = "name", column = @Column(name = "derived_from_name"))
+    @AttributeOverride(name = "version", column = @Column(name = "derived_from_version"))
     @VerifyKey
     private PfConceptKey derivedFrom;
 
index 9a07ea1..c28a1ae 100644 (file)
@@ -33,7 +33,6 @@ import javax.persistence.FetchType;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
 import javax.persistence.Lob;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
@@ -81,14 +80,14 @@ public class JpaToscaNodeTemplate extends JpaToscaEntityType<ToscaNodeTemplate>
 
     // formatter:off
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns({@JoinColumn(name = "requirementsName", referencedColumnName = "name"),
-        @JoinColumn(name = "requirementsVersion", referencedColumnName = "version")})
+    @JoinColumn(name = "requirementsName", referencedColumnName = "name")
+    @JoinColumn(name = "requirementsVersion", referencedColumnName = "version")
     @Valid
     private JpaToscaRequirements requirements;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns({@JoinColumn(name = "capabilitiesName", referencedColumnName = "name"),
-        @JoinColumn(name = "capabilitiesVersion", referencedColumnName = "version")})
+    @JoinColumn(name = "capabilitiesName", referencedColumnName = "name")
+    @JoinColumn(name = "capabilitiesVersion", referencedColumnName = "version")
     @Valid
     private JpaToscaCapabilityAssignments capabilities;
     // @formatter:on
index 5ea21ed..86be4b3 100644 (file)
@@ -35,7 +35,6 @@ import javax.persistence.FetchType;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
 import javax.persistence.Lob;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
@@ -76,8 +75,8 @@ public class JpaToscaNodeType extends JpaToscaEntityType<ToscaNodeType> implemen
 
     // formatter:off
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns({@JoinColumn(name = "requirementsName", referencedColumnName = "name"),
-        @JoinColumn(name = "requirementsVersion", referencedColumnName = "version")})
+    @JoinColumn(name = "requirementsName", referencedColumnName = "name")
+    @JoinColumn(name = "requirementsVersion", referencedColumnName = "version")
     // @formatter:on
     @Valid
     private JpaToscaRequirements requirements;
index 0be0435..11f1199 100644 (file)
@@ -27,7 +27,6 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
 import javax.persistence.Column;
 import javax.persistence.ElementCollection;
 import javax.persistence.Entity;
@@ -76,12 +75,8 @@ public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements P
 
     // @formatter:off
     @Column
-    @AttributeOverrides({
-        @AttributeOverride(name = "name",
-                           column = @Column(name = "type_name")),
-        @AttributeOverride(name = "version",
-                           column = @Column(name = "type_version"))
-        })
+    @AttributeOverride(name = "name", column = @Column(name = "type_name"))
+    @AttributeOverride(name = "version", column = @Column(name = "type_version"))
     @VerifyKey
     @NotNull
     private PfConceptKey type;
index 594a5c3..0d9060d 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2021 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.
@@ -34,7 +34,6 @@ import javax.persistence.FetchType;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import lombok.Data;
@@ -49,11 +48,6 @@ import org.onap.policy.models.base.PfAuthorative;
 import org.onap.policy.models.base.PfConcept;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 /**
@@ -84,69 +78,45 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp
     private String toscaDefinitionsVersion;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns(
-            {
-                @JoinColumn(name = "dataTypesName",    referencedColumnName = "name"),
-                @JoinColumn(name = "dataTypesVersion", referencedColumnName = "version")
-            }
-        )
+    @JoinColumn(name = "dataTypesName",    referencedColumnName = "name")
+    @JoinColumn(name = "dataTypesVersion", referencedColumnName = "version")
     @SerializedName("data_types")
     @Valid
     private JpaToscaDataTypes dataTypes;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns(
-            {
-                @JoinColumn(name = "capabilityTypesName",    referencedColumnName = "name"),
-                @JoinColumn(name = "capabilityTypesVersion", referencedColumnName = "version")
-            }
-        )
+    @JoinColumn(name = "capabilityTypesName",    referencedColumnName = "name")
+    @JoinColumn(name = "capabilityTypesVersion", referencedColumnName = "version")
     @SerializedName("capability_types")
     @Valid
     private JpaToscaCapabilityTypes capabilityTypes;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns(
-            {
-                @JoinColumn(name = "relationshipTypesName",    referencedColumnName = "name"),
-                @JoinColumn(name = "relationshipTypesVersion", referencedColumnName = "version")
-            }
-        )
+    @JoinColumn(name = "relationshipTypesName",    referencedColumnName = "name")
+    @JoinColumn(name = "relationshipTypesVersion", referencedColumnName = "version")
     @SerializedName("relationship_types")
     @Valid
     private JpaToscaRelationshipTypes relationshipTypes;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns(
-            {
-                @JoinColumn(name = "nodeTypesName",    referencedColumnName = "name"),
-                @JoinColumn(name = "nodeTypesVersion", referencedColumnName = "version")
-            }
-        )
+    @JoinColumn(name = "nodeTypesName",    referencedColumnName = "name")
+    @JoinColumn(name = "nodeTypesVersion", referencedColumnName = "version")
     @SerializedName("node_types")
     @Valid
     private JpaToscaNodeTypes nodeTypes;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns(
-            {
-                @JoinColumn(name = "policyTypesName",    referencedColumnName = "name"),
-                @JoinColumn(name = "policyTypesVersion", referencedColumnName = "version")
-            }
-        )
+    @JoinColumn(name = "policyTypesName",    referencedColumnName = "name")
+    @JoinColumn(name = "policyTypesVersion", referencedColumnName = "version")
     @SerializedName("policy_types")
     @Valid
     private JpaToscaPolicyTypes policyTypes;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns(
-            {
-                @JoinColumn(name = "topologyTemplateParentKeyName",    referencedColumnName = "parentKeyName"),
-                @JoinColumn(name = "topologyTemplateParentKeyVersion", referencedColumnName = "parentKeyVersion"),
-                @JoinColumn(name = "topologyTemplateParentLocalName",  referencedColumnName = "parentLocalName"),
-                @JoinColumn(name = "topologyTemplateLocalName",        referencedColumnName = "localName")
-            }
-        )
+    @JoinColumn(name = "topologyTemplateParentKeyName",    referencedColumnName = "parentKeyName")
+    @JoinColumn(name = "topologyTemplateParentKeyVersion", referencedColumnName = "parentKeyVersion")
+    @JoinColumn(name = "topologyTemplateParentLocalName",  referencedColumnName = "parentLocalName")
+    @JoinColumn(name = "topologyTemplateLocalName",        referencedColumnName = "localName")
     @SerializedName("topology_template")
     @Valid
     private JpaToscaTopologyTemplate topologyTemplate;
@@ -219,43 +189,23 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp
         toscaServiceTemplate.setToscaDefinitionsVersion(toscaDefinitionsVersion);
 
         if (dataTypes != null) {
-            toscaServiceTemplate.setDataTypes(new LinkedHashMap<>());
-            List<Map<String, ToscaDataType>> dataTypeMapList = dataTypes.toAuthorative();
-            for (Map<String, ToscaDataType> dataTypeMap : dataTypeMapList) {
-                toscaServiceTemplate.getDataTypes().putAll(dataTypeMap);
-            }
+            toscaServiceTemplate.setDataTypes(flattenMap(dataTypes.toAuthorative()));
         }
 
         if (capabilityTypes != null) {
-            toscaServiceTemplate.setCapabilityTypes(new LinkedHashMap<>());
-            List<Map<String, ToscaCapabilityType>> capabilityTypeMapList = capabilityTypes.toAuthorative();
-            for (Map<String, ToscaCapabilityType> capabilityTypeMap : capabilityTypeMapList) {
-                toscaServiceTemplate.getCapabilityTypes().putAll(capabilityTypeMap);
-            }
+            toscaServiceTemplate.setCapabilityTypes(flattenMap(capabilityTypes.toAuthorative()));
         }
 
         if (relationshipTypes != null) {
-            toscaServiceTemplate.setRelationshipTypes(new LinkedHashMap<>());
-            List<Map<String, ToscaRelationshipType>> relationshipTypeMapList = relationshipTypes.toAuthorative();
-            for (Map<String, ToscaRelationshipType> relationshipTypeMap : relationshipTypeMapList) {
-                toscaServiceTemplate.getRelationshipTypes().putAll(relationshipTypeMap);
-            }
+            toscaServiceTemplate.setRelationshipTypes(flattenMap(relationshipTypes.toAuthorative()));
         }
 
         if (nodeTypes != null) {
-            toscaServiceTemplate.setNodeTypes(new LinkedHashMap<>());
-            List<Map<String, ToscaNodeType>> nodeTypeMapList = nodeTypes.toAuthorative();
-            for (Map<String, ToscaNodeType> nodeTypeMap : nodeTypeMapList) {
-                toscaServiceTemplate.getNodeTypes().putAll(nodeTypeMap);
-            }
+            toscaServiceTemplate.setNodeTypes(flattenMap(nodeTypes.toAuthorative()));
         }
 
         if (policyTypes != null) {
-            toscaServiceTemplate.setPolicyTypes(new LinkedHashMap<>());
-            List<Map<String, ToscaPolicyType>> policyTypeMapList = policyTypes.toAuthorative();
-            for (Map<String, ToscaPolicyType> policyTypeMap : policyTypeMapList) {
-                toscaServiceTemplate.getPolicyTypes().putAll(policyTypeMap);
-            }
+            toscaServiceTemplate.setPolicyTypes(flattenMap(policyTypes.toAuthorative()));
         }
 
         if (topologyTemplate != null) {
@@ -265,6 +215,22 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp
         return toscaServiceTemplate;
     }
 
+    /**
+     * Takes a list of maps and flattens it into a single map.
+     *
+     * @param list list to be be flattened
+     * @return a map containing all of the elements from the list of maps
+     */
+    private <V> Map<String, V> flattenMap(List<Map<String, V>> list) {
+        Map<String, V> result = new LinkedHashMap<>();
+
+        for (Map<String, V> map : list) {
+            result.putAll(map);
+        }
+
+        return result;
+    }
+
     @Override
     public void fromAuthorative(ToscaServiceTemplate toscaServiceTemplate) {
         super.fromAuthorative(toscaServiceTemplate);
index 86add36..b00b14a 100644 (file)
@@ -35,7 +35,6 @@ import javax.persistence.FetchType;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
 import javax.persistence.Lob;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
@@ -87,23 +86,15 @@ public class JpaToscaTopologyTemplate extends PfConcept implements PfAuthorative
     private Map<@NotNull String, @NotNull @Valid JpaToscaParameter> inputs;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns(
-        {
-            @JoinColumn(name = "nodeTemplatesName", referencedColumnName = "name"),
-            @JoinColumn(name = "nodeTemplatessVersion", referencedColumnName = "version")
-        }
-    )
+    @JoinColumn(name = "nodeTemplatesName", referencedColumnName = "name")
+    @JoinColumn(name = "nodeTemplatessVersion", referencedColumnName = "version")
     @SerializedName("data_types")
     @Valid
     private JpaToscaNodeTemplates nodeTemplates;
 
     @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinColumns(
-            {
-                @JoinColumn(name = "policyName",    referencedColumnName = "name"),
-                @JoinColumn(name = "policyVersion", referencedColumnName = "version")
-            }
-        )
+    @JoinColumn(name = "policyName",    referencedColumnName = "name")
+    @JoinColumn(name = "policyVersion", referencedColumnName = "version")
     // @formatter:on
     @Valid
     private JpaToscaPolicies policies;