diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-04-11 17:48:54 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-11 17:48:54 +0000 |
commit | 84286faf575e4311720829c1df101614a769a240 (patch) | |
tree | 0b80804b01ed1c71a567005893ae8e414022b11e /controlloop/common/eventmanager/src/test/java | |
parent | a7a144ba512654bd93b0856b1e9eb5c886060c21 (diff) | |
parent | 080dd34e7f506027c2dc1a87ddc4c9aa347a9c59 (diff) |
Merge "Drools-App changes to support CQ"
Diffstat (limited to 'controlloop/common/eventmanager/src/test/java')
2 files changed, 47 insertions, 24 deletions
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java index 7c3a38b38..bce96b2f0 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java @@ -43,6 +43,7 @@ import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.onap.policy.aai.AaiCqResponse; import org.onap.policy.aai.AaiGetVnfResponse; import org.onap.policy.aai.AaiGetVserverResponse; import org.onap.policy.aai.AaiNqRequestError; @@ -80,6 +81,7 @@ public class ControlLoopEventManagerTest { private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManagerTest.class); + @Rule public ExpectedException thrown = ExpectedException.none(); @@ -558,7 +560,7 @@ public class ControlLoopEventManagerTest { VirtualControlLoopNotification clfNotification = manager.isControlLoopFinal(); assertNull(clfNotification); - + // serialize and de-serialize manager manager = Serializer.roundTrip(manager); @@ -632,7 +634,7 @@ public class ControlLoopEventManagerTest { ControlLoopOperationManager clom = manager.processControlLoop(); assertNotNull(clom); assertNull(clom.getOperationResult()); - + // serialize and de-serialize manager manager = Serializer.roundTrip(manager); @@ -724,7 +726,7 @@ public class ControlLoopEventManagerTest { } assertNull(manager.unlockCurrentOperation()); - + // serialize and de-serialize manager manager = Serializer.roundTrip(manager); @@ -917,7 +919,7 @@ public class ControlLoopEventManagerTest { try { onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, Boolean.TRUE.toString()); onset.getAai().put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS, - ControlLoopEventManager.PROV_STATUS_ACTIVE); + ControlLoopEventManager.PROV_STATUS_ACTIVE); mgr = makeManager(onset); mgr.queryAai(onset); @@ -1290,6 +1292,23 @@ public class ControlLoopEventManagerTest { assertNull(manager.getNqVserverFromAai()); } + @Test + public void testGetCqResponse() { + try { + ControlLoopEventManager mgr = null; + mgr = makeManager(onset); + mgr.queryAai(onset); + AaiCqResponse aaiCqResponse = mgr.getCqResponse(onset); + assertNotNull(aaiCqResponse); + + + } catch (Exception e) { + logger.error("testGetCqResponse Exception: ", e); + fail(e.getMessage()); + } + } + + private ControlLoopEventManager makeManager(VirtualControlLoopEvent event) { return new ControlLoopEventManager(event.getClosedLoopControlName(), event.getRequestId()); } diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java index d8533c7e7..568f8bcd4 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java @@ -7,9 +7,9 @@ * 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. @@ -119,7 +119,7 @@ public class ControlLoopOperationManagerTest { return numEvents; } - + /** * Set up test class. */ @@ -131,7 +131,7 @@ public class ControlLoopOperationManagerTest { } catch (Exception e) { fail(e.getMessage()); } - + // Set PU System.setProperty("OperationsHistoryPU", "OperationsHistoryPUTest"); @@ -155,7 +155,7 @@ public class ControlLoopOperationManagerTest { emf.close(); HttpServletServer.factory.destroy(); } - + @Test public void testRetriesFail() { // @@ -479,8 +479,11 @@ public class ControlLoopOperationManagerTest { onsetEvent.getAai().remove("generic-vnf.vnf-id"); manager.getVnfResponse(); - clom.getEventManager().getVnfResponse().setVnfId("generic-vnf.vnf-id"); - assertEquals("generic-vnf.vnf-id", clom.getTarget(policy)); + if (!Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty("aai.customQuery"))) { + clom.getEventManager().getVnfResponse().setVnfId("generic-vnf.vnf-id"); + assertEquals("generic-vnf.vnf-id", clom.getTarget(policy)); + } + policy.getTarget().setType(TargetType.VFC); try { @@ -550,6 +553,7 @@ public class ControlLoopOperationManagerTest { clom = new ControlLoopOperationManager(onsetEvent, policy, manager); assertNotNull(clom); + policy.setActor("SO"); clom = new ControlLoopOperationManager(onsetEvent, policy, manager); assertNotNull(clom); @@ -804,13 +808,13 @@ public class ControlLoopOperationManagerTest { System.setProperty("OperationsHistoryPU", "OperationsHistoryPUTest"); assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw)); - } + } @Test public void testCommitAbatement() throws ControlLoopException, AaiException, IOException { String yamlString = null; - try ( InputStream is = new FileInputStream(new File("src/test/resources/test.yaml")) ) { + try (InputStream is = new FileInputStream(new File("src/test/resources/test.yaml"))) { yamlString = IOUtils.toString(is, StandardCharsets.UTF_8); } catch (Exception e) { fail(e.getMessage()); @@ -835,19 +839,19 @@ public class ControlLoopOperationManagerTest { Policy policy = manager.getProcessor().getCurrentPolicy(); ControlLoopOperationManager clom = new ControlLoopOperationManager(onsetEvent, policy, manager); assertNotNull(clom); - + clom.startOperation(onsetEvent); int numEventsBefore = getCount(); - logger.info("numEventsBefore={}", numEventsBefore); - - clom.commitAbatement("Test message","TEST_RESULT"); + logger.info("numEventsBefore={}", numEventsBefore); + + clom.commitAbatement("Test message", "TEST_RESULT"); int numEventsAfter = getCount(); - logger.info("numEventsAfter={}", numEventsAfter); - - assertEquals(1, numEventsAfter - numEventsBefore); - } + logger.info("numEventsAfter={}", numEventsAfter); + + assertEquals(1, numEventsAfter - numEventsBefore); + } @Test public void testSerialization() throws Exception { @@ -876,7 +880,7 @@ public class ControlLoopOperationManagerTest { clom.startOperation(onsetEvent); assertTrue(clom.isOperationRunning()); - + clom = Serializer.roundTrip(clom); assertNotNull(clom); assertTrue(clom.isOperationRunning()); @@ -893,7 +897,7 @@ public class ControlLoopOperationManagerTest { assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw)); assertFalse(clom.isOperationRunning()); assertEquals(1, clom.getHistory().size()); - + clom = Serializer.roundTrip(clom); assertNotNull(clom); assertFalse(clom.isOperationRunning()); @@ -901,7 +905,7 @@ public class ControlLoopOperationManagerTest { System.setProperty("OperationsHistoryPU", "OperationsHistoryPUTest"); assertEquals(PolicyResult.FAILURE, clom.onResponse(soRw)); - + clom = Serializer.roundTrip(clom); assertNotNull(clom); assertFalse(clom.isOperationRunning()); |