From adc77015f156376316db0c3062a097544f33ce96 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Thu, 16 Apr 2020 12:34:52 -0400 Subject: 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 --- models-interactions/model-actors/actor.cds/pom.xml | 6 +++++ ...licy.controlloop.actorserviceprovider.spi.Actor | 1 - ...licy.controlloop.actorserviceprovider.spi.Actor | 1 + .../actor/cds/CdsActorServiceProviderTest.java | 22 +++++++++++------- .../actor/cds/GrpcActorServiceManagerTest.java | 6 ++--- .../controlloop/actor/cds/GrpcOperationTest.java | 10 ++++---- .../actor.cds/src/test/resources/service.yaml | 27 ++++++++++++++++++++++ 7 files changed, 56 insertions(+), 17 deletions(-) delete mode 100644 models-interactions/model-actors/actor.cds/src/main/resources/META-INF.services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor create mode 100644 models-interactions/model-actors/actor.cds/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor create mode 100644 models-interactions/model-actors/actor.cds/src/test/resources/service.yaml (limited to 'models-interactions') 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 @@ -69,6 +69,12 @@ ${project.version} provided + + org.onap.policy.models.policy-models-interactions.model-actors + actor.test + ${project.version} + test + org.mockito mockito-all 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 deleted file mode 100644 index e91d41989..000000000 --- a/models-interactions/model-actors/actor.cds/src/main/resources/META-INF.services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.controlloop.actor.cds.CdsActorServiceProvider 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 new file mode 100644 index 000000000..e91d41989 --- /dev/null +++ b/models-interactions/model-actors/actor.cds/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor @@ -0,0 +1 @@ +org.onap.policy.controlloop.actor.cds.CdsActorServiceProvider 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 payloadMap = new HashMap() { @@ -128,6 +128,12 @@ public class CdsActorServiceProviderTest { assertEquals(CdsActorConstants.CDS_ACTOR, cdsActor.actor()); } + @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<>()); 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 -- cgit 1.2.3-korg