From 73e3ea2f9183fc7ed6ba8c0f221e41a804fbe2c7 Mon Sep 17 00:00:00 2001 From: Rashmi Pujar Date: Tue, 29 Oct 2019 16:13:05 -0400 Subject: PNF support changes in policy/models AAI Enrichment method for PNF target-type and unit tests. Addition of a hashmap field to ControlLoopEvent class to hold event specific parameters. Update CDS actor to include additional event parameters Issue-ID: POLICY-1187 Signed-off-by: Rashmi Pujar Change-Id: Ie0ceb320943531de6e6bc8675844b29a358dfb7e --- .../java/org/onap/policy/aai/AaiManagerTest.java | 43 ++++++++++++++-------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'models-interactions/model-impl/aai/src/test/java') diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java index 9a8d7d260..ff86577b9 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java @@ -21,10 +21,12 @@ package org.onap.policy.aai; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.contains; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.startsWith; @@ -34,7 +36,6 @@ import static org.mockito.Mockito.when; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.util.HashMap; import java.util.Map; import java.util.UUID; import org.junit.Before; @@ -50,19 +51,17 @@ public class AaiManagerTest { private static final String DOROTHY = "Dorothy"; private static final String SOME_URL = "http://somewhere.over.the.rainbow"; private static final String ANOTHER_URL = "http://somewhere.under.the.rainbow"; - RestManager restManagerMock; - UUID aaiNqRequestUuid = UUID.randomUUID(); - Pair httpResponseOk; - Pair httpResponseErr0; - Pair httpResponseErr1; - Pair httpResponseWait; - Pair httpTenantResponseOk; - Pair httpCqResponseOk; - private static final String TENANT_RESPONSE_SAMPLE = "src/test/resources/org/onap/policy/aai/AaiTenantResponse.json"; - + private RestManager restManagerMock; + private UUID aaiNqRequestUuid = UUID.randomUUID(); + private Pair httpResponseOk; + private Pair httpResponseErr0; + private Pair httpResponseErr1; + private Pair httpResponseWait; + private Pair httpTenantResponseOk; + private Pair httpCqResponseOk; /** * Set up test cases. @@ -73,11 +72,6 @@ public class AaiManagerTest { public void beforeTestAaiManager() throws Exception { restManagerMock = mock(RestManager.class); - Map expectedHeaders = new HashMap<>(); - expectedHeaders.put("X-FromAppId", "POLICY"); - expectedHeaders.put("X-TransactionId", aaiNqRequestUuid.toString()); - expectedHeaders.put("Accept", "application/json"); - String aaiCqResponse = new AaiCqResponseTest().getAaiCqResponse(); String tenantResponse = this.getTenantQueryResponse(); httpCqResponseOk = restManagerMock.new Pair<>(200, aaiCqResponse); @@ -235,4 +229,21 @@ public class AaiManagerTest { "Gale", vserverNameRequestId, "vnfName"); assertNotNull(vnfResponse); } + + @Test + public void testAaiManagerGetPnf() { + AaiManager aaiManager = new AaiManager(restManagerMock); + assertNotNull(aaiManager); + String pnfName = "test-pnf"; + String pnfResponse = "{\"pnf-name\":" + pnfName + + ",\"pnf-id\":\"123456\",\"in-maint\":false,\"ipaddress-v4-oam\":\"1.1.1.1\"}"; + + Pair pnfHttpResponse = restManagerMock.new Pair<>(200, pnfResponse); + when(restManagerMock.get(contains(pnfName), eq(DOROTHY), eq("Gale"), anyMap())) + .thenReturn(pnfHttpResponse); + + Map pnfParams = aaiManager.getPnf(SOME_URL, DOROTHY, "Gale", UUID.randomUUID(), pnfName); + assertNotNull(pnfParams); + assertEquals(pnfName, pnfParams.get("pnf.pnf-name")); + } } -- cgit 1.2.3-korg