From 37d6fd9069eb30d88c4ad80b5f35099ed173cc13 Mon Sep 17 00:00:00 2001 From: ramverma Date: Fri, 1 Jun 2018 11:51:36 +0100 Subject: Adding apex core module to apex-pdp Change-Id: I4bfe1df3e44fe62ff6789e813e59836e267ab3b2 Issue-ID: POLICY-858 Signed-off-by: ramverma --- .../protocols/engdep/GetExecutionStatusTest.java | 58 ++++++++++++++++++ .../core/protocols/engdep/GetPolicyStatusTest.java | 58 ++++++++++++++++++ .../apex/core/protocols/engdep/ResponseTest.java | 65 ++++++++++++++++++++ .../core/protocols/engdep/UpdateModelTest.java | 58 ++++++++++++++++++ .../src/test/resources/logback-test.xml | 70 ++++++++++++++++++++++ 5 files changed, 309 insertions(+) create mode 100644 core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java create mode 100644 core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java create mode 100644 core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java create mode 100644 core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java create mode 100644 core/core-protocols/src/test/resources/logback-test.xml (limited to 'core/core-protocols/src/test') diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java new file mode 100644 index 000000000..d5cf2bcba --- /dev/null +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetExecutionStatusTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-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.protocols.engdep; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class GetExecutionStatusTest. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class GetExecutionStatusTest { + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(GetExecutionStatusTest.class); + + GetEngineStatus message = null; + + /** + * Test register entity. + * + * @throws UnknownHostException the unknown host exception + */ + @Test + public void testRegisterEntity() throws UnknownHostException { + final AxArtifactKey targetKey = new AxArtifactKey("UpdateModelTest", "0.0.1"); + message = new GetEngineStatus(targetKey); + assertNotNull(message); + logger.debug(message.toString()); + assertTrue((message.toString()).contains("UpdateModelTest")); + } +} diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java new file mode 100644 index 000000000..97cc8d5b9 --- /dev/null +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/GetPolicyStatusTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-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.protocols.engdep; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.policy.apex.core.protocols.engdep.messages.GetEngineStatus; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class GetPolicyStatusTest. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class GetPolicyStatusTest { + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(GetPolicyStatusTest.class); + + GetEngineStatus message = null; + + /** + * Test register entity. + * + * @throws UnknownHostException the unknown host exception + */ + @Test + public void testRegisterEntity() throws UnknownHostException { + final AxArtifactKey targetKey = new AxArtifactKey("PolicyStatusTest", "0.0.1"); + message = new GetEngineStatus(targetKey); + assertNotNull(message); + logger.debug(message.toString()); + assertTrue((message.toString()).contains("PolicyStatusTest")); + } +} diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java new file mode 100644 index 000000000..74def7cc0 --- /dev/null +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/ResponseTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-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.protocols.engdep; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.policy.apex.core.protocols.engdep.messages.Response; +import org.onap.policy.apex.core.protocols.engdep.messages.UpdateModel; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class ResponseTest. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class ResponseTest { + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(ResponseTest.class); + + Response message = null; + + /** + * Test response. + * + * @throws UnknownHostException the unknown host exception + */ + @Test + public void testResponse() throws UnknownHostException { + final AxArtifactKey responseKey = new AxArtifactKey("ResponseTest", "0.0.1"); + final AxArtifactKey responseToKey = new AxArtifactKey("ResponseTestTO", "0.0.1"); + message = new Response(responseKey, false, new UpdateModel(responseToKey)); + logger.debug(message.toString()); + assertTrue(message.toString().contains("ResponseTest")); + assertFalse(message.isSuccessful()); + + message = new Response(responseKey, true, new UpdateModel(responseToKey)); + logger.debug(message.toString()); + assertTrue(message.toString().contains("ResponseTest")); + assertTrue(message.isSuccessful()); + } +} diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java new file mode 100644 index 000000000..ca919c389 --- /dev/null +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/engdep/UpdateModelTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-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.protocols.engdep; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.policy.apex.core.protocols.engdep.messages.UpdateModel; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class UpdateModelTest. + * + * @author Liam Fallon (liam.fallon@ericsson.com) + */ +public class UpdateModelTest { + // Logger for this class + private static final XLogger logger = XLoggerFactory.getXLogger(UpdateModelTest.class); + + UpdateModel message = null; + + /** + * Test register entity. + * + * @throws UnknownHostException the unknown host exception + */ + @Test + public void testRegisterEntity() throws UnknownHostException { + final AxArtifactKey targetKey = new AxArtifactKey("UpdateModelTest", "0.0.1"); + message = new UpdateModel(targetKey, new String("Placeholder for Apex model XML"), false, false); + assertNotNull(message); + logger.debug(message.toString()); + assertTrue((message.toString()).contains("Placeholder for Apex model XML")); + } +} diff --git a/core/core-protocols/src/test/resources/logback-test.xml b/core/core-protocols/src/test/resources/logback-test.xml new file mode 100644 index 000000000..034511335 --- /dev/null +++ b/core/core-protocols/src/test/resources/logback-test.xml @@ -0,0 +1,70 @@ + + + + + + Apex + + + + + + + %d %contextName [%t] %level %logger{36} - %msg%n + + + + + + + + + + + + + + + + + ${LOG_DIR}/apex.log + + %d %-5relative [procId=${processId}] [%thread] %-5level + %logger{26} - %msg %n %ex{full} + + + + + ${LOG_DIR}/apex_ctxt.log + + %d %-5relative [procId=${processId}] [%thread] %-5level + %logger{26} - %msg %n %ex{full} + + + + + + + + + + + -- cgit 1.2.3-korg