summaryrefslogtreecommitdiffstats
path: root/controlloop/common/actors/actorServiceProvider
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-03-22 14:35:27 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-22 14:35:27 +0000
commit51619118d5148d10e9232d44b507a503c5b777e5 (patch)
tree52dfb8e570d79e79a52db0d61eb666fd276f319a /controlloop/common/actors/actorServiceProvider
parent9e4a0e9852f27e952c85272f0fdc4e2ae227a896 (diff)
parentaf861a9d8e28d49d357ead4a4acad82554510b6f (diff)
Merge "Removed checkstyle warnings"
Diffstat (limited to 'controlloop/common/actors/actorServiceProvider')
-rw-r--r--controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java71
-rw-r--r--controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java18
-rw-r--r--controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActor.java62
-rw-r--r--controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java47
4 files changed, 104 insertions, 94 deletions
diff --git a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
index 45bb9f265..b0b7eb566 100644
--- a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
+++ b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ActorService
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -20,42 +20,53 @@
package org.onap.policy.controlloop.actorserviceprovider;
+import com.google.common.collect.ImmutableList;
+
import java.util.Iterator;
import java.util.ServiceLoader;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableList;
public class ActorService {
- private static final Logger logger = LoggerFactory.getLogger(ActorService.class);
- private static ActorService service;
-
- // USed to load actors
- private ServiceLoader<Actor> loader;
-
- private ActorService() {
- loader = ServiceLoader.load(Actor.class);
- }
-
- public static synchronized ActorService getInstance() {
- if (service == null) {
- service = new ActorService();
- }
- return service;
- }
-
- public ImmutableList<Actor> actors() {
- Iterator<Actor> iter = loader.iterator();
- logger.debug("returning actors");
- while (iter.hasNext()) {
- if (logger.isDebugEnabled()) {
- logger.debug("Got {}", iter.next().actor());
- }
- }
-
- return ImmutableList.copyOf(loader.iterator());
- }
+ private static final Logger logger = LoggerFactory.getLogger(ActorService.class);
+ private static ActorService service;
+
+ // USed to load actors
+ private ServiceLoader<Actor> loader;
+
+ private ActorService() {
+ loader = ServiceLoader.load(Actor.class);
+ }
+
+ /**
+ * Get the single instance.
+ *
+ * @return the instance
+ */
+ public static synchronized ActorService getInstance() {
+ if (service == null) {
+ service = new ActorService();
+ }
+ return service;
+ }
+
+ /**
+ * Get the actors.
+ *
+ * @return the actors
+ */
+ public ImmutableList<Actor> actors() {
+ Iterator<Actor> iter = loader.iterator();
+ logger.debug("returning actors");
+ while (iter.hasNext()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Got {}", iter.next().actor());
+ }
+ }
+
+ return ImmutableList.copyOf(loader.iterator());
+ }
}
diff --git a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java
index b8e310d61..46cc6f643 100644
--- a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java
+++ b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Actor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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,13 +23,13 @@ package org.onap.policy.controlloop.actorserviceprovider.spi;
import java.util.List;
public interface Actor {
-
- public String actor();
-
- public List<String> recipes();
-
- public List<String> recipeTargets(String recipe);
-
- public List<String> recipePayloads(String recipe);
+
+ public String actor();
+
+ public List<String> recipes();
+
+ public List<String> recipeTargets(String recipe);
+
+ public List<String> recipePayloads(String recipe);
}
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
index 5bf66bc21..0fd00e12a 100644
--- 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
@@ -26,35 +26,35 @@ 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;
- }
+ @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
index 14c2d8297..1544e1ab4 100644
--- 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
@@ -24,31 +24,30 @@ 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());
- }
+
+ @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());
+ }
}