Flesh out junits for SDNR and VFC actors 25/108925/2
authorJim Hahn <jrh3@att.com>
Mon, 8 Jun 2020 14:49:39 +0000 (10:49 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 9 Jun 2020 13:06:47 +0000 (13:06 +0000)
Issue-ID: POLICY-2619
Change-Id: Ic0096a25dbcb40dc00f4b97cfafa57d162c7bdfd
Signed-off-by: Jim Hahn <jrh3@att.com>
models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java
models-interactions/model-actors/actor.sdnr/src/test/resources/service.yaml [new file with mode: 0644]
models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
models-interactions/model-actors/actor.vfc/src/test/resources/service.yaml [new file with mode: 0644]

index 12a1666..799872d 100644 (file)
@@ -26,14 +26,17 @@ import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
 import java.time.Instant;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.UUID;
+import java.util.stream.Collectors;
 import org.junit.Test;
 import org.onap.policy.controlloop.ControlLoopEventStatus;
 import org.onap.policy.controlloop.ControlLoopOperation;
 import org.onap.policy.controlloop.ControlLoopResponse;
 import org.onap.policy.controlloop.ControlLoopTargetType;
 import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.actor.test.BasicActor;
 import org.onap.policy.controlloop.actorserviceprovider.Operator;
 import org.onap.policy.controlloop.policy.Policy;
 import org.onap.policy.controlloop.policy.Target;
@@ -45,7 +48,7 @@ import org.onap.policy.sdnr.util.Serialization;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SdnrActorServiceProviderTest {
+public class SdnrActorServiceProviderTest extends BasicActor {
 
     private static final String MODIFY_CONFIG = "ModifyConfig";
 
@@ -94,6 +97,24 @@ public class SdnrActorServiceProviderTest {
 
     }
 
+    @Test
+    public void testConstructor() {
+        SdnrActorServiceProvider prov = new SdnrActorServiceProvider();
+        assertEquals(0, prov.getSequenceNumber());
+
+        // verify that it has the operators we expect
+        var expected = Arrays.asList(SdnrOperation.NAME).stream().sorted().collect(Collectors.toList());
+        var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList());
+
+        assertEquals(expected.toString(), actual.toString());
+    }
+
+    @Test
+    public void testActorService() {
+        // verify that it all plugs into the ActorService
+        verifyActorService(SdnrActorServiceProvider.NAME, "service.yaml");
+    }
+
     @Test
     public void testGetOperator() {
         SdnrActorServiceProvider sp = new SdnrActorServiceProvider();
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/resources/service.yaml b/models-interactions/model-actors/actor.sdnr/src/test/resources/service.yaml
new file mode 100644 (file)
index 0000000..f18e99c
--- /dev/null
@@ -0,0 +1,38 @@
+#
+# ============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========================================================
+#
+topics:
+  topicSources:
+  - topicCommInfrastructure: NOOP
+    topic: my-source
+    servers:
+    - localhost
+    managed: true
+  topicSinks:
+  - topicCommInfrastructure: NOOP
+    topic: my-sink
+    servers:
+    - localhost
+    managed: true
+actors:
+  SDNR:
+    sinkTopic: my-sink
+    sourceTopic: my-source
+    operations:
+      any: {}
index db224b0..9e05f22 100644 (file)
@@ -28,8 +28,10 @@ import static org.junit.Assert.assertNull;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
 import java.util.Objects;
 import java.util.UUID;
+import java.util.stream.Collectors;
 import org.apache.commons.io.IOUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -38,11 +40,12 @@ import org.onap.policy.aai.AaiCqResponse;
 import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
 import org.onap.policy.controlloop.ControlLoopOperation;
 import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.actor.test.BasicActor;
 import org.onap.policy.controlloop.policy.Policy;
 import org.onap.policy.simulators.Util;
 import org.onap.policy.vfc.VfcRequest;
 
-public class VfcActorServiceProviderTest {
+public class VfcActorServiceProviderTest extends BasicActor {
 
     private static final String DOROTHY_GALE_1939 = "dorothy.gale.1939";
     private static final String CQ_RESPONSE_JSON = "aai/AaiCqResponse.json";
@@ -62,6 +65,24 @@ public class VfcActorServiceProviderTest {
         HttpServletServerFactoryInstance.getServerFactory().destroy();
     }
 
+    @Test
+    public void testConstructor() {
+        VfcActorServiceProvider prov = new VfcActorServiceProvider();
+        assertEquals(0, prov.getSequenceNumber());
+
+        // verify that it has the operators we expect
+        var expected = Arrays.asList(Restart.NAME).stream().sorted().collect(Collectors.toList());
+        var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList());
+
+        assertEquals(expected.toString(), actual.toString());
+    }
+
+    @Test
+    public void testActorService() {
+        // verify that it all plugs into the ActorService
+        verifyActorService(VfcActorServiceProvider.NAME, "service.yaml");
+    }
+
     @Test
     public void testMethods() {
         VfcActorServiceProvider sp = new VfcActorServiceProvider();
diff --git a/models-interactions/model-actors/actor.vfc/src/test/resources/service.yaml b/models-interactions/model-actors/actor.vfc/src/test/resources/service.yaml
new file mode 100644 (file)
index 0000000..26192e0
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# ============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:
+  VFC:
+    Restart:
+        clientName: my-client
+        pathGet: jobs
+        maxGets: 20
+        waitSecGet: 20
+        path: ns
+        timeoutSec: 60