diff options
author | lapentafd <francesco.lapenta@est.tech> | 2021-05-27 10:18:49 +0100 |
---|---|---|
committer | lapentafd <francesco.lapenta@est.tech> | 2021-05-31 16:39:15 +0100 |
commit | b6c674891e00f3bac43bd7b4fca06e7a87b8dd34 (patch) | |
tree | 35e0dfe7f60b01e651e1ad8741825419537855de /core | |
parent | c70c2179f1555e356794145956cbe32a3407e622 (diff) |
Fix Sonar Issues on Apex-pdp
Changes made into cli-codegen, cli-editor, and core-engine
Renamed one test class to match other test classes
Issue-ID: POLICY-3093
Change-Id: Ib2d947782021590ffc08d426e7a1607a8c33f98a
Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'core')
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); |