aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-10 16:17:10 -0500
committerJim Hahn <jrh3@att.com>2021-02-10 17:17:34 -0500
commitb7097d21c25a48c9d209548ac8afdc09b1679457 (patch)
treeee7a911622c333818a9ac30f2cae68aee7eb6601
parentf04d89c55ab4dfa94dfed1cc9b65471d1d3140c5 (diff)
More sonars in models
Addressed the following: - make constructors protected - check exception type - too many assertions - remove annotation lists - use "<>" - reduce cognitive complexity - extract constant - multiple method calls in one assert - don't use eq() in verify() - indentation Issue-ID: POLICY-2905 Change-Id: I25bb3951f781250e9cdfe8f5f3b80cb63e129184 Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConcept.java6
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java11
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfKey.java5
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java10
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModel.java6
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java6
-rw-r--r--models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java4
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java4
-rw-r--r--models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java6
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java7
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java6
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java8
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java8
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java5
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java78
-rw-r--r--models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java60
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java4
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java4
-rw-r--r--models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java159
-rw-r--r--models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java69
-rw-r--r--models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java60
-rw-r--r--models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java69
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java4
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilter.java3
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilter.java2
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java4
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java5
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java106
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java17
38 files changed, 254 insertions, 533 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java b/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
index 394eb89f2..2357ec00d 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
@@ -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)
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
index d2015eb7e..e7cab460e 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
@@ -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);
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
index f38689a04..4b7f8cf95 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
@@ -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);
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java b/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
index bfeb870c1..b6d12198c 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java
@@ -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());
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
index bdd652a92..8cdcb90b7 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java
@@ -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);
}
diff --git a/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java b/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
index 91fa301f9..8fa757a00 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
@@ -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();
diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
index 89d5c4f2f..31b4aec6e 100644
--- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
* @param config configuration for this operation
* @param propertyNames names of properties required by this operation
*/
- public AppcOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
+ protected AppcOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
List<String> propertyNames) {
super(params, config, Response.class, propertyNames);
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
index d235fb2c8..f3d6f1daf 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public abstract class SdncOperation extends HttpOperation<SdncResponse> {
* @param config configuration for this operation
* @param propertyNames names of properties required by this operation
*/
- public SdncOperation(ControlLoopOperationParams params, HttpConfig config, List<String> propertyNames) {
+ protected SdncOperation(ControlLoopOperationParams params, HttpConfig config, List<String> propertyNames) {
super(params, config, SdncResponse.class, propertyNames);
}
diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
index fc4545966..f30802c32 100644
--- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -81,7 +81,7 @@ public abstract class BasicBidirectionalTopicOperation<Q> extends BasicOperation
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicBidirectionalTopicOperation() {
+ protected BasicBidirectionalTopicOperation() {
super();
}
@@ -91,7 +91,7 @@ public abstract class BasicBidirectionalTopicOperation<Q> extends BasicOperation
* @param actor actor name
* @param operation operation name
*/
- public BasicBidirectionalTopicOperation(String actor, String operation) {
+ protected BasicBidirectionalTopicOperation(String actor, String operation) {
super(actor, operation);
}
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
index ef9b37ba6..65ab0bbb3 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ package org.onap.policy.controlloop.actor.test;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import java.io.FileNotFoundException;
import org.junit.Test;
public class BasicActorTest extends BasicActor {
@@ -42,6 +43,8 @@ public class BasicActorTest extends BasicActor {
.isThrownBy(() -> verifyActorService(DummyActor.NAME, "serviceMissingActors.yaml"));
// config file not found
- assertThatThrownBy(() -> verifyActorService(DummyActor.NAME, "file-not-found.yaml"));
+ assertThatThrownBy(() -> verifyActorService(DummyActor.NAME, "file-not-found.yaml"))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasCauseInstanceOf(FileNotFoundException.class);
}
}
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
index 65c7318ff..2d6dc5802 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
* @param params operation parameters
* @param config configuration for this operation
*/
- public VfcOperation(ControlLoopOperationParams params, HttpConfig config) {
+ protected VfcOperation(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, VfcResponse.class, PROPERTY_NAMES);
setUsePolling();
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
index e02e59239..b0ad38eff 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
* @param clazz response class
* @param propertyNames names of properties required by this operation
*/
- public BidirectionalTopicOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
+ protected BidirectionalTopicOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
Class<S> clazz, List<String> propertyNames) {
super(params, config, propertyNames);
this.config = config;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
index c75ca1d4f..a4b48d432 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -93,7 +93,7 @@ public abstract class HttpOperation<T> extends OperationPartial {
* @param clazz response class
* @param propertyNames names of properties required by this operation
*/
- public HttpOperation(ControlLoopOperationParams params, HttpConfig config, Class<T> clazz,
+ protected HttpOperation(ControlLoopOperationParams params, HttpConfig config, Class<T> clazz,
List<String> propertyNames) {
super(params, config, propertyNames);
this.config = config;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
index 6874c5edd..7ad0cd82e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -118,7 +118,7 @@ public abstract class OperationPartial implements Operation {
* @param config configuration for this operation
* @param propertyNames names of properties required by this operation
*/
- public OperationPartial(ControlLoopOperationParams params, OperatorConfig config, List<String> propertyNames) {
+ protected OperationPartial(ControlLoopOperationParams params, OperatorConfig config, List<String> propertyNames) {
this.params = params;
this.config = config;
this.fullName = params.getActor() + "." + params.getOperation();
@@ -518,7 +518,7 @@ public abstract class OperationPartial implements Operation {
return futures[0];
}
- CompletableFuture.anyOf(futures).thenApply(outcome -> (OperationOutcome) outcome)
+ CompletableFuture.anyOf(futures).thenApply(OperationOutcome.class::cast)
.whenCompleteAsync(controller.delayedComplete(), params.getExecutor());
return controller;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
index 8007c24f9..e75e99eaa 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public abstract class OperatorPartial extends StartConfigPartial<Map<String, Obj
* @param actorName name of the actor with which this operator is associated
* @param name operation name
*/
- public OperatorPartial(String actorName, String name) {
+ protected OperatorPartial(String actorName, String name) {
super(actorName + "." + name);
this.actorName = actorName;
this.name = name;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
index 6c883f1b5..1cf611a61 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ public abstract class StartConfigPartial<T> implements Startable, Configurable<T
*
* @param fullName full name of this object, used for logging and exception purposes
*/
- public StartConfigPartial(String fullName) {
+ protected StartConfigPartial(String fullName) {
this.fullName = fullName;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
index 937776926..55bdab9ad 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ public abstract class TypedOperator<C, T extends Operation> extends OperatorPart
* @param name operation name
* @param operationMaker function to make an operation
*/
- public TypedOperator(String actorName, String name, OperationMaker<C, T> operationMaker) {
+ protected TypedOperator(String actorName, String name, OperationMaker<C, T> operationMaker) {
super(actorName, name);
this.operationMaker = operationMaker;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
index 605a7330c..6f667bb76 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -112,10 +112,10 @@ public class OperationOutcomeTest {
outcome.setOperation(OPERATION);
// null actor argument
- assertThatThrownBy(() -> outcome.isFor(null, OPERATION));
+ assertThatThrownBy(() -> outcome.isFor(null, OPERATION)).isInstanceOf(NullPointerException.class);
// null operation argument
- assertThatThrownBy(() -> outcome.isFor(ACTOR, null));
+ assertThatThrownBy(() -> outcome.isFor(ACTOR, null)).isInstanceOf(NullPointerException.class);
// true case
assertTrue(OperationOutcome.isFor(outcome, ACTOR, OPERATION));
@@ -126,7 +126,7 @@ public class OperationOutcomeTest {
outcome.setResult(OperationResult.FAILURE_EXCEPTION);
assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult());
- assertThatThrownBy(() -> outcome.setResult(null));
+ assertThatThrownBy(() -> outcome.setResult(null)).isInstanceOf(NullPointerException.class);
}
private void setAll() {
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
index 08d4adfd2..95799b7d2 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -166,7 +166,7 @@ public class BidirectionalTopicOperationTest {
assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals(response, outcome.getResponse());
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
/**
@@ -194,7 +194,7 @@ public class BidirectionalTopicOperationTest {
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(future.isCompletedExceptionally());
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
/**
@@ -210,7 +210,7 @@ public class BidirectionalTopicOperationTest {
verify(forwarder).register(eq(Arrays.asList(REQ_ID)), listenerCaptor.capture());
// must still unregister
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
@Test
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
index 54d56de53..7f2f6770e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -68,7 +67,7 @@ public class BidirectionalTopicHandlerTest {
MockitoAnnotations.initMocks(this);
when(mgr.getTopicSinks(MY_SINK)).thenReturn(Arrays.asList(publisher));
- when(mgr.getTopicSources(eq(Arrays.asList(MY_SOURCE)))).thenReturn(Arrays.asList(subscriber));
+ when(mgr.getTopicSources(Arrays.asList(MY_SOURCE))).thenReturn(Arrays.asList(subscriber));
when(publisher.getTopicCommInfrastructure()).thenReturn(CommInfrastructure.NOOP);
diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
index 30d4ed910..686e6a416 100644
--- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
+++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class CommonHeaderTest {
@@ -94,67 +95,28 @@ public class CommonHeaderTest {
assertEquals(commonHeader, clonedCommonHeader);
- commonHeader.setApiVer(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setApiVer(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setApiVer(KANSAS);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setApiVer(KANSAS);
- assertEquals(commonHeader, copiedCommonHeader);
+ checkField(KANSAS, CommonHeader::setApiVer);
+ checkField(flagSet, CommonHeader::setFlags);
+ checkField(DOROTHY, CommonHeader::setOriginatorId);
+ checkField(requestId, CommonHeader::setRequestId);
+ checkField(requestTrackSet, CommonHeader::setRequestTrack);
+ checkField(CAN_I_GO_HOME, CommonHeader::setSubRequestId);
+ checkField(timestamp, CommonHeader::setTimeStamp);
+ }
- commonHeader.setFlags(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setFlags(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setFlags(flagSet);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setFlags(flagSet);
- assertEquals(commonHeader, copiedCommonHeader);
+ private <T> void checkField(T value, BiConsumer<CommonHeader, T> setter) {
+ CommonHeader header1 = new CommonHeader();
+ CommonHeader header2 = new CommonHeader(header1);
- commonHeader.setOriginatorId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setOriginatorId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setOriginatorId(DOROTHY);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setOriginatorId(DOROTHY);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header2, null);
- commonHeader.setRequestId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setRequestId(requestId);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestId(requestId);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header1, value);
+ assertNotEquals(header1, header2);
- commonHeader.setRequestTrack(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestTrack(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setRequestTrack(requestTrackSet);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setRequestTrack(requestTrackSet);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header2, value);
+ assertEquals(header1, header2);
- commonHeader.setSubRequestId(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setSubRequestId(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertEquals(commonHeader, copiedCommonHeader);
-
- commonHeader.setTimeStamp(null);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setTimeStamp(null);
- assertEquals(commonHeader, copiedCommonHeader);
- commonHeader.setTimeStamp(timestamp);
- assertNotEquals(commonHeader, copiedCommonHeader);
- copiedCommonHeader.setTimeStamp(timestamp);
- assertEquals(commonHeader, copiedCommonHeader);
+ setter.accept(header1, null);
+ assertNotEquals(header1, header2);
}
}
diff --git a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
index 43686a747..5bff56b78 100644
--- a/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
+++ b/models-interactions/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class RequestTest {
@@ -77,49 +78,26 @@ public class RequestTest {
assertNotEquals(request, null);
assertNotEquals(request, (Object) "Hello");
- request.setCommonHeader(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setCommonHeader(null);
- assertEquals(request, copiedRequest);
- request.setCommonHeader(commonHeader);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setCommonHeader(commonHeader);
- assertEquals(request, copiedRequest);
+ checkField(commonHeader, Request::setCommonHeader);
+ checkField(GO_TO_OZ, Request::setAction);
+ checkField(WIZARD, Request::setObjectId);
+ checkField("Oz", Request::setTargetId);
+ checkField(payload, Request::setPayload);
+ }
- request.setAction(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setAction(null);
- assertEquals(request, copiedRequest);
- request.setAction(GO_TO_OZ);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setAction(GO_TO_OZ);
- assertEquals(request, copiedRequest);
+ private <T> void checkField(T value, BiConsumer<Request, T> setter) {
+ Request request1 = new Request();
+ Request request2 = new Request();
- request.setObjectId(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setObjectId(null);
- assertEquals(request, copiedRequest);
- request.setObjectId(WIZARD);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setObjectId(WIZARD);
- assertEquals(request, copiedRequest);
+ setter.accept(request2, null);
- request.setTargetId(null);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setTargetId(null);
- assertEquals(request, copiedRequest);
- request.setTargetId("Oz");
- assertNotEquals(request, copiedRequest);
- copiedRequest.setTargetId("Oz");
- assertEquals(request, copiedRequest);
+ setter.accept(request1, value);
+ assertNotEquals(request1, request2);
- request.setPayload(new HashMap<>());
- assertNotEquals(request, copiedRequest);
- copiedRequest.setPayload(new HashMap<>());
- assertEquals(request, copiedRequest);
- request.setPayload(payload);
- assertNotEquals(request, copiedRequest);
- copiedRequest.setPayload(payload);
- assertEquals(request, copiedRequest);
+ setter.accept(request2, value);
+ assertEquals(request1, request2);
+
+ setter.accept(request1, null);
+ assertNotEquals(request1, request2);
}
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
index 3106e3909..4f0dbf730 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,7 +54,7 @@ public abstract class ControlLoopEvent implements Serializable {
*
* @param event the existing instance
*/
- public ControlLoopEvent(ControlLoopEvent event) {
+ protected ControlLoopEvent(ControlLoopEvent event) {
if (event == null) {
return;
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
index c4c46d30a..890fb083a 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* controlloop
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -57,7 +57,7 @@ public abstract class ControlLoopNotification implements Serializable {
*
* @param event the event
*/
- public ControlLoopNotification(ControlLoopEvent event) {
+ protected ControlLoopNotification(ControlLoopEvent event) {
if (event == null) {
return;
}
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
index 21df853f4..e5a887429 100644
--- a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
+++ b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* rest
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -145,60 +145,39 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, null, null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, null, null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.delete(deleteUri, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, null, null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, null, null, null, PAYLOAD);
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
+
+ }
+
+ private void checkResult(Pair<Integer, String> result, String expectedText) {
assertEquals((Integer) 200, result.getLeft());
assertNotNull(result.getRight());
assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
-
+ assertEquals(expectedText, result.getRight());
}
@Test
@@ -206,53 +185,28 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, "", null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, "", null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, "", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, "", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, "", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
}
@@ -261,53 +215,28 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(getUri, "user", null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "GOT: " + EXPECT_STRING);
result = mgr.delete(deleteUri, "user", null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + EXPECT_STRING, result.getRight());
+ checkResult(result, "DELETE: " + EXPECT_STRING);
result = mgr.put(putUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + EXPECT_STRING);
result = mgr.put(putUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING);
result = mgr.post(postUri, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + EXPECT_STRING);
result = mgr.post(postUriBlank, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING);
result = mgr.patch(patchUri, "user", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + EXPECT_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + EXPECT_STRING);
result = mgr.patch(patchUriBlank, "user", null, null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING, result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING);
}
@@ -338,37 +267,21 @@ public class RestTest {
RestManager mgr = new RestManager();
Pair<Integer, String> result = mgr.get(baseUri + "RestTest/GetHello/" + NAME_PARAM, null, null, null);
-
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("GOT: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "GOT: " + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.delete(baseUri + "RestTest/DeleteHello/" + NAME_PARAM, null, null, null, null, null);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "DELETE: " + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.put(baseUri + "RestTest/PutHello/" + NAME_PARAM, null, null, null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "PUT: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.post(baseUri + "RestTest/PostHello/" + NAME_PARAM, null, null,
null, MediaType.TEXT_PLAIN, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "POST: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
result = mgr.patch(baseUri + "RestTest/PatchHello/" + NAME_PARAM, null, null,
null, PAYLOAD);
- assertEquals((Integer) 200, result.getLeft());
- assertNotNull(result.getRight());
- assertTrue(result.getRight().length() > 0);
- assertEquals("PATCH: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90", result.getRight());
+ checkResult(result, "PATCH: " + PAYLOAD + RETURN_STRING + NAME_PARAM + " aged 90");
}
diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java
index f4c0bf32d..9d497602f 100644
--- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java
+++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class PciCommonHeaderTest {
@@ -88,59 +89,27 @@ public class PciCommonHeaderTest {
assertEquals(commonHeader, clonedPciCommonHeader);
- commonHeader.setApiVer(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setApiVer(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setApiVer(KANSAS);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setApiVer(KANSAS);
- assertEquals(commonHeader, copiedPciCommonHeader);
-
- commonHeader.setFlags(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setFlags(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setFlags(flagMap);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setFlags(flagMap);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ checkField(KANSAS, PciCommonHeader::setApiVer);
+ checkField(flagMap, PciCommonHeader::setFlags);
+ checkField(requestMap, PciCommonHeader::setRequestTrack);
+ checkField(requestId, PciCommonHeader::setRequestId);
+ checkField(CAN_I_GO_HOME, PciCommonHeader::setSubRequestId);
+ checkField(timestamp, PciCommonHeader::setTimeStamp);
+ }
- commonHeader.setRequestTrack(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestTrack(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setRequestTrack(requestMap);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestTrack(requestMap);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ private <T> void checkField(T value, BiConsumer<PciCommonHeader, T> setter) {
+ PciCommonHeader details1 = new PciCommonHeader();
+ PciCommonHeader details2 = new PciCommonHeader(details1);
+ setter.accept(details2, null);
- commonHeader.setRequestId(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestId(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setRequestId(requestId);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setRequestId(requestId);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details1, value);
+ assertNotEquals(details1, details2);
- commonHeader.setSubRequestId(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setSubRequestId(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setSubRequestId(CAN_I_GO_HOME);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details2, value);
+ assertEquals(details1, details2);
- commonHeader.setTimeStamp(null);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setTimeStamp(null);
- assertEquals(commonHeader, copiedPciCommonHeader);
- commonHeader.setTimeStamp(timestamp);
- assertNotEquals(commonHeader, copiedPciCommonHeader);
- copiedPciCommonHeader.setTimeStamp(timestamp);
- assertEquals(commonHeader, copiedPciCommonHeader);
+ setter.accept(details1, null);
+ assertNotEquals(details1, details2);
}
}
diff --git a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java
index 914974691..91d42a3bf 100644
--- a/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java
+++ b/models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class PciWrapperTest {
@@ -73,49 +74,26 @@ public class PciWrapperTest {
assertNotEquals(wrapper, null);
assertNotEquals(wrapper, (Object) "Hello");
- wrapper.setVersion(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setVersion(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setVersion(VERSION_19);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setVersion(VERSION_19);
- assertEquals(wrapper, copiedPciWrapper);
+ checkField(VERSION_19, PciWrapper::setVersion);
+ checkField(THE_EMERALD_CITY, PciWrapper::setCambriaPartition);
+ checkField(TORNADO, PciWrapper::setRpcName);
+ checkField(YELLOW_BRICK_ROAD, PciWrapper::setCorrelationId);
+ checkField(MUNCHKIN, PciWrapper::setType);
+ }
- wrapper.setCambriaPartition(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCambriaPartition(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setCambriaPartition(THE_EMERALD_CITY);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCambriaPartition(THE_EMERALD_CITY);
- assertEquals(wrapper, copiedPciWrapper);
+ private <T> void checkField(T value, BiConsumer<PciWrapper, T> setter) {
+ PciWrapper details1 = new PciWrapper();
+ PciWrapper details2 = new PciWrapper();
- wrapper.setRpcName(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setRpcName(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setRpcName(TORNADO);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setRpcName(TORNADO);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details2, null);
- wrapper.setCorrelationId(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCorrelationId(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setCorrelationId(YELLOW_BRICK_ROAD);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setCorrelationId(YELLOW_BRICK_ROAD);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details1, value);
+ assertNotEquals(details1, details2);
- wrapper.setType(null);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setType(null);
- assertEquals(wrapper, copiedPciWrapper);
- wrapper.setType(MUNCHKIN);
- assertNotEquals(wrapper, copiedPciWrapper);
- copiedPciWrapper.setType(MUNCHKIN);
- assertEquals(wrapper, copiedPciWrapper);
+ setter.accept(details2, value);
+ assertEquals(details1, details2);
+
+ setter.accept(details1, null);
+ assertNotEquals(details1, details2);
}
}
diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java
index 43d5cd38a..66de1b2cd 100644
--- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java
+++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java
@@ -3,8 +3,7 @@
* so
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved
+ * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +29,7 @@ import static org.junit.Assert.assertNull;
import java.util.ArrayList;
import java.util.List;
+import java.util.function.BiConsumer;
import org.junit.Test;
public class SoRequestDetailsTest {
@@ -118,58 +118,27 @@ public class SoRequestDetailsTest {
assertNotEquals(details, null);
assertNotEquals(details, (Object) "Hello");
- details.setCloudConfiguration(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setCloudConfiguration(null);
- assertEquals(details, copiedDetails);
- details.setCloudConfiguration(cloudConfiguration);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setCloudConfiguration(cloudConfiguration);
- assertEquals(details, copiedDetails);
+ checkField(cloudConfiguration, SoRequestDetails::setCloudConfiguration);
+ checkField(modelInfo, SoRequestDetails::setModelInfo);
+ checkField(requestInfo, SoRequestDetails::setRequestInfo);
+ checkField(requestParameters, SoRequestDetails::setRequestParameters);
+ checkField(subscriberInfo, SoRequestDetails::setSubscriberInfo);
+ checkField(relatedInstanceList, SoRequestDetails::setRelatedInstanceList);
+ }
- details.setModelInfo(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setModelInfo(null);
- assertEquals(details, copiedDetails);
- details.setModelInfo(modelInfo);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setModelInfo(modelInfo);
- assertEquals(details, copiedDetails);
+ private <T> void checkField(T value, BiConsumer<SoRequestDetails, T> setter) {
+ SoRequestDetails details1 = new SoRequestDetails();
+ SoRequestDetails details2 = new SoRequestDetails(details1);
- details.setRequestInfo(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRequestInfo(null);
- assertEquals(details, copiedDetails);
- details.setRequestInfo(requestInfo);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRequestInfo(requestInfo);
- assertEquals(details, copiedDetails);
+ setter.accept(details2, null);
- details.setRequestParameters(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRequestParameters(null);
- assertEquals(details, copiedDetails);
- details.setRequestParameters(requestParameters);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRequestParameters(requestParameters);
- assertEquals(details, copiedDetails);
+ setter.accept(details1, value);
+ assertNotEquals(details1, details2);
- details.setSubscriberInfo(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setSubscriberInfo(null);
- assertEquals(details, copiedDetails);
- details.setSubscriberInfo(subscriberInfo);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setSubscriberInfo(subscriberInfo);
- assertEquals(details, copiedDetails);
+ setter.accept(details2, value);
+ assertEquals(details1, details2);
- details.setRelatedInstanceList(null);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRelatedInstanceList(null);
- assertEquals(details, copiedDetails);
- details.setRelatedInstanceList(relatedInstanceList);
- assertNotEquals(details, copiedDetails);
- copiedDetails.setRelatedInstanceList(relatedInstanceList);
- assertEquals(details, copiedDetails);
+ setter.accept(details1, null);
+ assertNotEquals(details1, details2);
}
}
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
index 596f9fa0d..4f574906a 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
@@ -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())
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilter.java
index ef0b6b183..d6f3a6815 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilter.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilter.java
@@ -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;
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilter.java
index b6ff86b3c..749873a23 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilter.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilter.java
@@ -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;
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java
index 4dfbae74d..f3dbeb030 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java
@@ -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);
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java
index 893cdbe84..2416bab69 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java
@@ -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;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java
index 9a07ea187..c28a1aefb 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java
@@ -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
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java
index 5ea21ed77..86be4b318 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java
@@ -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;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
index 0be04353f..11f1199c0 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
@@ -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;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java
index 594a5c348..0d9060d33 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java
@@ -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);
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java
index 86add360a..b00b14a9e 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java
@@ -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;