From 25e3f7a0d6cd5e364e4fd69eef310fcdb8a58b55 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 4 Sep 2020 11:03:24 +0100 Subject: Remove client code from apex-pdp Removal of the deployment and monitoring client from the apex-pdp as the functionality is replaced by the Policy Framework deployment using PAP and the Policy Framework monitoring GUI. Code in the engine proper that was used to administer apex-pdp over the Web Socket port is also removed, as this code was only used by the apex-pdp legacy GUIs. Issue-ID: POLICY-2621 Change-Id: Ib9fc4a667a4bc79377bb7b82fae6a2bd520a3e3d Signed-off-by: liamfallon --- .../deployment/ApexDeploymentExceptionTest.java | 45 --- .../apex/core/deployment/BatchDeployerTest.java | 160 -------- .../apex/core/deployment/DeploymentClientTest.java | 134 ------- .../core/deployment/DummyDeploymentClient.java | 220 ----------- .../core/deployment/EngineServiceFacadeTest.java | 141 ------- .../core/deployment/PeriodicEventManagerTest.java | 213 ----------- .../deployment/SupportMessageListenerTester.java | 42 --- .../src/test/resources/models/JunkModel.json | 2 - .../src/test/resources/models/SmallModel.json | 416 --------------------- 9 files changed, 1373 deletions(-) delete mode 100644 core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/ApexDeploymentExceptionTest.java delete mode 100644 core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java delete mode 100644 core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DeploymentClientTest.java delete mode 100644 core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java delete mode 100644 core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java delete mode 100644 core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/PeriodicEventManagerTest.java delete mode 100644 core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/SupportMessageListenerTester.java delete mode 100644 core/core-deployment/src/test/resources/models/JunkModel.json delete mode 100644 core/core-deployment/src/test/resources/models/SmallModel.json (limited to 'core/core-deployment/src/test') diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/ApexDeploymentExceptionTest.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/ApexDeploymentExceptionTest.java deleted file mode 100644 index 3a22fad12..000000000 --- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/ApexDeploymentExceptionTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.core.deployment; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; -import org.junit.Test; - -/** - * Test the Apex deployment Exception. - * - */ -public class ApexDeploymentExceptionTest { - - @Test - public void testDeploymentException() { - ApexDeploymentException ade0 = new ApexDeploymentException("a message"); - assertNotNull(ade0); - assertEquals("a message", ade0.getMessage()); - - ApexDeploymentException ade1 = new ApexDeploymentException("a message", new IOException()); - assertNotNull(ade1); - assertEquals("a message", ade0.getMessage()); - } -} diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java deleted file mode 100644 index 7e17cacdc..000000000 --- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.core.deployment; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.PrintStream; -import java.time.Duration; -import org.awaitility.Awaitility; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; -import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; - -/** - * Test the periodic event manager utility. - */ -public class BatchDeployerTest { - @Test - public void testBatchDeployerBad() { - final String[] eventArgs = { "-h" }; - - assertThatThrownBy(() -> BatchDeployer.main(eventArgs)) - .hasMessageContaining("invalid arguments: [-h]"); - } - - @Test - public void testBatchDeployerBadPort() { - final String[] eventArgs = { "localhost", "aport", "afile" }; - - assertThatThrownBy(() -> BatchDeployer.main(eventArgs)) - .hasMessage("argument port is invalid"); - } - - @Test - public void testBatchDeployerOk() { - final String[] eventArgs = { "Host", "43443", - "src/test/resources/models/SamplePolicyModelJAVASCRIPT.json" }; - - assertThatThrownBy(() -> BatchDeployer.main(eventArgs)) - .hasMessage("model deployment failed on parameters Host 43443"); - } - - @Test - public void testBatchDeployerDeployString() throws ApexException { - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - - BatchDeployer deployer = new BatchDeployer("localhost", 12345, new PrintStream(baosOut, true)); - final DummyDeploymentClient dummyDeploymentClient = new DummyDeploymentClient("aHost", 54553); - deployer.getEngineServiceFacade().setDeploymentClient(dummyDeploymentClient); - - // We are testing towards a dummy client, make it return a failed initiation - dummyDeploymentClient.setInitSuccessful(false); - assertThatThrownBy(deployer::init).hasMessage("model deployment failed on parameters localhost 12345"); - // Wait until the connection to the server closes following the bad connection - // attempt - Awaitility.await().atLeast(Duration.ofMillis(500)); - - // We are testing towards a dummy client, make it return a successful initiation - dummyDeploymentClient.setInitSuccessful(true); - deployer.init(); - - assertThatThrownBy(() -> deployer.deployModel("src/test/resources/models/SmallModel.json", false, false)) - .hasMessage("could not deploy apex model from src/test/resources/models/SmallModel.json"); - deployer.deployModel("src/test/resources/models/SmallModel.json", false, false); - - deployer.close(); - } - - @Test - public void testBatchDeployerStream() throws FileNotFoundException, ApexException { - - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - - BatchDeployer deployer = new BatchDeployer("localhost", 12345, new PrintStream(baosOut, true)); - final DummyDeploymentClient dummyDeploymentClient = new DummyDeploymentClient("aHost", 54553); - deployer.getEngineServiceFacade().setDeploymentClient(dummyDeploymentClient); - - dummyDeploymentClient.setInitSuccessful(false); - assertThatThrownBy(deployer::init) - .hasMessage("model deployment failed on parameters localhost 12345"); - // Wait until the connection to the server closes following the bad connection - // attempt - Awaitility.await().atLeast(Duration.ofMillis(500)); - - dummyDeploymentClient.setInitSuccessful(true); - - deployer.init(); - - final ApexModelReader modelReader = new ApexModelReader<>(AxPolicyModel.class); - modelReader.setValidateFlag(false); - final AxPolicyModel apexPolicyModel = modelReader - .read(new FileInputStream(new File("src/test/resources/models/SmallModel.json"))); - - assertThatThrownBy(() -> deployer.deployModel(apexPolicyModel, false, false)) - .hasMessage("failed response Operation failed received from serverlocalhost:12345"); - - deployer.deployModel(apexPolicyModel, false, false); - - deployer.close(); - } - - @Test - public void testBatchDeployerUninitialized() { - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - - BatchDeployer deployer = new BatchDeployer("localhost", 12345, new PrintStream(baosOut, true)); - deployer.getEngineServiceFacade().setDeploymentClient(new DummyDeploymentClient("aHost", 54553)); - - assertThatThrownBy(() -> deployer.deployModel("src/test/resources/models/SamplePolicyModelJAVASCRIPT.json", - false, false)) - .hasMessage("could not deploy apex model, deployer is not initialized"); - assertThatThrownBy(() -> deployer.deployModel("src/test/resources/models/SamplePolicyModelJAVASCRIPT.json", - false, false)) - .hasMessage("could not deploy apex model, deployer is not initialized"); - - deployer.close(); - } - - @Test - public void testBatchDeployerStreamUninitialized() throws ApexModelException, FileNotFoundException { - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - - BatchDeployer deployer = new BatchDeployer("localhost", 12345, new PrintStream(baosOut, true)); - deployer.getEngineServiceFacade().setDeploymentClient(new DummyDeploymentClient("aHost", 54553)); - - final ApexModelReader modelReader = new ApexModelReader<>(AxPolicyModel.class); - modelReader.setValidateFlag(false); - final AxPolicyModel apexPolicyModel = modelReader - .read(new FileInputStream(new File("src/test/resources/models/SmallModel.json"))); - - assertThatThrownBy(() -> deployer.deployModel(apexPolicyModel, false, false)) - .hasMessage("failed response Operation failed received from serverlocalhost:12345"); - deployer.close(); - } -} diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DeploymentClientTest.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DeploymentClientTest.java deleted file mode 100644 index 96b553a30..000000000 --- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DeploymentClientTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.core.deployment; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.awaitility.Awaitility.await; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyObject; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.policy.apex.core.infrastructure.messaging.MessageHolder; -import org.onap.policy.apex.core.infrastructure.messaging.MessageListener; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingService; -import org.onap.policy.apex.core.infrastructure.messaging.MessagingServiceFactory; -import org.onap.policy.apex.core.infrastructure.messaging.impl.ws.messageblock.MessageBlock; -import org.onap.policy.apex.core.protocols.Message; -import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus; -import org.onap.policy.apex.core.protocols.engdep.messages.Response; -import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; - -/** - * Test the deployment web socket client. - */ -@RunWith(MockitoJUnitRunner.class) -public class DeploymentClientTest { - @Mock - private static MessagingServiceFactory mockServiceFactory; - - @Mock - private static MessagingService mockService; - - @SuppressWarnings("rawtypes") - ArgumentCaptor messageListener = ArgumentCaptor.forClass(MessageListener.class); - - @SuppressWarnings("unchecked") - @Test - public void testDeploymentClientStart() throws Exception { - DeploymentClient deploymentClient = new DeploymentClient("localhost", 51332); - - final Field factoryField = deploymentClient.getClass().getDeclaredField("factory"); - factoryField.setAccessible(true); - factoryField.set(deploymentClient, mockServiceFactory); - - Mockito.doReturn(mockService).when(mockServiceFactory).createClient(anyObject()); - - Mockito.doNothing().when(mockService).addMessageListener(messageListener.capture()); - Mockito.doNothing().when(mockService).startConnection(); - - Mockito.doNothing().when(mockService).send((MessageHolder) anyObject()); - - Thread clientThread = new Thread(deploymentClient); - clientThread.start(); - - await().atMost(200, TimeUnit.MILLISECONDS).until(() -> deploymentClient.isStarted()); - - assertTrue(deploymentClient.isStarted()); - assertTrue(clientThread.isAlive()); - - AxArtifactKey engineKey = new AxArtifactKey("MyEngine", "0.0.1"); - GetEngineStatus getEngineStatus = new GetEngineStatus(engineKey); - deploymentClient.sendMessage(new GetEngineStatus(engineKey)); - - Response response = new Response(engineKey, true, getEngineStatus); - List messageList = new ArrayList<>(); - messageList.add(response); - - MessageBlock responseBlock = new MessageBlock<>(messageList, null); - messageListener.getValue().onMessage(responseBlock); - - assertThatThrownBy(() -> messageListener.getValue().onMessage("StringMessage")) - .hasMessage("String mesages are not supported on the EngDep protocol"); - - await().atMost(300, TimeUnit.MILLISECONDS).until(() -> deploymentClient.getMessagesReceived() == 2); - assertEquals(2, deploymentClient.getMessagesReceived()); - - deploymentClient.stopClient(); - } - - @Test - public void testDeploymentClientStartException() throws Exception { - DeploymentClient deploymentClient = new DeploymentClient("localhost", 51273); - - final Field factoryField = deploymentClient.getClass().getDeclaredField("factory"); - factoryField.setAccessible(true); - factoryField.set(deploymentClient, mockServiceFactory); - - Mockito.doReturn(mockService).when(mockServiceFactory).createClient(anyObject()); - - Mockito.doNothing().when(mockService).addMessageListener(anyObject()); - Mockito.doThrow(new ApexRuntimeException("connection start failed")).when(mockService).startConnection(); - - Thread clientThread = new Thread(deploymentClient); - clientThread.start(); - - await().atLeast(50, TimeUnit.MILLISECONDS).until(() -> !deploymentClient.isStarted()); - - assertFalse(deploymentClient.isStarted()); - assertFalse(clientThread.isAlive()); - assertEquals(0, deploymentClient.getReceiveQueue().size()); - - deploymentClient.stopClient(); - } -} diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java deleted file mode 100644 index 553380944..000000000 --- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. - * Modifications Copyright (C) 2020 Bell Canada. 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.core.deployment; - -import static org.awaitility.Awaitility.await; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import lombok.Getter; -import lombok.Setter; -import org.onap.policy.apex.core.protocols.Message; -import org.onap.policy.apex.core.protocols.engdep.messages.EngineServiceInfoResponse; -import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineInfo; -import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineServiceInfo; -import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus; -import org.onap.policy.apex.core.protocols.engdep.messages.Response; -import org.onap.policy.apex.core.protocols.engdep.messages.StartEngine; -import org.onap.policy.apex.core.protocols.engdep.messages.StartPeriodicEvents; -import org.onap.policy.apex.core.protocols.engdep.messages.StopEngine; -import org.onap.policy.apex.core.protocols.engdep.messages.StopPeriodicEvents; -import org.onap.policy.apex.core.protocols.engdep.messages.UpdateModel; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; -import org.onap.policy.common.utils.resources.TextFileUtils; - -/** - * Dummy deployment client. - */ -@Getter -@Setter -public class DummyDeploymentClient extends DeploymentClient implements Runnable { - private static final AxArtifactKey MODEL_KEY = new AxArtifactKey("Model", "0.0.1"); - private static final AxArtifactKey ENGINE_KEY = new AxArtifactKey("Engine", "0.0.1"); - private static final AxArtifactKey ENGINE_SERVICE_KEY = new AxArtifactKey("EngineService", "0.0.1"); - - private Thread thisThread; - - private final BlockingQueue receiveQueue = new LinkedBlockingQueue<>(); - - private boolean started = false; - - private boolean initSuccessful = false; - private boolean deployModelSuccessful = false; - private boolean startEngineSuccessful = false; - private boolean stopEngineSuccessful = false; - private boolean startPeriodicSuccessful = false; - private boolean stopPeriodicSuccessful = false; - private boolean statusSuccessful = false; - private boolean infoSuccessful = false; - - public DummyDeploymentClient(String host, int port) { - super(host, port); - } - - /** - * {@inheritDoc}. - */ - @Override - public void run() { - // Set up the thread name - thisThread = Thread.currentThread(); - thisThread.setName(DeploymentClient.class.getName() + "-" + getHost() + ":" + getPort()); - - started = true; - getCountDownLatch().get().countDown(); - // Loop forever, sending messages as they appear on the queue - await().atLeast(50, TimeUnit.MILLISECONDS).until(() -> !(started && !thisThread.isInterrupted())); - // Thread has been interrupted - thisThread = null; - started = false; - } - - /** - * Send an EngDep message to the Apex server. - * - * @param message the message to send to the Apex server - */ - @Override - public void sendMessage(final Message message) { - if (message instanceof GetEngineServiceInfo) { - handleEngineServiceInfo(message); - } else if (message instanceof UpdateModel) { - deployModelSuccessful = handleAndReturnMessage(message, deployModelSuccessful); - } else if (message instanceof StartEngine) { - startEngineSuccessful = handleAndReturnMessage(message, startEngineSuccessful); - } else if (message instanceof StopEngine) { - stopEngineSuccessful = handleAndReturnMessage(message, stopEngineSuccessful); - } else if (message instanceof StartPeriodicEvents) { - startPeriodicSuccessful = handleAndReturnMessage(message, startPeriodicSuccessful); - } else if (message instanceof StopPeriodicEvents) { - stopPeriodicSuccessful = handleAndReturnMessage(message, stopPeriodicSuccessful); - } else if (message instanceof GetEngineStatus) { - statusSuccessful = handleAndReturnEngineStatus(message, statusSuccessful); - } else if (message instanceof GetEngineInfo) { - infoSuccessful = handleAndReturnMessage(message, infoSuccessful); - } - } - - /** - * Handle the EngineServiceInfo message. - * - * @param message the EngineServiceInfo message - */ - private void handleEngineServiceInfo(final Message message) { - EngineServiceInfoResponse infoResponse = new EngineServiceInfoResponse(ENGINE_KEY, initSuccessful, message); - infoResponse.setApexModelKey(MODEL_KEY); - - List engineKeyList = new ArrayList<>(); - engineKeyList.add(ENGINE_KEY); - infoResponse.setEngineKeyArray(engineKeyList); - - infoResponse.setEngineServiceKey(ENGINE_SERVICE_KEY); - - receiveQueue.add(infoResponse); - } - - /** - * Handle and return the response to the engine status message. - * - * @param message the incoming status message - * @param successFlag true if the result should be successful - * @return engine status success or not - */ - private boolean handleAndReturnEngineStatus(Message message, boolean successFlag) { - if ("DoNotRespond".equals(message.getTarget().getName())) { - return !successFlag; - } - - if ("ReturnBadMessage".equals(message.getTarget().getName())) { - receiveQueue.add(message); - return !successFlag; - } - - if ("ReturnBadResponse".equals(message.getTarget().getName())) { - Response badResponse = new Response(ENGINE_KEY, successFlag, new StartEngine(message.getTarget())); - receiveQueue.add(badResponse); - return !successFlag; - } - - Response response = new Response(ENGINE_KEY, successFlag, message); - - if (successFlag) { - try { - response.setMessageData(TextFileUtils.getTextFileAsString("src/test/resources/models/SmallModel.json")); - } catch (IOException e) { - e.printStackTrace(); - } - } else { - response.setMessageData("Operation failed"); - } - - receiveQueue.add(response); - return !successFlag; - } - - /** - * Handle and return a message. - * - * @param message the message - */ - private boolean handleAndReturnMessage(final Message message, final boolean successFlag) { - Response response = new Response(ENGINE_KEY, successFlag, message); - - if (successFlag) { - response.setMessageData("Operation was successful"); - } else { - response.setMessageData("Operation failed"); - } - - receiveQueue.add(response); - return !successFlag; - } - - /** - * Stop the deployment client. - */ - @Override - public void stopClient() { - if (thisThread != null) { - thisThread.interrupt(); - } - started = false; - getCountDownLatch().set(new CountDownLatch(1)); - } - - /** - * Allows users of this class to get a reference to the receive queue to receove - * messages. - * - * @return the receive queue - */ - @Override - public BlockingQueue getReceiveQueue() { - return receiveQueue; - } -} diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java deleted file mode 100644 index 1740c7e55..000000000 --- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.core.deployment; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.time.Duration; -import org.awaitility.Awaitility; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; - -/** - * Test the deployment web socket client. - */ -public class EngineServiceFacadeTest { - @Test - public void testEngineServiceFacade() throws Exception { - EngineServiceFacade facade = new EngineServiceFacade("localhost", 51273); - - final DummyDeploymentClient dummyDeploymentClient = new DummyDeploymentClient("aHost", 54553); - facade.setDeploymentClient(dummyDeploymentClient); - - // First init should fail due to our dummy client - dummyDeploymentClient.setInitSuccessful(false); - assertThatThrownBy(facade::init) - .hasMessage("could not handshake with server localhost:51273"); - assertNull(facade.getKey()); - assertNull(facade.getApexModelKey()); - assertNull(facade.getEngineKeyArray()); - - assertThatThrownBy(() -> facade.deployModel("src/test/resources/models/SamplePolicyModelJAVASCRIPT.json", - false, false)) - .hasMessage("could not deploy apex model, deployer is not initialized"); - - // Second init should work - Awaitility.await().atLeast(Duration.ofMillis(1000)); - dummyDeploymentClient.setInitSuccessful(true); - facade.init(); - - assertEquals("EngineService:0.0.1", facade.getKey().getId()); - assertEquals("Model:0.0.1", facade.getApexModelKey().getId()); - assertEquals("Engine:0.0.1", facade.getEngineKeyArray()[0].getId()); - - assertThatThrownBy(() -> facade.deployModel("src/test/resources/models/NonExistantModel.json", - false, false)) - .hasMessage("could not create apex model, could not read from file " - + "src/test/resources/models/NonExistantModel.json"); - assertThatThrownBy(() -> facade.deployModel("src/test/resources/models/JunkModel.json", - false, false)) - .hasMessage("could not deploy apex model from src/test/resources/models/JunkModel.json"); - - InputStream badStream = new ByteArrayInputStream("".getBytes()); - assertThatThrownBy(() -> facade.deployModel("MyModel", badStream, false, false)) - .hasMessage("format of input for Apex concept is neither JSON nor XML"); - InputStream closedStream = new ByteArrayInputStream("".getBytes()); - closedStream.close(); - - assertThatThrownBy(() -> facade.deployModel("MyModel", closedStream, false, false)) - .hasMessage("format of input for Apex concept is neither JSON nor XML"); - assertThatThrownBy(() -> facade.deployModel("src/test/resources/models/SmallModel.json", false, false)) - .hasMessage("could not deploy apex model from src/test/resources/models/SmallModel.json"); - facade.deployModel("src/test/resources/models/SmallModel.json", false, false); - - assertThatThrownBy(() -> facade.startEngine(facade.getEngineKeyArray()[0])) - .hasMessage("failed response Operation failed received from serverlocalhost:51273"); - facade.startEngine(facade.getEngineKeyArray()[0]); - - assertThatThrownBy(() -> facade.stopEngine(facade.getEngineKeyArray()[0])) - .hasMessage("failed response Operation failed received from serverlocalhost:51273"); - facade.stopEngine(facade.getEngineKeyArray()[0]); - - assertThatThrownBy(() -> facade.startPerioidicEvents(facade.getEngineKeyArray()[0], 1000)) - .hasMessage("failed response Operation failed received from serverlocalhost:51273"); - facade.startPerioidicEvents(facade.getEngineKeyArray()[0], 1000); - - assertThatThrownBy(() -> facade.stopPerioidicEvents(facade.getEngineKeyArray()[0])) - .hasMessage("failed response Operation failed received from serverlocalhost:51273"); - facade.stopPerioidicEvents(facade.getEngineKeyArray()[0]); - - assertThatThrownBy(() -> facade.getEngineStatus(facade.getEngineKeyArray()[0])) - .hasMessage("failed response Operation failed received from serverlocalhost:51273"); - facade.getEngineStatus(facade.getEngineKeyArray()[0]); - - assertThatThrownBy(() -> facade.getEngineInfo(facade.getEngineKeyArray()[0])) - .hasMessage("failed response Operation failed received from serverlocalhost:51273"); - facade.getEngineInfo(facade.getEngineKeyArray()[0]); - - assertThatThrownBy(() -> facade.getEngineStatus(new AxArtifactKey("ReturnBadMessage", "0.0.1"))) - .hasMessage("response received from server is of incorrect type " - + "org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus, should be of type " - + "org.onap.policy.apex.core.protocols.engdep.messages.Response"); - assertThatThrownBy(() -> facade.getEngineStatus(new AxArtifactKey("ReturnBadResponse", "0.0.1"))) - .hasMessage("response received is not correct response to sent message GET_ENGINE_STATUS"); - assertThatThrownBy(() -> facade.getEngineStatus(new AxArtifactKey("DoNotRespond", "0.0.1"))) - .hasMessage("no response received to sent message GET_ENGINE_STATUS"); - assertThatThrownBy(() -> facade.stopPerioidicEvents(facade.getEngineKeyArray()[0])) - .hasMessage("failed response Operation failed received from serverlocalhost:51273"); - - facade.stopPerioidicEvents(facade.getEngineKeyArray()[0]); - - facade.getEngineStatus(facade.getEngineKeyArray()[0]); - - assertThatThrownBy(() -> facade.getEngineInfo(facade.getEngineKeyArray()[0])) - .hasMessage("failed response Operation failed received from serverlocalhost:51273"); - - facade.getEngineInfo(facade.getEngineKeyArray()[0]); - - assertThatThrownBy(() -> facade.getEngineStatus(new AxArtifactKey("ReturnBadMessage", "0.0.1"))) - .hasMessage("response received from server is of incorrect type " - + "org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus, should be of type " - + "org.onap.policy.apex.core.protocols.engdep.messages.Response"); - assertThatThrownBy(() -> facade.getEngineStatus(new AxArtifactKey("ReturnBadResponse", "0.0.1"))) - .hasMessage("response received is not correct response to sent message GET_ENGINE_STATUS"); - assertThatThrownBy(() -> facade.getEngineStatus(new AxArtifactKey("DoNotRespond", "0.0.1"))) - .hasMessage("no response received to sent message GET_ENGINE_STATUS"); - facade.close(); - } -} diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/PeriodicEventManagerTest.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/PeriodicEventManagerTest.java deleted file mode 100644 index 99c95465f..000000000 --- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/PeriodicEventManagerTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.core.deployment; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.PrintStream; -import org.junit.Test; - -/** - * Test the periodic event manager utility. - */ -public class PeriodicEventManagerTest { - @Test - public void testPeroidicEventManagerBad() { - final String[] eventArgs = { "-h" }; - - assertThatThrownBy(() -> PeriodicEventManager.main(eventArgs)) - .hasMessageContaining("invalid arguments: [-h]"); - } - - @Test - public void testPeroidicEventManagerOk() { - final String[] eventArgs = { "Host", "43443", "start", "1000" }; - - assertThatThrownBy(() -> PeriodicEventManager.main(eventArgs)) - .hasMessage("periodic event setting failed on parameters Host 43443 true"); - } - - @Test - public void testPeroidicEventManagerNoOptions() { - final String[] eventArgs = new String[] {}; - - final String outputString = testPeriodicEventManagerConstructor(eventArgs); - - assertTrue(outputString - .contains("usage: PeriodicEventManager ")); - } - - @Test - public void testPeroidicEventManagerBadOptions() { - final String[] eventArgs = { "-zabbu" }; - - final String outputString = testPeriodicEventManagerConstructor(eventArgs); - - assertTrue(outputString - .contains("usage: PeriodicEventManager ")); - } - - @Test - public void testPeroidicEventManagerNonNumeric3() { - final String[] eventArgs = { "aaa", "bbb", "ccc", "ddd" }; - - final String outputString = testPeriodicEventManagerConstructor(eventArgs); - - assertTrue(outputString.contains("argument port is invalid")); - } - - @Test - public void testPeroidicEventManagerNonNumeric2() { - final String[] eventArgs = { "aaa", "12345", "start", "stop" }; - - final String outputString = testPeriodicEventManagerConstructor(eventArgs); - - assertTrue(outputString.contains("argument period is invalid")); - } - - @Test - public void testPeroidicEventManagerNotStartStop() { - final String[] eventArgs = { "aaa", "12345", "1000", "1000" }; - - final String outputString = testPeriodicEventManagerConstructor(eventArgs); - - assertTrue(outputString.contains("argument 1000 must be \"start\" or \"stop\"")); - } - - @Test - public void testPeroidicEventManagerStart() throws ApexDeploymentException { - final String[] eventArgs = { "localhost", "12345", "start", "1000" }; - - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - - PeriodicEventManager peManager = null; - final DummyDeploymentClient dummyDeploymentClient = new DummyDeploymentClient("aHost", 54553); - peManager = new PeriodicEventManager(eventArgs, new PrintStream(baosOut, true)); - peManager.getEngineServiceFacade().setDeploymentClient(dummyDeploymentClient); - - dummyDeploymentClient.setInitSuccessful(false); - assertThatThrownBy(peManager::init) - .hasMessage("periodic event setting failed on parameters localhost 12345 true"); - dummyDeploymentClient.setInitSuccessful(true); - peManager.init(); - - assertThatThrownBy(peManager::runCommand) - .hasMessage("failed response Operation failed received from serverlocalhost:12345"); - - peManager.close(); - } - - @Test - public void testPeroidicEventManagerStop() throws ApexDeploymentException { - - final String[] eventArgs = { "localhost", "12345", "stop", "1000" }; - - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - - PeriodicEventManager peManager = null; - final DummyDeploymentClient dummyDeploymentClient = new DummyDeploymentClient("aHost", 54553); - peManager = new PeriodicEventManager(eventArgs, new PrintStream(baosOut, true)); - peManager.getEngineServiceFacade().setDeploymentClient(dummyDeploymentClient); - - dummyDeploymentClient.setInitSuccessful(false); - assertThatThrownBy(peManager::init) - .hasMessage("periodic event setting failed on parameters localhost 12345 false"); - dummyDeploymentClient.setInitSuccessful(true); - peManager.init(); - - assertThatThrownBy(peManager::runCommand) - .hasMessage("failed response Operation failed received from serverlocalhost:12345"); - peManager.runCommand(); - - peManager.close(); - } - - @Test - public void testPeroidicEventManagerStartUninitialized() throws ApexDeploymentException { - - final String[] eventArgs = { "localhost", "12345", "start", "1000" }; - - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - - PeriodicEventManager peManager = null; - final DummyDeploymentClient dummyDeploymentClient = new DummyDeploymentClient("aHost", 54553); - peManager = new PeriodicEventManager(eventArgs, new PrintStream(baosOut, true)); - peManager.getEngineServiceFacade().setDeploymentClient(dummyDeploymentClient); - - dummyDeploymentClient.setInitSuccessful(false); - assertThatThrownBy(peManager::runCommand) - .hasMessage("connection to apex is not initialized"); - dummyDeploymentClient.setInitSuccessful(true); - assertThatThrownBy(peManager::runCommand) - .hasMessage("connection to apex is not initialized"); - - peManager.close(); - } - - @Test - public void testPeroidicEventManagerStopUninitialized() throws ApexDeploymentException { - - final String[] eventArgs = { "localhost", "12345", "stop", "1000" }; - - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - - PeriodicEventManager peManager = null; - peManager = new PeriodicEventManager(eventArgs, new PrintStream(baosOut, true)); - peManager.getEngineServiceFacade().setDeploymentClient(new DummyDeploymentClient("aHost", 54553)); - - assertThatThrownBy(peManager::runCommand) - .hasMessage("connection to apex is not initialized"); - peManager.close(); - } - - /** - * Run the application. - * - * @param eventArgs the command arguments - * @return a string containing the command output - */ - private String testPeriodicEventManagerConstructor(final String[] eventArgs) { - final ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); - final ByteArrayOutputStream baosErr = new ByteArrayOutputStream(); - - String exceptionString = ""; - try { - PeriodicEventManager peManager = new PeriodicEventManager(eventArgs, new PrintStream(baosOut, true)); - peManager.getEngineServiceFacade().setDeploymentClient(new DummyDeploymentClient("aHost", 54553)); - } catch (ApexDeploymentException ade) { - exceptionString = ade.getCascadedMessage(); - } - - InputStream testInput = new ByteArrayInputStream("Test Data for Input to WS".getBytes()); - System.setIn(testInput); - - String outString = baosOut.toString(); - String errString = baosErr.toString(); - - return "*** StdOut ***\n" + outString + "\n*** StdErr ***\n" + errString + "\n*** exception ***\n" - + exceptionString; - } -} diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/SupportMessageListenerTester.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/SupportMessageListenerTester.java deleted file mode 100644 index 3ee6a4b51..000000000 --- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/SupportMessageListenerTester.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.core.deployment; - -import static org.junit.Assert.fail; - -import org.onap.policy.apex.core.infrastructure.messaging.MessageListener; -import org.onap.policy.apex.core.infrastructure.messaging.impl.ws.messageblock.MessageBlock; -import org.onap.policy.apex.core.protocols.Message; - -/** - * A test message listener. - */ -public class SupportMessageListenerTester implements MessageListener { - @Override - public void onMessage(String messageString) { - fail("Message should not be received"); - } - - @Override - public void onMessage(MessageBlock data) { - fail("Message should not be received"); - } -} diff --git a/core/core-deployment/src/test/resources/models/JunkModel.json b/core/core-deployment/src/test/resources/models/JunkModel.json deleted file mode 100644 index 7a73a41bf..000000000 --- a/core/core-deployment/src/test/resources/models/JunkModel.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/core/core-deployment/src/test/resources/models/SmallModel.json b/core/core-deployment/src/test/resources/models/SmallModel.json deleted file mode 100644 index 5c0628809..000000000 --- a/core/core-deployment/src/test/resources/models/SmallModel.json +++ /dev/null @@ -1,416 +0,0 @@ -{ - "apexPolicyModel" : { - "key" : { - "name" : "SmallModel", - "version" : "0.0.1" - }, - "keyInformation" : { - "key" : { - "name" : "SmallModel_KeyInfo", - "version" : "0.0.1" - }, - "keyInfoMap" : { - "entry" : [ { - "key" : { - "name" : "BasicContextAlbum", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "BasicContextAlbum", - "version" : "0.0.1" - }, - "UUID" : "fec1b353-b35f-4384-b7d9-69622059c248", - "description" : "Generated description for a concept called \"BasicContextAlbum\" with version \"0.0.1\" and UUID \"fec1b353-b35f-4384-b7d9-69622059c248\"" - } - }, { - "key" : { - "name" : "BasicEvent", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "BasicEvent", - "version" : "0.0.1" - }, - "UUID" : "cc8d3c1a-e975-459a-bcd2-69f423eaa1f3", - "description" : "Generated description for a concept called \"BasicEvent\" with version \"0.0.1\" and UUID \"cc8d3c1a-e975-459a-bcd2-69f423eaa1f3\"" - } - }, { - "key" : { - "name" : "BasicPolicy", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "BasicPolicy", - "version" : "0.0.1" - }, - "UUID" : "d0c5d8ee-5fe7-4978-89ce-4a3e69cad043", - "description" : "Generated description for a concept called \"BasicPolicy\" with version \"0.0.1\" and UUID \"d0c5d8ee-5fe7-4978-89ce-4a3e69cad043\"" - } - }, { - "key" : { - "name" : "BasicTask", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "BasicTask", - "version" : "0.0.1" - }, - "UUID" : "c5651414-fc1c-493b-878d-75f0ce685c36", - "description" : "Generated description for a concept called \"BasicTask\" with version \"0.0.1\" and UUID \"c5651414-fc1c-493b-878d-75f0ce685c36\"" - } - }, { - "key" : { - "name" : "IntType", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "IntType", - "version" : "0.0.1" - }, - "UUID" : "790ff718-8dc0-44e0-89d8-1b3bbe238310", - "description" : "Generated description for a concept called \"IntType\" with version \"0.0.1\" and UUID \"790ff718-8dc0-44e0-89d8-1b3bbe238310\"" - } - }, { - "key" : { - "name" : "SmallModel", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "SmallModel", - "version" : "0.0.1" - }, - "UUID" : "a1bd1f4e-713b-456b-b1a8-bb48beee28e8", - "description" : "Generated description for a concept called \"SmallModel\" with version \"0.0.1\" and UUID \"a1bd1f4e-713b-456b-b1a8-bb48beee28e8\"" - } - }, { - "key" : { - "name" : "SmallModel_Albums", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "SmallModel_Albums", - "version" : "0.0.1" - }, - "UUID" : "72bed9af-ab7d-3379-b9f7-b5eca5c9ef22", - "description" : "Generated description for concept referred to by key \"SmallModel_Albums:0.0.1\"" - } - }, { - "key" : { - "name" : "SmallModel_Events", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "SmallModel_Events", - "version" : "0.0.1" - }, - "UUID" : "796dc6b0-627d-34ae-a5e2-1bc4b4b486b8", - "description" : "Generated description for concept referred to by key \"SmallModel_Events:0.0.1\"" - } - }, { - "key" : { - "name" : "SmallModel_KeyInfo", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "SmallModel_KeyInfo", - "version" : "0.0.1" - }, - "UUID" : "b4876774-6907-3d27-a2b8-f05737c5ee4a", - "description" : "Generated description for concept referred to by key \"SmallModel_KeyInfo:0.0.1\"" - } - }, { - "key" : { - "name" : "SmallModel_Policies", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "SmallModel_Policies", - "version" : "0.0.1" - }, - "UUID" : "5bcf946b-67be-3190-a906-f954896f999f", - "description" : "Generated description for concept referred to by key \"SmallModel_Policies:0.0.1\"" - } - }, { - "key" : { - "name" : "SmallModel_Schemas", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "SmallModel_Schemas", - "version" : "0.0.1" - }, - "UUID" : "c25bf5c3-7f1e-3667-b8a9-971ba21517bc", - "description" : "Generated description for concept referred to by key \"SmallModel_Schemas:0.0.1\"" - } - }, { - "key" : { - "name" : "SmallModel_Tasks", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "SmallModel_Tasks", - "version" : "0.0.1" - }, - "UUID" : "43b015ca-2ed1-3a35-b103-e8a5aa68f1ef", - "description" : "Generated description for concept referred to by key \"SmallModel_Tasks:0.0.1\"" - } - } ] - } - }, - "policies" : { - "key" : { - "name" : "SmallModel_Policies", - "version" : "0.0.1" - }, - "policyMap" : { - "entry" : [ { - "key" : { - "name" : "BasicPolicy", - "version" : "0.0.1" - }, - "value" : { - "policyKey" : { - "name" : "BasicPolicy", - "version" : "0.0.1" - }, - "template" : "FREEFORM", - "state" : { - "entry" : [ { - "key" : "OnlyState", - "value" : { - "stateKey" : { - "parentKeyName" : "BasicPolicy", - "parentKeyVersion" : "0.0.1", - "parentLocalName" : "NULL", - "localName" : "OnlyState" - }, - "trigger" : { - "name" : "BasicEvent", - "version" : "0.0.1" - }, - "stateOutputs" : { - "entry" : [ { - "key" : "OnlyOutput", - "value" : { - "key" : { - "parentKeyName" : "BasicPolicy", - "parentKeyVersion" : "0.0.1", - "parentLocalName" : "OnlyState", - "localName" : "OnlyOutput" - }, - "outgoingEvent" : { - "name" : "BasicEvent", - "version" : "0.0.1" - }, - "nextState" : { - "parentKeyName" : "NULL", - "parentKeyVersion" : "0.0.0", - "parentLocalName" : "NULL", - "localName" : "NULL" - } - } - } ] - }, - "contextAlbumReference" : [ { - "name" : "BasicContextAlbum", - "version" : "0.0.1" - } ], - "taskSelectionLogic" : { - "key" : "NULL", - "logicFlavour" : "UNDEFINED", - "logic" : "" - }, - "stateFinalizerLogicMap" : { - "entry" : [ ] - }, - "defaultTask" : { - "name" : "BasicTask", - "version" : "0.0.1" - }, - "taskReferences" : { - "entry" : [ { - "key" : { - "name" : "BasicTask", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "parentKeyName" : "BasicPolicy", - "parentKeyVersion" : "0.0.1", - "parentLocalName" : "OnlyState", - "localName" : "BasicTask" - }, - "outputType" : "DIRECT", - "output" : { - "parentKeyName" : "BasicPolicy", - "parentKeyVersion" : "0.0.1", - "parentLocalName" : "OnlyState", - "localName" : "OnlyOutput" - } - } - } ] - } - } - } ] - }, - "firstState" : "OnlyState" - } - } ] - } - }, - "tasks" : { - "key" : { - "name" : "SmallModel_Tasks", - "version" : "0.0.1" - }, - "taskMap" : { - "entry" : [ { - "key" : { - "name" : "BasicTask", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "BasicTask", - "version" : "0.0.1" - }, - "inputFields" : { - "entry" : [ { - "key" : "intPar", - "value" : { - "key" : "intPar", - "fieldSchemaKey" : { - "name" : "IntType", - "version" : "0.0.1" - }, - "optional" : false - } - } ] - }, - "outputFields" : { - "entry" : [ { - "key" : "intPar", - "value" : { - "key" : "intPar", - "fieldSchemaKey" : { - "name" : "IntType", - "version" : "0.0.1" - }, - "optional" : false - } - } ] - }, - "taskParameters" : { - "entry" : [ ] - }, - "contextAlbumReference" : [ { - "name" : "BasicContextAlbum", - "version" : "0.0.1" - } ], - "taskLogic" : { - "key" : "TaskLogic", - "logicFlavour" : "JAVASCRIPT", - "logic" : "executor.logger.debug(executor.subject.id);\nvar gc = executor.getContextAlbum(\"BasicContextAlbum\");\nexecutor.logger.debug(gc.name);\nexecutor.logger.debug(executor.inFields);\n\nexecutor.logger.debug(executor.eo);\n\nvar returnValue = executor.isTrue;" - } - } - } ] - } - }, - "events" : { - "key" : { - "name" : "SmallModel_Events", - "version" : "0.0.1" - }, - "eventMap" : { - "entry" : [ { - "key" : { - "name" : "BasicEvent", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "BasicEvent", - "version" : "0.0.1" - }, - "nameSpace" : "org.onap.policy.apex.events", - "source" : "source", - "target" : "target", - "parameter" : { - "entry" : [ { - "key" : "intPar", - "value" : { - "key" : "intPar", - "fieldSchemaKey" : { - "name" : "IntType", - "version" : "0.0.1" - }, - "optional" : false - } - } ] - } - } - } ] - } - }, - "albums" : { - "key" : { - "name" : "SmallModel_Albums", - "version" : "0.0.1" - }, - "albums" : { - "entry" : [ { - "key" : { - "name" : "BasicContextAlbum", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "BasicContextAlbum", - "version" : "0.0.1" - }, - "scope" : "GLOBAL", - "isWritable" : true, - "itemSchema" : { - "name" : "IntType", - "version" : "0.0.1" - } - } - } ] - } - }, - "schemas" : { - "key" : { - "name" : "SmallModel_Schemas", - "version" : "0.0.1" - }, - "schemas" : { - "entry" : [ { - "key" : { - "name" : "IntType", - "version" : "0.0.1" - }, - "value" : { - "key" : { - "name" : "IntType", - "version" : "0.0.1" - }, - "schemaFlavour" : "Java", - "schemaDefinition" : "java.lang.Integer" - } - } ] - } - } - } -} -- cgit 1.2.3-korg