aboutsummaryrefslogtreecommitdiffstats
path: root/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUriTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUriTest.java')
-rw-r--r--graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUriTest.java50
1 files changed, 15 insertions, 35 deletions
diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUriTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUriTest.java
index 514a349095..6a1b459e6f 100644
--- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUriTest.java
+++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUriTest.java
@@ -56,10 +56,10 @@ import org.mockito.InjectMocks;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aaiclient.client.aai.AAIClient;
-import org.onap.aaiclient.client.aai.AAIObjectPlurals;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.defaultproperties.DefaultAAIPropertiesImpl;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri;
import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException;
import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException;
@@ -93,7 +93,7 @@ public class ServiceInstanceUriTest {
final String content = new String(
Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "service-instance-pathed-query.json")));
- ServiceInstanceUri instance = new ServiceInstanceUri("key3");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key3"));
final Optional<String> result = instance.extractRelatedLink(content);
final String expected =
"/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3";
@@ -105,7 +105,7 @@ public class ServiceInstanceUriTest {
public void oneKey()
throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key1"));
ServiceInstanceUri spy = spy(instance);
doReturn(
"/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3")
@@ -123,7 +123,7 @@ public class ServiceInstanceUriTest {
public void oneKeyQueryParams()
throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key1"));
ServiceInstanceUri spy = spy(instance);
doReturn(
"/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3")
@@ -141,7 +141,7 @@ public class ServiceInstanceUriTest {
public void oneKeyEncoded()
throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key1"));
ServiceInstanceUri spy = spy(instance);
doReturn(
"/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space")
@@ -159,7 +159,7 @@ public class ServiceInstanceUriTest {
public void oneKeyGetKeys()
throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key1"));
ServiceInstanceUri spy = spy(instance);
doReturn(
"/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%28space")
@@ -171,7 +171,7 @@ public class ServiceInstanceUriTest {
@Test
public void oneKeyClone() throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key1"));
ServiceInstanceUri spy = spy(instance);
String uri =
"/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3";
@@ -184,23 +184,11 @@ public class ServiceInstanceUriTest {
}
@Test
- public void threeKey() throws IOException {
-
- ServiceInstanceUri instance = new ServiceInstanceUri("key1", "key2", "key3");
- final URI result = instance.build();
- final URI expected = UriBuilder.fromPath(
- "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3")
- .build();
- assertEquals("result is equal", expected, result);
-
- }
-
- @Test
public void notfound() throws IOException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
final String content =
new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "empty-query-result.json")));
- ServiceInstanceUri instance = new ServiceInstanceUri("key3");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key3"));
ServiceInstanceUri spy = spy(instance);
AAIResourcesClient mockResourcesClient = mock(AAIResourcesClient.class);
AAIResultWrapper wrapper = mock(AAIResultWrapper.class);
@@ -214,17 +202,8 @@ public class ServiceInstanceUriTest {
}
@Test
- public void cloneTest() {
- ServiceInstanceUri instance = new ServiceInstanceUri("key1", "key2", "key3");
- final URI result = instance.build();
- final URI result2 = instance.clone().queryParam("something", "new").build();
- assertEquals("uris are not equal", false, result.toString().equals(result2.toString()));
-
- }
-
- @Test
public void noVertexFound() throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key3");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key3"));
ServiceInstanceUri spy = spy(instance);
AAIResourcesClient client = aaiClient;
doReturn(client).when(spy).getResourcesClient();
@@ -238,7 +217,7 @@ public class ServiceInstanceUriTest {
@Test
public void serializeTest() throws IOException, ClassNotFoundException, GraphInventoryUriNotFoundException,
GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key3");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key3"));
final String content = new String(
Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "service-instance-pathed-query.json")));
@@ -274,13 +253,14 @@ public class ServiceInstanceUriTest {
@Test
public void relatedToTest() throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key1"));
ServiceInstanceUri spy = spy(instance);
doReturn(
"/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3")
.when(spy).getObjectById(any(Object.class));
- final URI result = spy.relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "my-vnf-name").build();
+ final URI result =
+ spy.relatedTo(Types.GENERIC_VNFS.getFragment()).queryParam("vnf-name", "my-vnf-name").build();
final URI expected = UriBuilder.fromUri(
"/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3/related-to/generic-vnfs?vnf-name=my-vnf-name")
.build();
@@ -290,11 +270,11 @@ public class ServiceInstanceUriTest {
@Test
public void relatedToEqualityTestBeforeBuildTest()
throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
- ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri instance = new ServiceInstanceUri(Types.SERVICE_INSTANCE.getFragment("key1"));
ServiceInstanceUri spy = spy(instance);
final AAIPluralResourceUri result =
- spy.relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "my-vnf-name");
+ spy.relatedTo(Types.GENERIC_VNFS.getFragment()).queryParam("vnf-name", "my-vnf-name");
assertEquals("result is equal", result, result);
}