diff options
author | Jim Hahn <jrh3@att.com> | 2020-04-16 12:34:52 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-04-16 13:00:06 -0400 |
commit | adc77015f156376316db0c3062a097544f33ce96 (patch) | |
tree | 2dcb3c02f63bda6034b04db8f2fdc925e716d17e | |
parent | 85841e358763f6d71a3b2ac27d3fd39dc60667c0 (diff) |
CDS actor was not registered
Moved the spi file to register the actor and added a test to
ensure that the registration worked.
Also removed some deprecated code from the CDS junits.
Issue-ID: POLICY-2501
Change-Id: I06f50ea8f074cdb7a89c7e387f9f31ea7cffa7e2
Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r-- | models-interactions/model-actors/actor.cds/pom.xml | 6 | ||||
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor (renamed from models-interactions/model-actors/actor.cds/src/main/resources/META-INF.services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor) | 0 | ||||
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceProviderTest.java | 22 | ||||
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java | 6 | ||||
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java | 10 | ||||
-rw-r--r-- | models-interactions/model-actors/actor.cds/src/test/resources/service.yaml | 27 |
6 files changed, 55 insertions, 16 deletions
diff --git a/models-interactions/model-actors/actor.cds/pom.xml b/models-interactions/model-actors/actor.cds/pom.xml index c67f46355..36d652760 100644 --- a/models-interactions/model-actors/actor.cds/pom.xml +++ b/models-interactions/model-actors/actor.cds/pom.xml @@ -70,6 +70,12 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId> + <artifactId>actor.test</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <scope>test</scope> diff --git a/models-interactions/model-actors/actor.cds/src/main/resources/META-INF.services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor b/models-interactions/model-actors/actor.cds/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor index e91d41989..e91d41989 100644 --- a/models-interactions/model-actors/actor.cds/src/main/resources/META-INF.services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor +++ b/models-interactions/model-actors/actor.cds/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor 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 f26034389..9c59e5648 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 @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Bell Canada. All rights reserved. * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications 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. @@ -23,8 +24,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyLong; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -32,19 +33,16 @@ 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; import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; - import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.MockitoAnnotations; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; @@ -58,10 +56,10 @@ import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actor.cds.CdsActorServiceProvider.CdsActorServiceManager; import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants; +import org.onap.policy.controlloop.actor.test.BasicActor; import org.onap.policy.controlloop.policy.Policy; -@RunWith(MockitoJUnitRunner.class) -public class CdsActorServiceProviderTest { +public class CdsActorServiceProviderTest extends BasicActor { private static final String CDS_BLUEPRINT_NAME = "vfw-cds"; private static final String CDS_BLUEPRINT_VERSION = "1.0.0"; @@ -83,6 +81,8 @@ public class CdsActorServiceProviderTest { */ @Before public void setup() { + MockitoAnnotations.initMocks(this); + // Setup policy policy = new Policy(); Map<String, String> payloadMap = new HashMap<String, String>() { @@ -129,6 +129,12 @@ public class CdsActorServiceProviderTest { } @Test + public void testActorService() { + // verify that it all plugs into the ActorService + verifyActorService(CdsActorConstants.CDS_ACTOR, "service.yaml"); + } + + @Test public void testConstructRequestWhenMissingCdsParamsInPolicyPayload() { policy.setPayload(new HashMap<>()); Optional<ExecutionServiceInput> cdsRequestOpt = cdsActor.constructRequest(onset, operation, policy, aaiParams); diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java index 187b69e60..83473a89a 100644 --- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java +++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications 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. @@ -29,15 +30,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.MockitoAnnotations; import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.policy.PolicyResult; -@RunWith(MockitoJUnitRunner.class) public class GrpcActorServiceManagerTest { CdsActorServiceManager manager; @@ -49,6 +48,7 @@ public class GrpcActorServiceManagerTest { */ @Before public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); future = new CompletableFuture<>(); manager = new CdsActorServiceManager(new OperationOutcome(), future); } diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java index 7baf8aaf7..5dca2909f 100644 --- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java +++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications 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. @@ -22,8 +23,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -39,9 +40,8 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.MockitoAnnotations; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; import org.onap.policy.aai.AaiCqResponse; import org.onap.policy.cds.client.CdsProcessorGrpcClient; @@ -55,7 +55,6 @@ import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopE import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.policy.PolicyResult; -@RunWith(MockitoJUnitRunner.class) public class GrpcOperationTest { private static final String CDS_BLUEPRINT_NAME = "vfw-cds"; @@ -74,6 +73,7 @@ public class GrpcOperationTest { */ @Before public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); // Setup the CDS properties cdsProps = new CdsServerProperties(); diff --git a/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml b/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml new file mode 100644 index 000000000..d48b4542f --- /dev/null +++ b/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml @@ -0,0 +1,27 @@ +# +# ============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======================================================== +# +actors: + CDS: + gRPC: + timeout: 10 + port: 6700 + host: my-host + username: my-user + password: my-pass |