diff options
author | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-09-30 12:12:07 -0400 |
---|---|---|
committer | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-10-01 12:01:14 +0000 |
commit | 5af913104ec412086deab4d599359751246e4ba3 (patch) | |
tree | 436e10c0bb6e02aa354ffaf93714069309e2e611 /models-interactions/model-actors/actor.cds/src/test | |
parent | f70ddacbd97e34ad0d1373466367115982a251db (diff) |
Update CDS grpc request generation in CDS Actor service provider
- CDS payload requires resolution-key (random UUID)
- Update the CDS request object to rename the payload child node key name from config-deploy-properties to policy-payload.
- Generate dynamic childnode key name from the policy recipe-name aka CDS action-name. action-name itself is never included in serialization as is.
Below is a sample:
{
"commonHeader": {
"subRequestId": "$subReqId",
"requestId": "$reqId",
"originatorId": "POLICY"
},
"actionIdentifiers": {
"mode": "sync",
"blueprintName": "$bpName",
"blueprintVersion": "$bpVer",
"actionName": "$recipeName"
},
"payload": {
"$recipeName-request": {
"resolution-key": "{{$guid}}",
"aai-properties": {
"$key": "$value",
...
},
"policy-payload": {
"$clamp-payload"
}
}
}
}
Issue-ID: POLICY-2120
Signed-off-by: Rashmi Pujar <rashmi.pujar@bell.ca>
Change-Id: Ia7f0551f94755bbe73b48ae387b4c53842729a81
Diffstat (limited to 'models-interactions/model-actors/actor.cds/src/test')
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java index 65fd60239..0152521af 100644 --- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java +++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableMap; +import com.google.protobuf.Struct; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -63,6 +64,7 @@ public class CdsActorServiceProviderTest { private static final String CDS_BLUEPRINT_VERSION = "1.0.0"; private static final UUID REQUEST_ID = UUID.randomUUID(); private static final String SUBREQUEST_ID = "123456"; + private static final String CDS_RECIPE = "test-cds-recipe"; @Rule public ExpectedException exceptionRule = ExpectedException.none(); @@ -90,7 +92,7 @@ public class CdsActorServiceProviderTest { } }; policy.setPayload(payloadMap); - policy.setRecipe("CDS"); + policy.setRecipe(CDS_RECIPE); // Setup the CDS properties cdsProps = new CdsServerProperties(); @@ -124,7 +126,7 @@ public class CdsActorServiceProviderTest { } @Test - public void testConstructRequest() { + public void testConstructRequestWhenMissingCdsParamsInPolicyPayload() { policy.setPayload(new HashMap<>()); Optional<ExecutionServiceInput> cdsRequestOpt = cdsActor .constructRequest(onset, operation, policy, aaiParams); @@ -133,7 +135,7 @@ public class CdsActorServiceProviderTest { } @Test - public void testConstructRequestWhenMissingCdsParamsInPolicyPayload() { + public void testConstructRequest() { Optional<ExecutionServiceInput> cdsRequestOpt = cdsActor .constructRequest(onset, operation, policy, aaiParams); @@ -146,10 +148,12 @@ public class CdsActorServiceProviderTest { assertEquals(commonHeader.getSubRequestId(), SUBREQUEST_ID); assertTrue(cdsRequest.hasPayload()); + Struct cdsPayload = cdsRequest.getPayload(); + assertTrue(cdsPayload.containsFields(CDS_RECIPE + "-request")); assertTrue(cdsRequest.hasActionIdentifiers()); ActionIdentifiers actionIdentifiers = cdsRequest.getActionIdentifiers(); - assertEquals(actionIdentifiers.getActionName(), CdsActorConstants.CDS_ACTOR); + assertEquals(actionIdentifiers.getActionName(), CDS_RECIPE); assertEquals(actionIdentifiers.getBlueprintName(), CDS_BLUEPRINT_NAME); assertEquals(actionIdentifiers.getBlueprintVersion(), CDS_BLUEPRINT_VERSION); } |