summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAjith Sreekumar <ajith.sreekumar@bell.ca>2021-06-02 11:44:06 +0000
committerGerrit Code Review <gerrit@onap.org>2021-06-02 11:44:06 +0000
commit471f4036f96a11a1d4bf33d39f3e802c8fdb4aae (patch)
treedfbac00bd50229de9822e2bce6100a387e58ac5a /core
parent328fa34f8ac18d30fec00c7c5f59a05850f631a5 (diff)
parentb6c674891e00f3bac43bd7b4fca06e7a87b8dd34 (diff)
Merge "Fix Sonar Issues on Apex-pdp"
Diffstat (limited to 'core')
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java18
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java9
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java11
3 files changed, 31 insertions, 7 deletions
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
index d559d7591..c9d9b9c8d 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -169,7 +169,7 @@ public class ApexEngineImplTest {
}
@Test
- public void testSanity() throws ApexException {
+ public void testSanity() throws ApexException {
AxArtifactKey engineKey = new AxArtifactKey("Engine:0.0.1");
ApexEngineImpl engine = (ApexEngineImpl) new ApexEngineFactory().createApexEngine(engineKey);
assertNotNull(engine);
@@ -196,6 +196,12 @@ public class ApexEngineImplTest {
assertThatThrownBy(() -> engine.removeEventListener(null))
.hasMessage("removeEventListener()<-Engine:0.0.1,STOPPED, listenerName is null");
+ }
+
+ @Test
+ public void testListener() throws ApexException {
+ AxArtifactKey engineKey = new AxArtifactKey("Engine:0.0.1");
+ ApexEngineImpl engine = (ApexEngineImpl) new ApexEngineFactory().createApexEngine(engineKey);
engine.addEventListener("myListener", new DummyListener());
engine.removeEventListener("myListener");
@@ -244,6 +250,14 @@ public class ApexEngineImplTest {
assertEquals(AxEngineState.READY, engine.getState());
assertNull(engine.createEvent(null));
+ }
+
+ @Test
+ public void testEventKey() throws ApexException {
+ AxArtifactKey engineKey = new AxArtifactKey("Engine:0.0.1");
+ ApexEngineImpl engine = (ApexEngineImpl) new ApexEngineFactory().createApexEngine(engineKey);
+ engine.updateModel(policyModel, false);
+ engine.start();
AxArtifactKey eventKey = new AxArtifactKey("Event:0.0.1");
EnEvent event = engine.createEvent(eventKey);
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java
index 47b85629f..e794a7d04 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/engine/impl/DummySlowEnEventListener.java
@@ -1,20 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 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=========================================================
*/
@@ -27,6 +27,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
/**
* Dummy engine event listener for unit test.
+ * Thread.sleep is used to simulate a slow event listener.
*
*/
public class DummySlowEnEventListener implements EnEventListener {
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java
index fa04f19b5..128e585fe 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/event/EnEventTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -101,6 +101,15 @@ public class EnEventTest {
.hasMessage("null keys are illegal on method parameter \"key\"");
assertThatThrownBy(() -> event.put("NonField", null))
.hasMessage("parameter with key \"NonField\" not defined on event \"Event\"");
+ }
+
+ @Test
+ public void testAxEvent() {
+ AxArtifactKey eventKey = new AxArtifactKey("Event:0.0.1");
+ AxEvent axEvent = new AxEvent(eventKey, "a.name.space", "some source", "some target");
+ ModelService.getModel(AxEvents.class).getEventMap().put(eventKey, axEvent);
+ EnEvent event = new EnEvent(eventKey);
+
AxReferenceKey fieldKey = new AxReferenceKey("Parent", "0.0.1", "MyParent", "MyField");
AxArtifactKey fieldSchemaKey = new AxArtifactKey("FieldSchema:0.0.1");
AxField axField = new AxField(fieldKey, fieldSchemaKey);