From 2505a543b0e45c1c3c2fe2fb8b85664b08bf2fca Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Mon, 21 Sep 2020 11:38:23 -0400 Subject: removed references to AAIObjectType removed references to AAIObjectType and AAIObjectPlurals additional corrections for removal of aai object type corrected additional java files updated groovy files to match aai fluent builder style Issue-ID: SO-3259 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ifdf12fcacb34cc648548eb18b638afd06dad67a9 --- .../workflow/tasks/VrfValidationTest.java | 6 +- .../workflow/tasks/WorkflowActionTest.java | 19 +++--- .../orchestration/AAICollectionResourcesTest.java | 21 +++--- .../AAIConfigurationResourcesTest.java | 16 +++-- .../AAIInstanceGroupResourcesTest.java | 38 +++++------ .../orchestration/AAINetworkResourcesTest.java | 74 ++++++++++++---------- .../client/orchestration/AAIPnfResourcesTest.java | 28 ++++---- .../AAIServiceInstanceResourcesTest.java | 14 ++-- .../orchestration/AAIVfModuleResourcesTest.java | 16 ++--- .../client/orchestration/AAIVnfResourcesTest.java | 47 +++++++------- .../orchestration/AAIVolumeGroupResourcesTest.java | 14 ++-- 11 files changed, 152 insertions(+), 141 deletions(-) (limited to 'bpmn/so-bpmn-tasks/src/test') diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java index d9fb7f676c..7f9f0417ea 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java @@ -41,10 +41,10 @@ import org.onap.aai.domain.yang.RouteTargets; import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.Subnets; import org.onap.aai.domain.yang.VpnBinding; -import org.onap.so.bpmn.BaseTaskTest; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; @@ -205,7 +205,7 @@ public class VrfValidationTest extends BaseTaskTest { AAIResultWrapper networkWrapper = new AAIResultWrapper(l3Network); if (networkWrapper.getRelationships().isPresent()) { List vpnBindingUris = - networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING); + networkWrapper.getRelationships().get().getRelatedUris(Types.VPN_BINDING); VpnBinding vpnBinding = new VpnBinding(); vpnBinding.setRouteTargets(new RouteTargets()); vpnBinding.getRouteTargets().getRouteTarget().add(new RouteTarget()); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index c1970ec32c..53d1bea1f2 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -39,7 +39,6 @@ import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; @@ -78,12 +77,12 @@ import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.VolumeGroup; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.Relationships; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -1584,11 +1583,11 @@ public class WorkflowActionTest extends BaseTaskTest { when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule); doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), - eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC)); + eq(org.onap.aai.domain.yang.Vnfc.class), eq(Types.VNFC)); doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), - eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION)); doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), - eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION)); List results = SPY_workflowAction.getConfigBuildingBlocks(dataObj); @@ -1659,11 +1658,11 @@ public class WorkflowActionTest extends BaseTaskTest { when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule); doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), - eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC)); + eq(org.onap.aai.domain.yang.Vnfc.class), eq(Types.VNFC)); doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), - eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION)); doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), - eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION)); + eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION)); List results = SPY_workflowAction.getConfigBuildingBlocks(dataObj); @@ -1763,13 +1762,13 @@ public class WorkflowActionTest extends BaseTaskTest { List configurationResultWrappers = new ArrayList(); configurationResultWrappers.add(configurationWrapper); - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfc.getVnfcName())); when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper); doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(), anyObject()); org.onap.aai.domain.yang.Configuration configuration = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, - org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); + org.onap.aai.domain.yang.Configuration.class, Types.CONFIGURATION); assertEquals("testConfigurationId", configuration.getConfigurationId()); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java index 2c7ab92438..fcd44e137b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAICollectionResourcesTest.java @@ -28,18 +28,11 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.BaseTaskTest; -import org.onap.so.bpmn.common.InjectionHelper; -import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; public class AAICollectionResourcesTest extends BaseTaskTest { @@ -65,7 +58,8 @@ public class AAICollectionResourcesTest extends BaseTaskTest { assertEquals(OrchestrationStatus.INVENTORIED, networkCollection.getOrchestrationStatus()); verify(MOCK_aaiResourcesClient, times(1)).create( - eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())), + eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().collection(networkCollection.getId()))), isA(org.onap.aai.domain.yang.Collection.class)); } @@ -74,15 +68,16 @@ public class AAICollectionResourcesTest extends BaseTaskTest { doReturn(new org.onap.aai.domain.yang.Collection()).when(MOCK_aaiObjectMapper).mapCollection(networkCollection); aaiCollectionResources.updateCollection(networkCollection); verify(MOCK_aaiResourcesClient, times(1)).update( - eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId())), + eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().collection(networkCollection.getId()))), isA(org.onap.aai.domain.yang.Collection.class)); } @Test public void deleteCollectionTest() throws Exception { aaiCollectionResources.deleteCollection(networkCollection); - verify(MOCK_aaiResourcesClient, times(1)) - .delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId()))); + verify(MOCK_aaiResourcesClient, times(1)).delete(eq( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(networkCollection.getId())))); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java index 2bf177ef83..11694ff83f 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java @@ -35,6 +35,11 @@ import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -44,11 +49,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -204,7 +204,8 @@ public class AAIConfigurationResourcesTest extends TestDataSetup { @Test public void getConfigurationTest() { - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "configurationId"); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration("configurationId")); doReturn(Optional.of(new org.onap.aai.domain.yang.Configuration())).when(MOCK_aaiResourcesClient) .get(org.onap.aai.domain.yang.Configuration.class, aaiResourceUri); aaiConfigurationResources.getConfiguration("configurationId"); @@ -213,7 +214,8 @@ public class AAIConfigurationResourcesTest extends TestDataSetup { @Test public void deleteConfigurationTest() { - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "configurationId"); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration("configurationId")); doNothing().when(MOCK_aaiResourcesClient).delete(aaiResourceUri); aaiConfigurationResources.deleteConfiguration("configurationId"); verify(MOCK_aaiResourcesClient, times(1)).delete(aaiResourceUri); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java index a73cf81e75..b2978e6e62 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java @@ -36,18 +36,17 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.bpmn.common.InjectionHelper; -import org.onap.so.bpmn.common.data.TestDataSetup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel; import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.client.aai.mapper.AAIObjectMapper; @RunWith(MockitoJUnitRunner.Silent.class) @@ -83,39 +82,42 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup { .mapInstanceGroup(instanceGroup); aaiInstanceGroupResources.createInstanceGroup(instanceGroup); verify(MOCK_aaiResourcesClient, times(1)).createIfNotExists( - eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), + eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId()))), isA(Optional.class)); } @Test public void deleteInstanceGroupTest() throws Exception { aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup); - verify(MOCK_aaiResourcesClient, times(1)) - .delete(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()))); + verify(MOCK_aaiResourcesClient, times(1)).delete(eq( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())))); } @Test public void connectInstanceGroupTest() throws Exception { aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()))); + eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId()))), + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())))); } @Test public void connectInstanceGroupWithEdgeTest() throws Exception { aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())), + eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId()))), + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()))), eq(AAIEdgeLabel.BELONGS_TO)); } @Test public void existsTest() throws Exception { aaiInstanceGroupResources.exists(instanceGroup); - verify(MOCK_aaiResourcesClient, times(1)) - .exists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()))); + verify(MOCK_aaiResourcesClient, times(1)).exists(eq( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())))); } @Test @@ -135,7 +137,7 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup { @Test public void checkInstanceGroupNameInUseTrueTest() throws Exception { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroups()) .queryParam("instance-group-name", "instanceGroupName"); doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri)); boolean nameInUse = aaiInstanceGroupResources.checkInstanceGroupNameInUse("instanceGroupName"); @@ -144,7 +146,7 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup { @Test public void checkInstanceGroupNameInUseFalseTest() throws Exception { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroups()) .queryParam("instance-group-name", "instanceGroupName"); doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri)); boolean nameInUse = aaiInstanceGroupResources.checkInstanceGroupNameInUse("instanceGroupName"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java index 3bc4fc0503..535a159e10 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java @@ -46,6 +46,14 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.RouteTableReference; import org.onap.aai.domain.yang.VpnBinding; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -55,15 +63,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -167,7 +166,8 @@ public class AAINetworkResourcesTest extends TestDataSetup { new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiVpnBinding.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content); Optional oVpnBinding = Optional.empty(); - AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, "ModelInvariantUUID"); + AAIResourceUri aaiUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vpnBinding("ModelInvariantUUID")); doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class)); oVpnBinding = aaiNetworkResources.getVpnBinding(aaiUri); @@ -186,7 +186,7 @@ public class AAINetworkResourcesTest extends TestDataSetup { AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content); Optional oNetPolicy = Optional.empty(); AAIResourceUri netPolicyUri = - AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID"); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy("ModelInvariantUUID")); doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class)); oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri); @@ -204,7 +204,8 @@ public class AAINetworkResourcesTest extends TestDataSetup { new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicies.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content); Optional oNetPolicies = Optional.empty(); - AAIPluralResourceUri netPoliciesUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY); + AAIPluralResourceUri netPoliciesUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()); doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIPluralResourceUri.class)); oNetPolicies = aaiNetworkResources.getNetworkPolicies(netPoliciesUri); @@ -222,8 +223,8 @@ public class AAINetworkResourcesTest extends TestDataSetup { new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkTableRefs.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content); Optional oRtref = Optional.empty(); - AAIResourceUri rTRefUri = - AAIUriFactory.createResourceUri(AAIObjectType.ROUTE_TABLE_REFERENCE, "ModelInvariantUUID"); + AAIResourceUri rTRefUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().routeTableReference("ModelInvariantUUID")); doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class)); oRtref = aaiNetworkResources.getRouteTable(rTRefUri); @@ -310,41 +311,45 @@ public class AAINetworkResourcesTest extends TestDataSetup { public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception { aaiNetworkResources.connectNetworkToNetworkCollectionInstanceGroup(network, instanceGroup); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()))); + eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId()))), + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId())))); } @Test public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception { aaiNetworkResources.connectNetworkToNetworkCollectionServiceInstance(network, serviceInstance); verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), - eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()))); + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId())))); } @Test public void connectNetworkToCloudRegionTest() throws Exception { aaiNetworkResources.connectNetworkToCloudRegion(network, cloudRegion); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId()))); + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId()))), + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())))); } @Test public void connectNetworkToTenantTest() throws Exception { aaiNetworkResources.connectNetworkToTenant(network, cloudRegion); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()))); + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .tenant(cloudRegion.getTenantId()))), + (eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId()))))); } @Test public void connectNetworkCollectionInstanceGroupToNetworkCollectionTest() throws Exception { aaiNetworkResources.connectNetworkCollectionInstanceGroupToNetworkCollection(instanceGroup, collection); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()))); + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(collection.getId()))), + eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())))); } @Test @@ -384,9 +389,10 @@ public class AAINetworkResourcesTest extends TestDataSetup { public void connectInstanceGroupToCloudRegionTest() throws Exception { aaiNetworkResources.connectInstanceGroupToCloudRegion(instanceGroup, cloudRegion); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId())), + eq(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId()))), + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()))), eq(AAIEdgeLabel.USES)); } @@ -396,8 +402,8 @@ public class AAINetworkResourcesTest extends TestDataSetup { new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content); Optional oSubnet = Optional.empty(); - AAIResourceUri subnetUri = - AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, "ModelInvariantUUID", "serviceModelVersionId"); + AAIResourceUri subnetUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().l3Network("ModelInvariantUUID").subnet("serviceModelVersionId")); doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class)); oSubnet = aaiNetworkResources.getSubnet(subnetUri); @@ -429,8 +435,8 @@ public class AAINetworkResourcesTest extends TestDataSetup { @Test public void checkInstanceGroupNameInUseTrueTest() throws Exception { - AAIPluralResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "networkName"); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Networks()) + .queryParam("network-name", "networkName"); doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri)); boolean nameInUse = aaiNetworkResources.checkNetworkNameInUse("networkName"); assertTrue(nameInUse); @@ -438,8 +444,8 @@ public class AAINetworkResourcesTest extends TestDataSetup { @Test public void checkInstanceGroupNameInUseFalseTest() throws Exception { - AAIPluralResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "networkName"); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Networks()) + .queryParam("network-name", "networkName"); doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri)); boolean nameInUse = aaiNetworkResources.checkNetworkNameInUse("networkName"); assertFalse(nameInUse); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java index b8be045f97..8547ea53b4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java @@ -32,25 +32,25 @@ import static org.mockito.Mockito.when; import java.io.File; import java.io.IOException; import java.util.Optional; -import com.fasterxml.jackson.databind.ObjectMapper; -import joptsimple.internal.Strings; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; +import com.fasterxml.jackson.databind.ObjectMapper; +import joptsimple.internal.Strings; @RunWith(MockitoJUnitRunner.Silent.class) public class AAIPnfResourcesTest extends TestDataSetup { @@ -118,7 +118,8 @@ public class AAIPnfResourcesTest extends TestDataSetup { Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(OrchestrationStatus.INVENTORIED.toString()); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(PNF_NAME)))) + .thenReturn(Optional.of(pnfFromAai)); // when testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); verify(aaiResourcesClientMock, times(1)).update(any(), any()); @@ -131,7 +132,8 @@ public class AAIPnfResourcesTest extends TestDataSetup { org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(null); pnfTest.setRole("test"); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(PNF_NAME)))) + .thenReturn(Optional.of(pnfFromAai)); // when testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); verify(aaiResourcesClientMock, times(1)).update(any(), eq(pnfFromAai)); @@ -143,7 +145,8 @@ public class AAIPnfResourcesTest extends TestDataSetup { org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(null); Pnf pnfTest = getPnfWithTestValues(); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(PNF_NAME)))) + .thenReturn(Optional.of(pnfFromAai)); // when testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); verify(aaiResourcesClientMock, times(1)).update(any(), eq(pnfFromAai)); @@ -181,7 +184,8 @@ public class AAIPnfResourcesTest extends TestDataSetup { Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(Strings.EMPTY); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(PNF_NAME)))) + .thenReturn(Optional.of(pnfFromAai)); // when testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); } @@ -192,7 +196,8 @@ public class AAIPnfResourcesTest extends TestDataSetup { Pnf pnfTest = createPnfWithDefaultName(); org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(OrchestrationStatus.ACTIVE.toString()); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(PNF_NAME)))) + .thenReturn(Optional.of(pnfFromAai)); // when try { testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); @@ -216,7 +221,8 @@ public class AAIPnfResourcesTest extends TestDataSetup { org.onap.aai.domain.yang.Pnf pnfFromAai = new ObjectMapper().readValue(new File(path), org.onap.aai.domain.yang.Pnf.class); when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(PNF_NAME)))) + .thenReturn(Optional.of(pnfFromAai)); // when try { testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java index 9f9ac88c3c..8ccb46257d 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java @@ -39,6 +39,11 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -46,11 +51,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -195,7 +195,7 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup { @Test public void checkInstanceServiceNameInUseTrueTest() throws Exception { - AAIPluralResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE) + AAIPluralResourceUri uri = AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCES.getFragment()) .queryParam("service-instance-name", serviceInstance.getServiceInstanceName()); doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri)); boolean nameInUse = aaiServiceInstanceResources.checkInstanceServiceNameInUse(serviceInstance); @@ -204,7 +204,7 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup { @Test public void checkInstanceServiceNameInUseFalseTest() throws Exception { - AAIPluralResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE) + AAIPluralResourceUri uri = AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCES.getFragment()) .queryParam("service-instance-name", serviceInstance.getServiceInstanceName()); doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri)); boolean nameInUse = aaiServiceInstanceResources.checkInstanceServiceNameInUse(serviceInstance); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java index 3dbacd2679..7cc628266b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java @@ -38,17 +38,17 @@ import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -163,7 +163,7 @@ public class AAIVfModuleResourcesTest extends TestDataSetup { @Test public void checkNameInUseTrueTest() throws Exception { - AAIPluralResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE) + AAIPluralResourceUri vfModuleUri = AAIUriFactory.createNodesUri(Types.VF_MODULES.getFragment()) .queryParam("vf-module-name", vfModule.getVfModuleName()); AAIPluralResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id", vfModule.getModelInfoVfModule().getModelCustomizationUUID()); @@ -175,7 +175,7 @@ public class AAIVfModuleResourcesTest extends TestDataSetup { @Test public void checkNameInUseFalseIsResumeTest() throws Exception { - AAIPluralResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE) + AAIPluralResourceUri vfModuleUri = AAIUriFactory.createNodesUri(Types.VF_MODULES.getFragment()) .queryParam("vf-module-name", vfModule.getVfModuleName()); AAIPluralResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id", vfModule.getModelInfoVfModule().getModelCustomizationUUID()); @@ -186,7 +186,7 @@ public class AAIVfModuleResourcesTest extends TestDataSetup { @Test public void checkNameInUseFalseTest() throws Exception { - AAIPluralResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE) + AAIPluralResourceUri vfModuleUri = AAIUriFactory.createNodesUri(Types.VF_MODULES.getFragment()) .queryParam("vf-module-name", vfModule.getVfModuleName()); AAIPluralResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id", vfModule.getModelInfoVfModule().getModelCustomizationUUID()); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java index 7750c8ad90..bdde1a1237 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java @@ -43,15 +43,6 @@ import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.bpmn.common.InjectionHelper; -import org.onap.so.bpmn.common.data.TestDataSetup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAIRestClientImpl; import org.onap.aaiclient.client.aai.AAIValidatorImpl; @@ -59,8 +50,16 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.so.client.aai.mapper.AAIObjectMapper; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @RunWith(MockitoJUnitRunner.Silent.class) @@ -197,18 +196,19 @@ public class AAIVnfResourcesTest extends TestDataSetup { public void connectVnfToTenantTest() throws Exception { aaiVnfResources.connectVnfToTenant(genericVnf, cloudRegion); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId()))); + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .tenant(cloudRegion.getTenantId()))), + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnf.getVnfId())))); } @Test public void connectVnfToCloudRegionTest() throws Exception { aaiVnfResources.connectVnfToCloudRegion(genericVnf, cloudRegion); verify(MOCK_aaiResourcesClient, times(1)).connect( - eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())), - eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId()))); + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnf.getVnfId()))), + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())))); } @@ -244,8 +244,8 @@ public class AAIVnfResourcesTest extends TestDataSetup { @Test public void checkNameInUseTrueTest() { - AAIPluralResourceUri vnfUri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "vnfName"); + AAIPluralResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()) + .queryParam("vnf-name", "vnfName"); doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(vnfUri)); boolean nameInUse = aaiVnfResources.checkNameInUse("vnfName"); assertTrue(nameInUse); @@ -253,8 +253,8 @@ public class AAIVnfResourcesTest extends TestDataSetup { @Test public void checkNameInUseFalseTest() { - AAIPluralResourceUri vnfUri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "vnfName"); + AAIPluralResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()) + .queryParam("vnf-name", "vnfName"); doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vnfUri)); boolean nameInUse = aaiVnfResources.checkNameInUse("vnfName"); assertFalse(nameInUse); @@ -262,7 +262,8 @@ public class AAIVnfResourcesTest extends TestDataSetup { @Test public void queryVnfWrapperByIdTest() throws Exception { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId").depth(Depth.ALL); + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")).depth(Depth.ALL); final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiGenericVnf.json"))); GenericVnf genericVnf = new GenericVnf(); genericVnf.setVnfId("vnfId"); @@ -279,8 +280,8 @@ public class AAIVnfResourcesTest extends TestDataSetup { new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVserverQueryResponse.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content); Optional oVserver = Optional.empty(); - AAIResourceUri vserverUri = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, "ModelInvariantUUID", - "serviceModelVersionId", "abc", "abc"); + AAIResourceUri vserverUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion("ModelInvariantUUID", "serviceModelVersionId").tenant("abc").vserver("abc")); doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class)); oVserver = aaiVnfResources.getVserver(vserverUri); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java index 0eae6a3fdc..ada59721fe 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java @@ -37,16 +37,16 @@ import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -155,7 +155,7 @@ public class AAIVolumeGroupResourcesTest extends TestDataSetup { @Test public void checkNameInUseTrueTest() { - AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(Types.VOLUME_GROUPS.getFragment()) .queryParam("volume-group-name", "testVolumeGroupName1"); doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(volumeGroupUri)); boolean nameInUse = aaiVolumeGroupResources.checkNameInUse(volumeGroup); @@ -164,7 +164,7 @@ public class AAIVolumeGroupResourcesTest extends TestDataSetup { @Test public void checkNameInUseFalseTest() { - AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(Types.VOLUME_GROUPS.getFragment()) .queryParam("volume-group-name", "testVolumeGroupName1"); doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(volumeGroupUri)); boolean nameInUse = aaiVolumeGroupResources.checkNameInUse(volumeGroup); -- cgit 1.2.3-korg