From dd41f2509cfd5538ece6446dd3b3f1ced85c9e5d Mon Sep 17 00:00:00 2001 From: Liam Fallon Date: Mon, 5 Feb 2018 12:02:05 +0000 Subject: Fix package directory naming to lower case In macOS (and windows) directory names are case insensitive, but in Linux they are case sensitive. Therefore, when the "actorServiceProvider" directory name was renamed to "actorserviceprovider", the change did not propogate into git when a Macbook was used for development. This error was discovered when working on a Ubuntu machine and is now fixed. Signed-off-by: liamfallon Issue-ID: POLICY-455 Change-Id: Ifebe3d37d42e79fff8da2370369967a25c371b11 Signed-off-by: liamfallon --- .../actorServiceProvider/ActorService.java | 61 ---------------------- .../actorServiceProvider/spi/Actor.java | 35 ------------- .../actorserviceprovider/ActorService.java | 61 ++++++++++++++++++++++ .../actorserviceprovider/spi/Actor.java | 35 +++++++++++++ .../actorserviceprovider/TestActor.java | 60 +++++++++++++++++++++ .../TestActorServiceProvider.java | 54 +++++++++++++++++++ ...licy.controlloop.actorserviceprovider.spi.Actor | 1 + 7 files changed, 211 insertions(+), 96 deletions(-) delete mode 100644 controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java delete mode 100644 controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/spi/Actor.java create mode 100644 controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java create mode 100644 controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java create mode 100644 controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActor.java create mode 100644 controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java create mode 100644 controlloop/common/actors/actorServiceProvider/src/test/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor (limited to 'controlloop/common/actors/actorServiceProvider/src') 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 deleted file mode 100644 index 45bb9f265..000000000 --- a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/ActorService.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ActorService - * ================================================================================ - * Copyright (C) 2017 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========================================================= - */ - -package org.onap.policy.controlloop.actorserviceprovider; - -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 loader; - - private ActorService() { - loader = ServiceLoader.load(Actor.class); - } - - public static synchronized ActorService getInstance() { - if (service == null) { - service = new ActorService(); - } - return service; - } - - public ImmutableList actors() { - Iterator 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 deleted file mode 100644 index b8e310d61..000000000 --- a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorServiceProvider/spi/Actor.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Actor - * ================================================================================ - * Copyright (C) 2017 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========================================================= - */ - -package org.onap.policy.controlloop.actorserviceprovider.spi; - -import java.util.List; - -public interface Actor { - - public String actor(); - - public List recipes(); - - public List recipeTargets(String recipe); - - public List recipePayloads(String recipe); - -} 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 new file mode 100644 index 000000000..45bb9f265 --- /dev/null +++ b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * ActorService + * ================================================================================ + * Copyright (C) 2017 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========================================================= + */ + +package org.onap.policy.controlloop.actorserviceprovider; + +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 loader; + + private ActorService() { + loader = ServiceLoader.load(Actor.class); + } + + public static synchronized ActorService getInstance() { + if (service == null) { + service = new ActorService(); + } + return service; + } + + public ImmutableList actors() { + Iterator 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 new file mode 100644 index 000000000..b8e310d61 --- /dev/null +++ b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Actor + * ================================================================================ + * Copyright (C) 2017 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========================================================= + */ + +package org.onap.policy.controlloop.actorserviceprovider.spi; + +import java.util.List; + +public interface Actor { + + public String actor(); + + public List recipes(); + + public List recipeTargets(String recipe); + + public List 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 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 recipes() { + List recipieList = new ArrayList<>(); + recipieList.add("Dorothy"); + recipieList.add("Wizard"); + + return recipieList; + } + + @Override + public List recipeTargets(String recipe) { + List recipieTargetList = new ArrayList<>(); + recipieTargetList.add("Wicked Witch"); + recipieTargetList.add("Wizard of Oz"); + + return recipieTargetList; + } + + @Override + public List recipePayloads(String recipe) { + List 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 -- cgit 1.2.3-korg