diff options
author | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-10-29 16:13:05 -0400 |
---|---|---|
committer | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-11-04 10:11:21 -0500 |
commit | 73e3ea2f9183fc7ed6ba8c0f221e41a804fbe2c7 (patch) | |
tree | e1033b47c0c1d091bd90d215c44727a99d9dc341 /models-interactions/model-impl/aai/src/test | |
parent | 18555714bf9d3204be552c8664f008ec31115479 (diff) |
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 <rashmi.pujar@bell.ca>
Change-Id: Ie0ceb320943531de6e6bc8675844b29a358dfb7e
Diffstat (limited to 'models-interactions/model-impl/aai/src/test')
-rw-r--r-- | models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java | 43 |
1 files changed, 27 insertions, 16 deletions
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<Integer, String> httpResponseOk; - Pair<Integer, String> httpResponseErr0; - Pair<Integer, String> httpResponseErr1; - Pair<Integer, String> httpResponseWait; - Pair<Integer, String> httpTenantResponseOk; - Pair<Integer, String> 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<Integer, String> httpResponseOk; + private Pair<Integer, String> httpResponseErr0; + private Pair<Integer, String> httpResponseErr1; + private Pair<Integer, String> httpResponseWait; + private Pair<Integer, String> httpTenantResponseOk; + private Pair<Integer, String> httpCqResponseOk; /** * Set up test cases. @@ -73,11 +72,6 @@ public class AaiManagerTest { public void beforeTestAaiManager() throws Exception { restManagerMock = mock(RestManager.class); - Map<String, String> 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<Integer, String> pnfHttpResponse = restManagerMock.new Pair<>(200, pnfResponse); + when(restManagerMock.get(contains(pnfName), eq(DOROTHY), eq("Gale"), anyMap())) + .thenReturn(pnfHttpResponse); + + Map<String, String> pnfParams = aaiManager.getPnf(SOME_URL, DOROTHY, "Gale", UUID.randomUUID(), pnfName); + assertNotNull(pnfParams); + assertEquals(pnfName, pnfParams.get("pnf.pnf-name")); + } } |