diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-01-28 22:24:23 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-01-30 17:10:41 +0000 |
commit | d896f94cecc28b5a91cd423ba62ee096dc0fac60 (patch) | |
tree | 9ca95d120d45959d1913a3c5bf179b4e71b1f46c /controlloop/common/actors/actorserviceprovider/src | |
parent | e285764b0eddab0d4195128f55a9f524beee3f05 (diff) |
Fix technical debt/JUnit on actor service provider
Unit test for actor service provider added and technical debt removed.
Change-Id: I9573f1c3ff0252b166e06caaa88eb679a1fc7347
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Issue-ID: POLICY-455
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'controlloop/common/actors/actorserviceprovider/src')
3 files changed, 115 insertions, 0 deletions
diff --git a/controlloop/common/actors/actorserviceprovider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActor.java b/controlloop/common/actors/actorserviceprovider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActor.java new file mode 100644 index 000000000..5bf66bc21 --- /dev/null +++ b/controlloop/common/actors/actorserviceprovider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActor.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * TestActorServiceProvider + * ================================================================================ + * Copyright (C) 2018 Ericsson. 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========================================================= + */ + +package org.onap.policy.controlloop.actorserviceprovider; + +import java.util.ArrayList; +import java.util.List; + +import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; + +public class TestActor implements Actor { + @Override + public String actor() { + return this.getClass().getSimpleName(); + } + + @Override + public List<String> recipes() { + List<String> recipieList = new ArrayList<>(); + recipieList.add("Dorothy"); + recipieList.add("Wizard"); + + return recipieList; + } + + @Override + public List<String> recipeTargets(String recipe) { + List<String> recipieTargetList = new ArrayList<>(); + recipieTargetList.add("Wicked Witch"); + recipieTargetList.add("Wizard of Oz"); + + return recipieTargetList; + } + + @Override + public List<String> recipePayloads(String recipe) { + List<String> recipiePayloadList = new ArrayList<>(); + recipiePayloadList.add("Dorothy"); + recipiePayloadList.add("Toto"); + + return recipiePayloadList; + } +} diff --git a/controlloop/common/actors/actorserviceprovider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java b/controlloop/common/actors/actorserviceprovider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java new file mode 100644 index 000000000..14c2d8297 --- /dev/null +++ b/controlloop/common/actors/actorserviceprovider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * TestActorServiceProvider + * ================================================================================ + * Copyright (C) 2018 Ericsson. 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========================================================= + */ + +package org.onap.policy.controlloop.actorserviceprovider; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.onap.policy.controlloop.actorserviceprovider.ActorService; +import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; + +public class TestActorServiceProvider { + + @Test + public void testActorServiceProvider() { + ActorService actorService = ActorService.getInstance(); + assertNotNull(actorService); + + assertEquals(1, actorService.actors().size()); + + actorService = ActorService.getInstance(); + assertNotNull(actorService); + + Actor testActor = ActorService.getInstance().actors().get(0); + assertNotNull(testActor); + + assertEquals("TestActor", testActor.actor()); + + assertEquals(2, testActor.recipes().size()); + assertEquals("Dorothy", testActor.recipes().get(0)); + assertEquals("Wizard", testActor.recipes().get(1)); + + assertEquals(2, testActor.recipeTargets("Dorothy").size()); + assertEquals(2, testActor.recipePayloads("Dorothy").size()); + } +} diff --git a/controlloop/common/actors/actorserviceprovider/src/test/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor b/controlloop/common/actors/actorserviceprovider/src/test/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor new file mode 100644 index 000000000..a15871456 --- /dev/null +++ b/controlloop/common/actors/actorserviceprovider/src/test/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor @@ -0,0 +1 @@ +org.onap.policy.controlloop.actorserviceprovider.TestActor
\ No newline at end of file |