aboutsummaryrefslogtreecommitdiffstats
path: root/graph-inventory/aai-client/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'graph-inventory/aai-client/src/test')
-rw-r--r--graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientTest.java2
-rw-r--r--graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookupTest.java74
-rw-r--r--graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java11
3 files changed, 86 insertions, 1 deletions
diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientTest.java
index 4cb79ef9ad..ca361f46d8 100644
--- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientTest.java
+++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientTest.java
@@ -49,7 +49,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
-import org.onap.so.client.RestClient;
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri;
@@ -57,6 +56,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.defaultproperties.DefaultAAIPropertiesImpl;
import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryMultipleItemsException;
+import org.onap.so.client.RestClient;
import com.github.tomakehurst.wiremock.admin.NotFoundException;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookupTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookupTest.java
new file mode 100644
index 0000000000..699eac9768
--- /dev/null
+++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookupTest.java
@@ -0,0 +1,74 @@
+package org.onap.aaiclient.client.aai.entities.uri;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+
+public class AAIFluentTypeReverseLookupTest {
+
+
+ @Test
+ public void reverseParseEntryUri() {
+ String cloudRegion =
+ "http://localhost:8888/aai/v38/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}";
+ String newvce = "/aai/v9/network/newvces/newvce/{vnf-id2}";
+
+ AAIFluentTypeReverseLookup lookup = new AAIFluentTypeReverseLookup();
+ AAIObjectType type = lookup.fromName("cloud-region", cloudRegion);
+
+ assertEquals("cloud-region", type.typeName());
+ assertEquals("/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}", type.partialUri());
+ assertEquals("/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}",
+ type.uriTemplate());
+
+ type = lookup.fromName("newvce", newvce);
+
+ assertEquals("newvce", type.typeName());
+ assertEquals("/newvces/newvce/{vnf-id2}", type.partialUri());
+ assertEquals("/network/newvces/newvce/{vnf-id2}", type.uriTemplate());
+
+ type = lookup.fromName("unknown-type-of-something", "/some/endpoint");
+
+ assertEquals("unknown", type.typeName());
+
+ }
+
+ @Test
+ public void reverseParseTest() {
+
+ String pserverParent =
+ "/aai/v9/cloud-infrastructure/pservers/pserver/{hostname}/lag-interfaces/lag-interface/{interface-name}/l-interfaces/l-interface/{l-interface.interface-name}";
+ String cloudRegionParent =
+ "http://localhost:8888/aai/v38/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}/l-interfaces/l-interface/{interface-name}";
+ String newVceParent = "/network/newvces/newvce/{vnf-id2}/l-interfaces/l-interface/{l-interface.interface-name}";
+
+
+ AAIFluentTypeReverseLookup lookup = new AAIFluentTypeReverseLookup();
+
+ AAIObjectType type = lookup.fromName("l-interface", pserverParent);
+
+ assertEquals("l-interface", type.typeName());
+ assertEquals("/l-interfaces/l-interface/{l-interface.interface-name}", type.partialUri());
+ assertEquals(
+ "/cloud-infrastructure/pservers/pserver/{hostname}/lag-interfaces/lag-interface/{interface-name}/l-interfaces/l-interface/{l-interface.interface-name}",
+ type.uriTemplate());
+
+ type = lookup.fromName("l-interface", cloudRegionParent);
+
+ assertEquals("l-interface", type.typeName());
+ assertEquals("/l-interfaces/l-interface/{l-interface.interface-name}", type.partialUri());
+ assertEquals(
+ "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}/l-interfaces/l-interface/{l-interface.interface-name}",
+ type.uriTemplate());
+
+ type = lookup.fromName("l-interface", newVceParent);
+
+ assertEquals("l-interface", type.typeName());
+ assertEquals("/l-interfaces/l-interface/{l-interface.interface-name}", type.partialUri());
+ assertEquals("/network/newvces/newvce/{vnf-id2}/l-interfaces/l-interface/{l-interface.interface-name}",
+ type.uriTemplate());
+
+
+
+ }
+}
diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java
index 3b11c01436..f8dd1726d3 100644
--- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java
+++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriTest.java
@@ -31,6 +31,7 @@ import java.util.Map;
import org.junit.Test;
import org.onap.aaiclient.client.aai.AAIObjectPlurals;
import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
public class AAISimpleUriTest {
@@ -130,4 +131,14 @@ public class AAISimpleUriTest {
assertEquals(e2.build().toString(), uri.build().toString());
}
+
+ @Test
+ public void fluentBuilderTest() {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
+ .cloudRegion("cloud1", "cloud-id").tenant("tenant-id").vserver("vserver-id"));
+
+ assertEquals(
+ "/cloud-infrastructure/cloud-regions/cloud-region/cloud1/cloud-id/tenants/tenant/tenant-id/vservers/vserver/vserver-id",
+ uri.build().toString());
+ }
}