diff options
Diffstat (limited to 'models-interactions/model-actors/actor.guard/src/test')
5 files changed, 57 insertions, 17 deletions
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java index cd9f4e316..1c256090e 100644 --- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java +++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java @@ -32,6 +32,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.controlloop.actorserviceprovider.Util; +import org.onap.policy.controlloop.actorserviceprovider.parameters.CommonActorParams; public class GuardActorParamsTest { private static final String CONTAINER = "my-container"; @@ -68,13 +69,14 @@ public class GuardActorParamsTest { assertTrue(params.validate(CONTAINER).isValid()); // only a few fields are required - GuardActorParams sparse = Util.translate(CONTAINER, Map.of("operation", operations), GuardActorParams.class); + GuardActorParams sparse = Util.translate(CONTAINER, Map.of(CommonActorParams.OPERATIONS_FIELD, operations), + GuardActorParams.class); assertTrue(sparse.validate(CONTAINER).isValid()); assertEquals(GuardActorParams.DEFAULT_ACTION, sparse.getAction()); // check fields from superclass - testValidateField("operation", "null", params2 -> params2.setOperation(null)); + testValidateField(CommonActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null)); testValidateField("timeoutSec", "minimum", params2 -> params2.setTimeoutSec(-1)); } @@ -96,7 +98,7 @@ public class GuardActorParamsTest { GuardActorParams params2 = new GuardActorParams(); params2.setClientName(CLIENT); params2.setTimeoutSec(TIMEOUT); - params2.setOperation(operations); + params2.setOperations(operations); params2.setOnapName(ONAP_NAME); params2.setOnapComponent(ONAP_COMP); diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java index f4ab6061e..bb5d4ddf8 100644 --- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java +++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java @@ -25,8 +25,9 @@ import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.stream.Collectors; import org.junit.Test; +import org.onap.policy.controlloop.actor.test.BasicActor; -public class GuardActorServiceProviderTest { +public class GuardActorServiceProviderTest extends BasicActor { @Test public void test() { @@ -37,5 +38,8 @@ public class GuardActorServiceProviderTest { var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList()); assertEquals(expected.toString(), actual.toString()); + + // verify that it all plugs into the ActorService + verifyActorService(GuardActorServiceProvider.NAME, "service.yaml"); } } diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java index 406cdd05d..bd23a818b 100644 --- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java +++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java @@ -92,14 +92,16 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> { verifyPayload("makeReqStd.json", makePayload()); verifyPayload("makeReqDefault.json", new TreeMap<>()); - Map<String, String> payload = new TreeMap<>(); + Map<String, Object> payload = new TreeMap<>(); payload.put("action", "some action"); payload.put("hello", "world"); payload.put("r u there?", "yes"); payload.put("requestId", "some request id"); - payload.put("resource.abc", "def"); - payload.put("resource.ghi", "jkl"); - payload.put("some.other", "unused"); + + Map<String, Object> resource = new TreeMap<>(); + payload.put("resource", resource); + resource.put("abc", "def"); + resource.put("ghi", "jkl"); verifyPayload("makeReq.json", payload); @@ -109,7 +111,7 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> { assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest()); } - private void verifyPayload(String expectedJsonFile, Map<String, String> payload) throws CoderException { + private void verifyPayload(String expectedJsonFile, Map<String, Object> payload) throws CoderException { params.getPayload().clear(); params.getPayload().putAll(payload); @@ -150,7 +152,7 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> { } @Override - protected Map<String, String> makePayload() { + protected Map<String, Object> makePayload() { DecisionRequest req = new DecisionRequest(); req.setAction("my-action"); req.setOnapComponent("my-onap-component"); @@ -158,12 +160,14 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> { req.setOnapName("my-onap-name"); req.setRequestId("my-request-id"); - @SuppressWarnings("unchecked") - Map<String, String> map = Util.translate("", req, TreeMap.class); - // add resources - map.put(GuardOperation.RESOURCE_PREFIX + "actor", "resource-actor"); - map.put(GuardOperation.RESOURCE_PREFIX + "operation", "resource-operation"); + Map<String, Object> resource = new TreeMap<>(); + req.setResource(resource); + resource.put("actor", "resource-actor"); + resource.put("operation", "resource-operation"); + + @SuppressWarnings("unchecked") + Map<String, Object> map = Util.translate("", req, TreeMap.class); return map; } diff --git a/models-interactions/model-actors/actor.guard/src/test/resources/makeReqDefault.json b/models-interactions/model-actors/actor.guard/src/test/resources/makeReqDefault.json index 9e9df7b22..d757eb993 100644 --- a/models-interactions/model-actors/actor.guard/src/test/resources/makeReqDefault.json +++ b/models-interactions/model-actors/actor.guard/src/test/resources/makeReqDefault.json @@ -1,5 +1,4 @@ { "action": "guard", - "requestId": "abcdefghi", - "resource": {} + "requestId": "abcdefghi" } diff --git a/models-interactions/model-actors/actor.guard/src/test/resources/service.yaml b/models-interactions/model-actors/actor.guard/src/test/resources/service.yaml new file mode 100644 index 000000000..131cf785b --- /dev/null +++ b/models-interactions/model-actors/actor.guard/src/test/resources/service.yaml @@ -0,0 +1,31 @@ +# +# ============LICENSE_START====================================================== +# ONAP +# =============================================================================== +# Copyright (C) 2020 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END======================================================== +# +httpClients: +- clientName: my-client + hostname: localhost + port: 80 + basePath: base-url + managed: true +actors: + GUARD: + clientName: my-client + operations: + Decision: + path: decide
\ No newline at end of file |