diff options
author | Jim Hahn <jrh3@att.com> | 2020-08-18 09:39:19 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-08-18 17:11:52 -0400 |
commit | 8722cb8a654ddcdcb472546a58809e041fe84eba (patch) | |
tree | eba3aee017377733f6a44840a58fc322f7e4f807 /models-interactions/model-actors/actor.appclcm/src | |
parent | ca3827f43ada2b160f6966d205ca97d4402a0935 (diff) |
Make targetEntity a property
The target entity is not always known when an Operation is first
constructed, thus it should be treated as an Operation property instead
of being included within the ControlLoopParams. Started the process of
moving it from the Params to the properties.
Also fixed a bug in custom query - it was setting the outcome response
to the String response instead of setting it to the AaiCqResponse
object.
Also added logging when an Operation's properties are set.
Issue-ID: POLICY-2746
Change-Id: I56c0cd90985f6140363548b0b8d031471b586e88
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.appclcm/src')
2 files changed, 8 insertions, 14 deletions
diff --git a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java index 590bf1968..dc74825f7 100644 --- a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java +++ b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java @@ -20,11 +20,9 @@ package org.onap.policy.controlloop.actor.appclcm; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; -import org.apache.commons.lang3.StringUtils; import org.onap.policy.appclcm.AppcLcmBody; import org.onap.policy.appclcm.AppcLcmCommonHeader; import org.onap.policy.appclcm.AppcLcmDmaapWrapper; @@ -34,6 +32,7 @@ import org.onap.policy.appclcm.AppcLcmResponseCode; import org.onap.policy.appclcm.AppcLcmResponseStatus; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; @@ -45,6 +44,8 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr private static final String MISSING_STATUS = "APPC-LCM response is missing the response status"; public static final String VNF_ID_KEY = "vnf-id"; + private static final List<String> PROPERTY_NAMES = List.of(OperationProperties.AAI_TARGET_ENTITY); + /** * Keys used to match the response with the request listener. The sub request ID is a * UUID, so it can be used to uniquely identify the response. @@ -62,11 +63,7 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr * @param config configuration for this operation */ public AppcLcmOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) { - super(params, config, AppcLcmDmaapWrapper.class, Collections.emptyList()); - - if (StringUtils.isBlank(params.getTargetEntity())) { - throw new IllegalArgumentException("missing targetEntity"); - } + super(params, config, AppcLcmDmaapWrapper.class, PROPERTY_NAMES); } /** @@ -97,7 +94,7 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr * Action Identifiers are required for APPC LCM requests. For R1, the recipes * supported by Policy only require a vnf-id. */ - inputRequest.setActionIdentifiers(Map.of(VNF_ID_KEY, params.getTargetEntity())); + inputRequest.setActionIdentifiers(Map.of(VNF_ID_KEY, getTargetEntity())); /* * For R1, the payloads will not be required for the Restart, Rebuild, or Migrate diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java index 705fd105f..f3b3cc2f3 100644 --- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java +++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java @@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -55,6 +56,7 @@ import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation.Status; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; @@ -135,16 +137,11 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL public void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(DEFAULT_OPERATION, oper.getName()); - - // missing target entity - params = params.toBuilder().targetEntity("").build(); - assertThatIllegalArgumentException().isThrownBy(() -> new AppcLcmOperation(params, config)) - .withMessage("missing targetEntity"); } @Test public void testGetPropertyNames() { - assertThat(oper.getPropertyNames()).isEmpty(); + assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_TARGET_ENTITY)); } @Test |