diff options
Diffstat (limited to 'graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri')
7 files changed, 62 insertions, 138 deletions
diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriFromParentUriTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriFromParentUriTest.java index 3823392b01..e8c84c02ff 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriFromParentUriTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriFromParentUriTest.java @@ -22,7 +22,8 @@ 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; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; public class AAISimpleUriFromParentUriTest { @@ -30,10 +31,10 @@ public class AAISimpleUriFromParentUriTest { @Test public void appendChildren() { - AAIResourceUri parentUri = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "key1", "key2", "key3"); + AAIResourceUri parentUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().customer("key1").serviceSubscription("key2").serviceInstance("key3")); - AAIResourceUri uri = new AAISimpleUri(parentUri, AAIObjectType.ALLOTTED_RESOURCE, "key4"); + AAIResourceUri uri = new AAISimpleUri(parentUri, Types.ALLOTTED_RESOURCE.getFragment("").get().build(), "key4"); assertEquals("path appended", "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3/allotted-resources/allotted-resource/key4", diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriFromUriTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriFromUriTest.java index 9030789cfd..3c8b2e8743 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriFromUriTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUriFromUriTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals; import javax.ws.rs.core.UriBuilder; import org.junit.Test; import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; public class AAISimpleUriFromUriTest { @@ -66,10 +67,11 @@ public class AAISimpleUriFromUriTest { @Test public void beforeBuildEquality() { - AAIResourceUri uri = new AAISimpleUri(AAIObjectType.VCE, + AAIResourceUri uri = new AAISimpleUri(AAIFluentTypeBuilder.network().vce("").build(), UriBuilder.fromUri("/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053").build()); - AAIResourceUri uri2 = new AAISimpleUri(AAIObjectType.VCE, "a9f ec18e-1ea3-40e4-a6c0-a89b3de07053"); + AAIResourceUri uri2 = new AAISimpleUri(AAIFluentTypeBuilder.network().vce("").build(), + "a9f ec18e-1ea3-40e4-a6c0-a89b3de07053"); assertEquals("are equal", uri2, uri); } 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 92e74163a7..6382be4a92 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 @@ -29,8 +29,6 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; 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.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; @@ -41,14 +39,14 @@ public class AAISimpleUriTest { @Test public void relatedToTestPlural() { - AAIPluralResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1").relatedTo(AAIObjectPlurals.PSERVER); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")) + .relatedTo(Types.PSERVERS.getFragment()); String uriOutput = uri.build().toString(); String expected = "/network/generic-vnfs/generic-vnf/test1/related-to/pservers"; assertEquals(expected, uriOutput); - uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") + uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")) .relatedTo(Types.PSERVERS.getFragment()); uriOutput = uri.build().toString(); assertEquals(expected, uriOutput); @@ -56,14 +54,14 @@ public class AAISimpleUriTest { @Test public void relatedToTestSingular() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") - .relatedTo(AAIObjectType.PSERVER, "test2"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")) + .relatedTo(Types.PSERVER.getFragment("test2")); String uriOutput = uri.build().toString(); String expected = "/network/generic-vnfs/generic-vnf/test1/related-to/pservers/pserver/test2"; assertEquals(expected, uriOutput); - uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") + uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")) .relatedTo(Types.PSERVER.getFragment("test2")); uriOutput = uri.build().toString(); @@ -74,7 +72,7 @@ public class AAISimpleUriTest { @Test public void cloneTestSingular() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")); AAIResourceUri cloned = uri.clone(); assertEquals("/network/generic-vnfs/generic-vnf/test1", cloned.build().toString()); @@ -85,31 +83,31 @@ public class AAISimpleUriTest { @Test public void cloneTestPlural() { - AAISimplePluralUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAISimplePluralUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()); AAISimplePluralUri cloned = uri.clone(); assertEquals("/network/generic-vnfs", cloned.build().toString()); } @Test public void cloneTestWithRelatedTo() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1") - .relatedTo(AAIObjectType.PSERVER, "test2"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")) + .relatedTo(Types.PSERVER.getFragment("test2")); String uriOutput = uri.clone().build().toString(); assertEquals("/network/generic-vnfs/generic-vnf/test1/related-to/pservers/pserver/test2", uriOutput); } @Test public void cloneTestPluralWithRelatedTo() { - AAIPluralResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1").relatedTo(AAIObjectPlurals.PSERVER); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")) + .relatedTo(Types.PSERVERS.getFragment()); String uriOutput = uri.clone().build().toString(); assertEquals("/network/generic-vnfs/generic-vnf/test1/related-to/pservers", uriOutput); } @Test public void getKeysTest() { - AAIResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, "cloud1", "cloud2", "tenant1", "vserver1"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion("cloud1", "cloud2").tenant("tenant1").vserver("vserver1")); Map<String, String> keys = uri.getURIKeys(); System.out.println(keys); System.out.println(uri.build()); @@ -118,8 +116,8 @@ public class AAISimpleUriTest { @Test public void getEncodedKeyTest() { - AAIResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "test1", "my value", "test3"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("test1") + .serviceSubscription("my value").serviceInstance("test3")); Map<String, String> keys = uri.getURIKeys(); assertEquals("my value", keys.get("service-type")); @@ -127,7 +125,7 @@ public class AAISimpleUriTest { @Test public void serializeTest() throws IOException, ClassNotFoundException { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")); uri.depth(Depth.ONE); uri.limit(1); diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactoryTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactoryTest.java index ec40b1b477..87517369c3 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactoryTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactoryTest.java @@ -22,15 +22,16 @@ package org.onap.aaiclient.client.aai.entities.uri; import static org.junit.Assert.assertEquals; 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.generated.fluentbuilders.AAIFluentTypeBuilder.Types; public class AAIUriFactoryTest { @Test public void testCreateResourceUri() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("VIP(VelocitytoIP)")); String expected = "/network/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; assertEquals(expected, uri.build().toString()); @@ -39,7 +40,7 @@ public class AAIUriFactoryTest { @Test public void testCreateNodesUri() { - AAIResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); + AAIResourceUri uri = AAIUriFactory.createNodesUri(Types.GENERIC_VNF.getFragment("VIP(VelocitytoIP)")); String expected = "/nodes/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; assertEquals(expected, uri.build().toString()); @@ -48,8 +49,9 @@ public class AAIUriFactoryTest { @Test public void testCreateResourceFromExistingURI() { - AAIResourceUri uri = new AAISimpleUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); - AAIResourceUri uri2 = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.GENERIC_VNF, uri.build()); + AAIResourceUri uri = + new AAISimpleUri(AAIFluentTypeBuilder.network().genericVnf("").build(), "VIP(VelocitytoIP)"); + AAIResourceUri uri2 = AAIUriFactory.createResourceFromExistingURI(Types.GENERIC_VNF, uri.build()); String expected = "/network/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; assertEquals(expected, uri2.build().toString()); @@ -58,11 +60,20 @@ public class AAIUriFactoryTest { @Test public void testCreateResourceURIForPluralsWithValues() { - AAIPluralResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, "customerId", "serviceType"); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer("customerId").serviceSubscription("serviceType").serviceInstances()); String expected = "/business/customers/customer/customerId/service-subscriptions/service-subscription/serviceType/service-instances"; assertEquals(expected, uri.build().toString()); } + + @Test + public void testCreateResourceURIForPluralsWithNoValues() { + + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customers()); + + String expected = "/business/customers"; + assertEquals(expected, uri.build().toString()); + } } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUriTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUriTest.java index e6add8cbc1..eb59173c9f 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUriTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUriTest.java @@ -29,6 +29,7 @@ import java.net.URI; import java.net.URISyntaxException; import javax.ws.rs.core.UriBuilder; import org.junit.Test; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriNotFoundException; @@ -38,7 +39,7 @@ public class AllottedResourceLookupUriTest { public void oneKey() throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException { - AllottedResourceLookupUri instance = new AllottedResourceLookupUri("key1"); + AllottedResourceLookupUri instance = new AllottedResourceLookupUri(Types.ALLOTTED_RESOURCE.getFragment("key1")); AllottedResourceLookupUri spy = spy(instance); doReturn( "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3/allotted-resources/allotted-resource/key4") diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java deleted file mode 100644 index 2cbf5bb090..0000000000 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aaiclient.client.aai.entities.uri; - -import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.graphinventory.exceptions.IncorrectNumberOfUriKeys; - -public class IncorrectNumberOfUriKeysTest { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void verifyIncorrectNumberOfKeysSingle() { - - thrown.expect(IncorrectNumberOfUriKeys.class); - thrown.expectMessage(equalTo("Expected 3 variables: [cloud-owner, cloud-region-id, volume-group-id]")); - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, "volume-group-id"); - - } - - @Test - public void verifyIncorrectNumberOfKeysPlural() { - - thrown.expect(IncorrectNumberOfUriKeys.class); - AAISimplePluralUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, "my-cloud-owner"); - - } - - @Test - public void verifyIncorrectNumberOfKeysFromParent() { - - thrown.expect(IncorrectNumberOfUriKeys.class); - AAIResourceUri parentUri = - AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, "my-cloud-owner", "my-cloud-region-id"); - AAIResourceUri uri = AAIUriFactory.createResourceFromParentURI(parentUri, AAIObjectType.VOLUME_GROUP); - } - - @Test - public void verifyIncorrectNumberOfKeysHttpAware() { - - thrown.expect(IncorrectNumberOfUriKeys.class); - AAIResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "customer-id", "subscription-id"); - } -} 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); } |