aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-08-29 11:40:46 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-08-29 11:40:46 +0300
commit0ba9caffd1185fdd16f97830916ae6e3d6b08116 (patch)
treef900d8ade78af05cbb487e0ca0b87ca12270baaa /vid-app-common/src/test
parent9d0908e18d51a4ba1c4a54b01fcbe16598bd352a (diff)
fix url and payload for getting latest model
Issue-ID: VID-378 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: I5b2dc7df0202838898ab060a71c144f69a54900f
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
index 9793862ca..5c37bb1ee 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
@@ -913,4 +913,76 @@ public class AaiClientTest {
void acceptThrows(T t, U u) throws Exception;
}
+ @Test
+ public void getLatestVersionByInvariantId_verifyCallingExpectedApi(){
+
+ when(aaiClientMock.getLatestVersionByInvariantId(anyString())).thenCallRealMethod();
+
+ aaiClientMock.getLatestVersionByInvariantId("model-invariant-id");
+
+ Mockito.verify(aaiClientMock).doAaiPut(argThat(url -> url.endsWith("query?format=resource&depth=0")),argThat(payload -> payload.contains("service-design-and-creation/models/model/model-invariant-id")),anyBoolean());
+
+ }
+
+ @DataProvider
+ public static Object[][] getSubscriberDataDataProvider() {
+ return new Object[][] {
+ { "Some-ID", true },
+ { "another id 123", false },
+ };
+ }
+
+ @Test(dataProvider = "getSubscriberDataDataProvider")
+ public void getSubscriberDataParams(String subscriberId, boolean omitServiceInstances) {
+ String depth = omitServiceInstances ? "1" : "2";
+ when(aaiClientMock.getSubscriberData(anyString(),anyBoolean())).thenCallRealMethod();
+ aaiClientMock.getSubscriberData(subscriberId, omitServiceInstances);
+ Mockito.verify(aaiClientMock).doAaiGet(argThat(s -> s.contains("customer/" + subscriberId + "?") && s.contains("depth=" + depth)),any(Boolean.class));
+ }
+
+ @Test
+ public void testToModelVerStream() throws IOException {
+
+ ModelVersions modelVersions = JACKSON_OBJECT_MAPPER.readValue("" +
+ "{\n" +
+ " \"results\": [\n" +
+ " {\n" +
+ " \"model\": {\n" +
+ " \"model-invariant-id\": \"f6342be5-d66b-4d03-a1aa-c82c3094c4ea\",\n" +
+ " \"model-type\": \"service\",\n" +
+ " \"resource-version\": \"1534274421300\"\n" +
+ " }\n" +
+ " },\n" +
+ " {\n" +
+ " \"model-ver\": {\n" +
+ " \"model-version-id\": \"a92f899d-a3ec-465b-baed-1663b0a5aee1\",\n" +
+ " \"model-name\": \"NCM_VLAN_SVC_ym161f\",\n" +
+ " \"model-version\": \"bbb\",\n" +
+ " \"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
+ " \"model-description\": \"Network Collection service for vLAN tagging\",\n" +
+ " \"resource-version\": \"1534788756086\"\n" +
+ " }\n" +
+ " },\n" +
+ " {\n" +
+ " \"model-ver\": {\n" +
+ " \"model-version-id\": \"d2fda667-e92e-4cfa-9620-5da5de01a319\",\n" +
+ " \"model-name\": \"NCM_VLAN_SVC_ym161f\",\n" +
+ " \"model-version\": \"aaa\",\n" +
+ " \"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
+ " \"model-description\": \"Network Collection service for vLAN tagging\",\n" +
+ " \"resource-version\": \"1534444087221\"\n" +
+ " }\n" +
+ " }]}", ModelVersions.class);
+
+
+ final AaiClient aaiClient = new AaiClient(null, null, null);
+
+ assertThat(aaiClient.toModelVerStream(modelVersions).collect(toList()),
+ containsInAnyOrder(
+ hasProperty("modelVersionId", is("a92f899d-a3ec-465b-baed-1663b0a5aee1")),
+ hasProperty("modelVersionId", is("d2fda667-e92e-4cfa-9620-5da5de01a319"))
+ ));
+
+ }
+
}