diff options
223 files changed, 2376 insertions, 2511 deletions
diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java index 3995185f23..f326d92927 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java @@ -25,11 +25,22 @@ import java.util.LinkedList; import java.util.List; import java.util.Optional; import org.apache.logging.log4j.util.Strings; -import org.onap.aai.domain.yang.*; -import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aai.domain.yang.EsrSystemInfo; +import org.onap.aai.domain.yang.EsrSystemInfoList; +import org.onap.aai.domain.yang.EsrVnfm; +import org.onap.aai.domain.yang.EsrVnfmList; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.GenericVnfs; +import org.onap.aai.domain.yang.RelatedToProperty; +import org.onap.aai.domain.yang.Relationship; +import org.onap.aai.domain.yang.RelationshipData; +import org.onap.aai.domain.yang.RelationshipList; +import org.onap.aai.domain.yang.Vserver; 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; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.slf4j.Logger; @@ -104,7 +115,7 @@ public class AaiConnection { } private List<EsrSystemInfo> receiveVnfmInternal() { - final AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VNFM_LIST); + final AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.externalSystem().esrVnfmList()); final Optional<EsrVnfmList> response = getResourcesClient().get(EsrVnfmList.class, resourceUri); if (response.isPresent()) { @@ -127,7 +138,7 @@ public class AaiConnection { private List<EsrSystemInfo> receiveVnfmServiceUrl(final String vnfmId) { final Optional<EsrVnfm> response = getResourcesClient().get(EsrVnfm.class, - AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId).depth(Depth.ONE)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.externalSystem().esrVnfm(vnfmId)).depth(Depth.ONE)); if (response.isPresent()) { final EsrVnfm esrVnfm = response.get(); @@ -143,8 +154,8 @@ public class AaiConnection { } public String receiveGenericVnfId(final String href) { - final AAIResourceUri resourceUri = - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNFS).queryParam(SELFLINK, href); + final AAIPluralResourceUri resourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()).queryParam(SELFLINK, href); final Optional<GenericVnfs> response = getResourcesClient().get(GenericVnfs.class, resourceUri); if (response.isPresent()) { @@ -165,7 +176,7 @@ public class AaiConnection { } public String receiveVserverName(final String genericId) { - final AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericId); + final AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericId)); final Optional<GenericVnf> response = getResourcesClient().get(GenericVnf.class, resourceUri); if (response.isPresent()) { @@ -199,7 +210,7 @@ public class AaiConnection { private String receiveVserverNameFromParams(final String cloudOwner, final String cloudId, final String tenantId, final String vserverId) { final AAIResourceUri resourceUri = - AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudId, tenantId, vserverId); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudId).tenant(tenantId).vserver(vserverId)); final Optional<Vserver> response = getResourcesClient().get(Vserver.class, resourceUri); if (response.isPresent()) { diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/aai/AaiServiceProviderImpl.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/aai/AaiServiceProviderImpl.java index d9450b3472..8f95d8ab85 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/aai/AaiServiceProviderImpl.java @@ -26,8 +26,8 @@ import org.onap.aai.domain.yang.EsrVnfmList; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.Tenant; import org.slf4j.Logger; @@ -49,7 +49,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public GenericVnf invokeGetGenericVnf(final String vnfId) { return aaiClientProvider.getAaiClient() - .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + .get(GenericVnf.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))) .orElseGet(() -> { logger.debug("No vnf found in AAI with ID: {}", vnfId); return null; @@ -58,9 +59,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public GenericVnfs invokeQueryGenericVnf(final String selfLink) { - return aaiClientProvider.getAaiClient() - .get(GenericVnfs.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNFS).queryParam("selflink", selfLink)) + return aaiClientProvider.getAaiClient().get(GenericVnfs.class, AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()).queryParam("selflink", selfLink)) .orElseGet(() -> { logger.debug("No vnf found in AAI with selflink: {}", selfLink); return null; @@ -70,7 +70,9 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public EsrVnfmList invokeGetVnfms() { return aaiClientProvider.getAaiClient() - .get(EsrVnfmList.class, AAIUriFactory.createResourceUri(AAIObjectType.VNFM_LIST)).orElseGet(() -> { + .get(EsrVnfmList.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.externalSystem().esrVnfmList())) + .orElseGet(() -> { logger.debug("No VNFMs in AAI"); return null; }); @@ -79,7 +81,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public EsrVnfm invokeGetVnfm(final String vnfmId) { return aaiClientProvider.getAaiClient() - .get(EsrVnfm.class, AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId).depth(Depth.ONE)) + .get(EsrVnfm.class, AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.externalSystem().esrVnfm(vnfmId)).depth(Depth.ONE)) .orElseGet(() -> { logger.debug("VNFM not found in AAI"); return null; @@ -90,7 +93,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { public EsrSystemInfoList invokeGetVnfmEsrSystemInfoList(final String vnfmId) { return aaiClientProvider.getAaiClient() .get(EsrSystemInfoList.class, - AAIUriFactory.createResourceUri(AAIObjectType.VNFM_ESR_SYSTEM_INFO_LIST, vnfmId)) + AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.externalSystem().esrVnfm(vnfmId).esrSystemInfoList())) .orElseGet(() -> { logger.debug("VNFM ESR system info list not found in AAI"); return null; @@ -99,45 +103,47 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public void invokePatchGenericVnf(final GenericVnf vnf) { - aaiClientProvider.getAaiClient() - .update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()), vnf); + aaiClientProvider.getAaiClient().update( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())), vnf); } @Override public void invokePutGenericVnfToVnfmRelationship(final GenericVnf vnf, final String vnfmId) { - aaiClientProvider.getAaiClient().connect(AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId), - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())); + aaiClientProvider.getAaiClient().connect( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.externalSystem().esrVnfm(vnfmId)), + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()))); } @Override public void invokePutVserver(final String cloudOwner, final String cloudRegion, final String tenant, final Vserver vserver) { - aaiClientProvider.getAaiClient().create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, - cloudRegion, tenant, vserver.getVserverId()), vserver); + aaiClientProvider + .getAaiClient().create( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenant).vserver(vserver.getVserverId())), + vserver); } @Override public void invokePutVserverToVnfRelationship(final String cloudOwner, final String cloudRegion, final String tenant, final Vserver vserver, final String vnfId) { - aaiClientProvider.getAaiClient() - .connect( - AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenant, - vserver.getVserverId()), - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + aaiClientProvider.getAaiClient().connect( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenant).vserver(vserver.getVserverId())), + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))); } @Override public void invokeDeleteVserver(final String cloudOwner, final String cloudRegion, final String tenant, final String vserverId) { - aaiClientProvider.getAaiClient().delete( - AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenant, vserverId)); + aaiClientProvider.getAaiClient().delete(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenant).vserver(vserverId))); } @Override public Tenant invokeGetTenant(final String cloudOwner, final String cloudRegion, final String tenantId) { - return aaiClientProvider.getAaiClient() - .get(Tenant.class, - AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId)) + return aaiClientProvider.getAaiClient().get(Tenant.class, AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId))) .orElseGet(() -> { logger.debug("Tenant not found in AAI"); return null; @@ -147,8 +153,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public EsrSystemInfoList invokeGetCloudRegionEsrSystemInfoList(final String cloudOwner, final String cloudRegion) { return aaiClientProvider - .getAaiClient().get(EsrSystemInfoList.class, AAIUriFactory - .createResourceUri(AAIObjectType.CLOUD_ESR_SYSTEM_INFO_LIST, cloudOwner, cloudRegion)) + .getAaiClient().get(EsrSystemInfoList.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).esrSystemInfoList())) .orElseGet(() -> { logger.debug("Cloud esr system info list not found in AAI"); return null; diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/EtsiSol003AdapterControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/EtsiSol003AdapterControllerTest.java index 9aed675324..5bc4daac42 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/EtsiSol003AdapterControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/EtsiSol003AdapterControllerTest.java @@ -53,6 +53,7 @@ import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.aaiclient.client.aai.entities.uri.AAIBaseResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.EtsiPackageProvider; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.vnfm.VnfmRestTemplateConfiguration; @@ -534,7 +535,7 @@ public class EtsiSol003AdapterControllerTest { } - private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> { + private class AaiResourceUriMatcher extends BaseMatcher<AAIBaseResourceUri<?, ?>> { final String uriAsString; @@ -544,12 +545,12 @@ public class EtsiSol003AdapterControllerTest { @Override public boolean matches(final Object item) { - if (item instanceof AAIResourceUri) { + if (item instanceof AAIBaseResourceUri<?, ?>) { if (uriAsString.endsWith("...")) { - return ((AAIResourceUri) item).build().toString() + return ((AAIBaseResourceUri<?, ?>) item).build().toString() .startsWith(uriAsString.substring(0, uriAsString.indexOf("..."))); } - return ((AAIResourceUri) item).build().toString().equals(uriAsString); + return ((AAIBaseResourceUri<?, ?>) item).build().toString().equals(uriAsString); } return false; } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003GrantControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003GrantControllerTest.java index 21e56617cd..99b8c71764 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003GrantControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003GrantControllerTest.java @@ -43,7 +43,7 @@ import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIBaseResourceUri; import org.onap.so.adapters.etsisol003adapter.lcm.grant.model.GrantRequest; import org.onap.so.adapters.etsisol003adapter.lcm.grant.model.GrantRequest.OperationEnum; import org.onap.so.adapters.etsisol003adapter.lcm.grant.model.GrantsAddResources; @@ -224,7 +224,7 @@ public class Sol003GrantControllerTest { "/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm"))); } - private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> { + private class AaiResourceUriMatcher extends BaseMatcher<AAIBaseResourceUri<?, ?>> { final String uriAsString; @@ -234,12 +234,12 @@ public class Sol003GrantControllerTest { @Override public boolean matches(final Object item) { - if (item instanceof AAIResourceUri) { + if (item instanceof AAIBaseResourceUri) { if (uriAsString.endsWith("...")) { - return ((AAIResourceUri) item).build().toString() + return ((AAIBaseResourceUri<?, ?>) item).build().toString() .startsWith(uriAsString.substring(0, uriAsString.indexOf("..."))); } - return ((AAIResourceUri) item).build().toString().equals(uriAsString); + return ((AAIBaseResourceUri<?, ?>) item).build().toString().equals(uriAsString); } return false; } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003LcnControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003LcnControllerTest.java index 86eda0abfa..0d5bcd2573 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003LcnControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsisol003adapter/lcm/rest/Sol003LcnControllerTest.java @@ -54,6 +54,7 @@ import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.Vserver; import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIBaseResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.aai.AaiHelper; import org.onap.so.adapters.etsisol003adapter.lcm.extclients.aai.OamIpAddressSource; @@ -385,7 +386,7 @@ public class Sol003LcnControllerTest { genericVnf.getRelationshipList().getRelationship().add(relationshipToVserver); } - private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> { + private class AaiResourceUriMatcher extends BaseMatcher<AAIBaseResourceUri<?, ?>> { final String uriAsString; @@ -395,12 +396,12 @@ public class Sol003LcnControllerTest { @Override public boolean matches(final Object item) { - if (item instanceof AAIResourceUri) { + if (item instanceof AAIBaseResourceUri<?, ?>) { if (uriAsString.endsWith("...")) { - return ((AAIResourceUri) item).build().toString() + return ((AAIBaseResourceUri<?, ?>) item).build().toString() .startsWith(uriAsString.substring(0, uriAsString.indexOf("..."))); } - return ((AAIResourceUri) item).build().toString().equals(uriAsString); + return ((AAIBaseResourceUri<?, ?>) item).build().toString().equals(uriAsString); } return false; } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml index 01ba94ddd4..b636f6818c 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml @@ -100,6 +100,7 @@ <source>${project.basedir}/target/generated-sources/vnfmadapter/src/gen/java/main</source> <source>${project.basedir}/target/generated-sources/sol003-vnf-lcn/src/gen/java/main</source> <source>${project.basedir}/target/generated-sources/sol003-vnf-grant/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/etsisol003adapter/src/gen/java/main</source> </sources> </configuration> </execution> diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java index 3f2e5b23f2..442339d9fe 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java @@ -24,9 +24,9 @@ package org.onap.so.adapters.nssmf.extclients.aai; import org.onap.aai.domain.yang.EsrSystemInfoList; import org.onap.aai.domain.yang.EsrThirdpartySdncList; import org.onap.aai.domain.yang.ServiceInstance; -import org.onap.aaiclient.client.aai.AAIObjectType; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -47,7 +47,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public EsrThirdpartySdncList invokeGetThirdPartySdncList() { return aaiClientProvider.getAaiClient() - .get(EsrThirdpartySdncList.class, AAIUriFactory.createResourceUri(AAIObjectType.THIRDPARTY_SDNC_LIST)) + .get(EsrThirdpartySdncList.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.externalSystem().esrThirdpartySdncList())) .orElseGet(() -> { logger.debug("No VNFMs in AAI"); return null; @@ -58,7 +59,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { public EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId) { return aaiClientProvider.getAaiClient() .get(EsrSystemInfoList.class, - AAIUriFactory.createResourceUri(AAIObjectType.THIRDPARTY_SDNC_SYSTEM_INFO_LIST, sdncId)) + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.externalSystem().esrThirdpartySdnc((sdncId)))) .orElseGet(() -> { logger.debug("VNFM not found in AAI"); return null; @@ -69,8 +71,8 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { @Override public void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, String serviceInstanceId) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, - serviceType, serviceInstanceId); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); aaiClientProvider.getAaiClient().create(uri, nssiInstance); } } diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java index 67cd913b3e..f150f47f4f 100644 --- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java @@ -20,6 +20,17 @@ package org.onap.so.adapters.nssmf; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; +import static org.onap.so.beans.nsmf.NetworkType.CORE; +import static org.onap.so.beans.nsmf.ResourceSharingLevel.NON_SHARED; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.LinkedList; @@ -56,19 +67,9 @@ import org.onap.so.beans.nsmf.NssiResponse; import org.onap.so.beans.nsmf.PerfReq; import org.onap.so.beans.nsmf.PerfReqEmbb; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; -import static org.onap.so.beans.nsmf.NetworkType.CORE; -import static org.onap.so.beans.nsmf.ResourceSharingLevel.NON_SHARED; @RunWith(SpringRunner.class) public class NssmfAdapterRestTest { @@ -281,7 +282,7 @@ public class NssmfAdapterRestTest { // @Test public void testAllocateJsonSerDeSer() throws Exception { - assertEquals(marshal(allocateNssi()), ALLOCATE); + JSONAssert.assertEquals(marshal(allocateNssi()), ALLOCATE, false); NssiAllocateRequest all = unMarshal(ALLOCATE, NssiAllocateRequest.class); assertNotNull(all); assertNotNull(all.getAllocateCnNssi()); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java index 2849907e38..bb2c938940 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java @@ -5,12 +5,11 @@ import java.util.Optional; import org.onap.aai.domain.yang.CloudRegion; import org.onap.aai.domain.yang.Complex; import org.onap.aai.domain.yang.NetworkTechnologies; -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.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.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.NetworkTechnologyReference; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -68,11 +67,12 @@ public class CloudRestImpl { if (complex.isPresent()) { cloudRegion.setComplexName(complex.get().getComplexName()); } - AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, - cloudRegion.getCloudOwner(), cloudRegion.getCloudRegionId()); + AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getCloudRegionId())); getAaiClient().createIfNotExists(cloudRegionURI, Optional.of(cloudRegion)); if (complex.isPresent()) { - AAIResourceUri complexURI = AAIUriFactory.createResourceUri(AAIObjectType.COMPLEX, cloudSite.getClli()); + AAIResourceUri complexURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().complex(cloudSite.getClli())); getAaiClient().connect(cloudRegionURI, complexURI); } createCloudRegionNetworkTechnologyRelationship(cloudSite, cloudRegionURI); @@ -88,18 +88,21 @@ public class CloudRestImpl { } protected Optional<Complex> retrieveComplex(CloudSite cloudSite) { - AAIResourceUri complexURI = AAIUriFactory.createResourceUri(AAIObjectType.COMPLEX, cloudSite.getClli()); + AAIResourceUri complexURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().complex(cloudSite.getClli())); return getAaiClient().get(Complex.class, complexURI); } protected void linkCloudAndTechnology(String networkTechnologyName, AAIResourceUri cloudRegionURI) { - AAIPluralResourceUri technologyPluralUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_TECHNOLOGY) - .queryParam("network-technology-name", networkTechnologyName); + AAIPluralResourceUri technologyPluralUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().networkTechnologies()) + .queryParam("network-technology-name", networkTechnologyName); Optional<NetworkTechnologies> networkTechnology = getAaiClient().get(NetworkTechnologies.class, technologyPluralUri); if (networkTechnology.isPresent()) { - AAIResourceUri networkTechnologyURI = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_TECHNOLOGY, - networkTechnology.get().getNetworkTechnology().get(0).getNetworkTechnologyId()); + AAIResourceUri networkTechnologyURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().networkTechnology( + networkTechnology.get().getNetworkTechnology().get(0).getNetworkTechnologyId())); getAaiClient().connect(cloudRegionURI, networkTechnologyURI); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java index 1445622357..6f87b6b309 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java @@ -27,12 +27,13 @@ import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; import org.onap.aaiclient.client.aai.AAIObjectType; 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; @@ -49,20 +50,20 @@ public class AuditVServer extends AbstractAudit { public void auditVservers(AAIObjectAuditList aaiObjectAuditList) { aaiObjectAuditList.getAuditList().forEach(aaiObjectAudit -> { - boolean vserverExist = getAaiClient().exists(AAIUriFactory - .createResourceFromExistingURI(AAIObjectType.VSERVER, aaiObjectAudit.getResourceURI())); + boolean vserverExist = getAaiClient().exists( + AAIUriFactory.createResourceFromExistingURI(Types.VSERVER, aaiObjectAudit.getResourceURI())); aaiObjectAudit.setDoesObjectExist(vserverExist); }); } public Optional<AAIObjectAuditList> auditVserversThroughRelationships(String genericVnfId, String vfModuleName) { AAIObjectAuditList auditList = new AAIObjectAuditList(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, genericVnfId) - .queryParam("vf-module-name", vfModuleName); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModules()) + .queryParam("vf-module-name", vfModuleName); Optional<AAIResultWrapper> wrapper = getAaiClient().getFirstWrapper(VfModules.class, VfModule.class, uri); if (wrapper.isPresent() && wrapper.get().getRelationships().isPresent()) { - List<AAIResourceUri> relatedVservers = - wrapper.get().getRelationships().get().getRelatedUris(AAIObjectType.VSERVER); + List<AAIResourceUri> relatedVservers = wrapper.get().getRelationships().get().getRelatedUris(Types.VSERVER); if (!relatedVservers.isEmpty()) { relatedVservers.forEach(vserverUri -> { Optional<Vserver> vserver = getAaiClient().get(vserverUri).asBean(Vserver.class); @@ -70,7 +71,7 @@ public class AuditVServer extends AbstractAudit { BeanUtils.copyProperties(vserver, vServerShallow); AAIObjectAudit vServerAudit = new AAIObjectAudit(); vServerAudit.setAaiObject(vServerShallow); - vServerAudit.setAaiObjectType(AAIObjectType.VSERVER.typeName()); + vServerAudit.setAaiObjectType(Types.VSERVER.typeName()); vServerAudit.setDoesObjectExist(true); auditList.getAuditList().add(vServerAudit); }); @@ -103,8 +104,8 @@ public class AuditVServer extends AbstractAudit { String cloudRegion) { AAIObjectAuditList auditList = new AAIObjectAuditList(); AAIObjectAudit vServerAudit = new AAIObjectAudit(); - AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, - tenantId, vServer.getVserverId()); + AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vServer.getVserverId())); Vserver vServerShallow = new Vserver(); BeanUtils.copyProperties(vServer, vServerShallow, "LInterfaces"); boolean vServerExists = getAaiClient().exists(vserverURI); @@ -112,7 +113,7 @@ public class AuditVServer extends AbstractAudit { vServerAudit.setAaiObject(vServerShallow); vServerAudit.setDoesObjectExist(vServerExists); vServerAudit.setResourceURI(vserverURI.build()); - vServerAudit.setAaiObjectType(AAIObjectType.VSERVER.typeName()); + vServerAudit.setAaiObjectType(Types.VSERVER.typeName()); auditList.getAuditList().add(vServerAudit); if (vServer.getLInterfaces() != null) { vServer.getLInterfaces().getLInterface().stream().forEach(lInterface -> auditList.getAuditList().addAll( @@ -126,8 +127,9 @@ public class AuditVServer extends AbstractAudit { String cloudOwner, String cloudRegion) { AAIObjectAuditList auditList = new AAIObjectAuditList(); AAIObjectAudit lInterfaceAudit = new AAIObjectAudit(); - AAIResourceUri linterfaceURI = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, - cloudRegion, tenantId, vServerId, lInterface.getInterfaceName()); + AAIResourceUri linterfaceURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) + .tenant(tenantId).vserver(vServerId).lInterface(lInterface.getInterfaceName())); Optional<LInterface> queriedLInterface = getAaiClient().get(LInterface.class, linterfaceURI); if (queriedLInterface.isPresent()) { lInterfaceAudit.setDoesObjectExist(true); @@ -135,7 +137,7 @@ public class AuditVServer extends AbstractAudit { } lInterfaceAudit.setAaiObject(lInterface); lInterfaceAudit.setResourceURI(linterfaceURI.build()); - lInterfaceAudit.setAaiObjectType(AAIObjectType.L_INTERFACE.typeName()); + lInterfaceAudit.setAaiObjectType(Types.L_INTERFACE.typeName()); auditList.getAuditList().add(lInterfaceAudit); logger.info("l-interface id:{} name: {} exists: {} ", lInterface.getInterfaceId(), lInterface.getInterfaceName(), lInterfaceAudit.isDoesObjectExist()); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java index 3ff15ffe2f..c58e568ea4 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java @@ -37,8 +37,9 @@ import org.onap.aai.domain.yang.LInterfaces; import org.onap.aai.domain.yang.Vlan; import org.onap.aai.domain.yang.Vlans; import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectType; 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.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import org.onap.so.openstack.utils.MsoHeatUtils; @@ -260,10 +261,12 @@ public class HeatStackAudit { Vserver vServerShallow = new Vserver(); BeanUtils.copyProperties(vServer, vServerShallow); aaiObjectAudit.setAaiObject(vServerShallow); - aaiObjectAudit.setAaiObjectType(AAIObjectType.VSERVER.typeName()); - aaiObjectAudit.setResourceURI(AAIUriFactory - .createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenantId, vServer.getVserverId()) - .build()); + aaiObjectAudit.setAaiObjectType(Types.VSERVER.typeName()); + aaiObjectAudit + .setResourceURI(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vServer.getVserverId())) + .build()); return aaiObjectAudit; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 1fa757f547..c1a97cefc4 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -50,9 +50,9 @@ import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectType; 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.heatbridge.constants.HeatBridgeConstants; import org.openstack4j.model.compute.Server; import org.openstack4j.model.network.Network; @@ -82,39 +82,39 @@ public class AaiHelper { // vserver to pserver relationship if (!StringUtils.isEmpty(server.getHypervisorHostname())) { - Relationship pserverRelationship = buildRelationship( - AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, server.getHypervisorHostname())); + Relationship pserverRelationship = buildRelationship(AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().pserver(server.getHypervisorHostname()))); relationships.add(pserverRelationship); } // vserver to generic-vnf relationship - Relationship genericVnfRelationship = - buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnfId)); + Relationship genericVnfRelationship = buildRelationship( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId))); relationships.add(genericVnfRelationship); // vserver to vnfc relationship if (!StringUtils.isEmpty(server.getName())) { - Relationship vnfcRelationship = - buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VNFC, server.getName())); + Relationship vnfcRelationship = buildRelationship( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(server.getName()))); relationships.add(vnfcRelationship); } // vserver to vf-module relationship - Relationship vfModuleRelationship = - buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, genericVnfId, vfModuleId)); + Relationship vfModuleRelationship = buildRelationship(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId))); relationships.add(vfModuleRelationship); // vserver to image relationship if (server.getImage() != null) { - Relationship imageRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.IMAGE, cloudOwner, - cloudRegionId, server.getImage().getId())); + Relationship imageRel = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).image(server.getImage().getId()))); relationships.add(imageRel); } // vserver to flavor relationship if (server.getFlavor() != null) { - Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner, - cloudRegionId, server.getFlavor().getId())); + Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).flavor(server.getFlavor().getId()))); relationships.add(flavorRel); } @@ -127,20 +127,21 @@ public class AaiHelper { List<Relationship> relationships = relationshipList.getRelationship(); // sriov-vf to sriov-pf relationship - Relationship sriovPfRelationship = buildRelationship( - AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, pserverName, pIfName, pfPciId)); + Relationship sriovPfRelationship = buildRelationship(AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName).pInterface(pIfName).sriovPf(pfPciId))); relationships.add(sriovPfRelationship); return relationshipList; } public Relationship getRelationshipToVfModule(String vnfId, String vfModuleId) { - return buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)); + return buildRelationship( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId))); } public Relationship getRelationshipToTenant(String cloudOwner, String cloudRegionId, String tenantId) { - return buildRelationship( - AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegionId, tenantId)); + return buildRelationship(AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId))); } public org.onap.aai.domain.yang.Subnet buildSubnet(Subnet subnet) { diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java index 76bc8d2456..9d5a4c62b9 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/cloudregion/CloudRegionRestImplTest.java @@ -17,10 +17,10 @@ import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.CloudRegion; -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.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.data.repository.NetworkTechnologyReferenceRepository; @@ -94,7 +94,8 @@ public class CloudRegionRestImplTest { public void createCloudRegionTest() { when(catalogDbClientMock.getCloudSite("region1")).thenReturn(null); when(catalogDbClientMock.postCloudSite(cloudSite)).thenReturn(cloudSite); - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, "bob", "region1"); + AAIResourceUri uri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("bob", "region1")); cloudRestImpl.createCloudRegion(cloudSite); ArgumentCaptor<AAIResourceUri> actualURI = ArgumentCaptor.forClass(AAIResourceUri.class); ArgumentCaptor<Optional<Object>> actualCloudRegion = ArgumentCaptor.forClass(Optional.class); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java index e70b56dfc5..2e496c50cd 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditVServerTest.java @@ -41,12 +41,12 @@ import org.onap.aai.domain.yang.LInterfaces; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.Vserver; -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.AAIResultWrapper; 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.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import org.skyscreamer.jsonassert.JSONAssert; @@ -70,35 +70,43 @@ public class AuditVServerTest extends AuditVServer { private String cloudRegion = "cloudRegion"; private String tenantId = "tenantId"; - private AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, - tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4db"); + private AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db")); - private AAIResourceUri vserverURI2 = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, - tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4dz"); + private AAIResourceUri vserverURI2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz")); - private AAIResourceUri ssc_1_trusted_port_0_uri = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, - cloudOwner, cloudRegion, tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_trusted_port_0"); + private AAIResourceUri ssc_1_trusted_port_0_uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId) + .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_trusted_port_0")); - private AAIResourceUri ssc_1_service1_port_0_uri = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, - cloudOwner, cloudRegion, tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_service1_port_0"); + private AAIResourceUri ssc_1_service1_port_0_uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId) + .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_service1_port_0")); - private AAIResourceUri ssc_1_mgmt_port_1_uri = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, - cloudOwner, cloudRegion, tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_mgmt_port_1"); + private AAIResourceUri ssc_1_mgmt_port_1_uri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) + .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_mgmt_port_1")); - private AAIResourceUri ssc_1_mgmt_port_0_uri = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, - cloudOwner, cloudRegion, tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_mgmt_port_0"); + private AAIResourceUri ssc_1_mgmt_port_0_uri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) + .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_mgmt_port_0")); - private AAIResourceUri ssc_1_service2_port_0_uri = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, - cloudOwner, cloudRegion, tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_service2_port_0"); + private AAIResourceUri ssc_1_service2_port_0_uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId) + .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_service2_port_0")); - private AAIResourceUri ssc_1_int_ha_port_0_uri = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, - cloudOwner, cloudRegion, tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4db", "ssc_1_int_ha_port_0"); + private AAIResourceUri ssc_1_int_ha_port_0_uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId) + .vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4db").lInterface("ssc_1_int_ha_port_0")); - private AAIResourceUri test_port_1_uri = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, - cloudRegion, tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4dz", "test_port_1"); + private AAIResourceUri test_port_1_uri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) + .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz").lInterface("test_port_1")); - private AAIResourceUri test_port_2_uri = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, - cloudRegion, tenantId, "3a4c2ca5-27b3-4ecc-98c5-06804867c4dz", "test_port_2"); + private AAIResourceUri test_port_2_uri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) + .tenant(tenantId).vserver("3a4c2ca5-27b3-4ecc-98c5-06804867c4dz").lInterface("test_port_2")); private AAIResourceUri service2_sub_1_uri = AAIUriFactory.createResourceUri(AAIObjectType.SUB_L_INTERFACE, cloudOwner, cloudRegion, tenantId, @@ -368,17 +376,20 @@ public class AuditVServerTest extends AuditVServer { Vserver vserver = new Vserver(); vserver.setVserverId("testVserverId"); obj1.setAaiObject(vserver); - obj1.setResourceURI(AAIUriFactory - .createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenantId, "testVserverId").build()); + obj1.setResourceURI( + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId")) + .build()); auditList.getAuditList().add(obj1); - doReturn(false).when(aaiResourcesMock).exists(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, - cloudRegion, tenantId, "testVserverId")); + doReturn(false).when(aaiResourcesMock).exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId"))); auditNova.auditVservers(auditList); - Mockito.verify(aaiResourcesMock).exists(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, - cloudRegion, tenantId, "testVserverId")); + Mockito.verify(aaiResourcesMock).exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver("testVserverId"))); Assert.assertEquals(false, auditList.getAuditList().get(0).isDoesObjectExist()); } @@ -392,8 +403,8 @@ public class AuditVServerTest extends AuditVServer { AAIResultWrapper wrapper = new AAIResultWrapper(vfModule); doReturn(Optional.of(wrapper)).when(aaiResourcesMock).getFirstWrapper(VfModules.class, VfModule.class, - AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "genericVnfId").queryParam("vf-module-name", - "vfModuleName")); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("genericVnfId").vfModules()) + .queryParam("vf-module-name", "vfModuleName")); Optional<AAIObjectAuditList> auditList = auditNova.auditVserversThroughRelationships("genericVnfId", "vfModuleName"); @@ -410,11 +421,12 @@ public class AuditVServerTest extends AuditVServer { AAIResultWrapper vserverWrapper = new AAIResultWrapper(new Vserver()); doReturn(Optional.of(wrapper)).when(aaiResourcesMock).getFirstWrapper(VfModules.class, VfModule.class, - AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "genericVnfId").queryParam("vf-module-name", - "vfModuleName")); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("genericVnfId").vfModules()) + .queryParam("vf-module-name", "vfModuleName")); - doReturn(vserverWrapper).when(aaiResourcesMock).get(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, - "cloud-owner", "cloud-region-id", "tenant-id", "VUSCHGA1")); + doReturn(vserverWrapper).when(aaiResourcesMock) + .get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion("cloud-owner", "cloud-region-id").tenant("tenant-id").vserver("VUSCHGA1"))); Optional<AAIObjectAuditList> auditList = auditNova.auditVserversThroughRelationships("genericVnfId", "vfModuleName"); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index cea436b799..110faaf8ab 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -45,7 +45,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.mockito.Mockito.doReturn; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; @@ -66,20 +65,17 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.L3InterfaceIpv6AddressList; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.SriovPf; import org.onap.aaiclient.client.aai.AAIDSLQueryClient; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; 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.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; import org.onap.so.cloud.resource.beans.NodeType; import org.onap.so.db.catalog.beans.CloudIdentity; @@ -105,7 +101,6 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; -import inet.ipaddr.IPAddressString; @RunWith(MockitoJUnitRunner.Silent.class) @@ -202,10 +197,10 @@ public class HeatBridgeImplTest { verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); List<AAIResourceUri> uris = captor.getAllValues(); - assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, - server1.getId()), uris.get(0)); - assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, - server2.getId()), uris.get(1)); + assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server1.getId())), uris.get(0)); + assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server2.getId())), uris.get(1)); } @@ -246,10 +241,10 @@ public class HeatBridgeImplTest { verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); List<AAIResourceUri> uris = captor.getAllValues(); - assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, - server1.getId()), uris.get(0)); - assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, - server2.getId()), uris.get(1)); + assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server1.getId())), uris.get(0)); + assertEquals(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(CLOUD_OWNER, REGION_ID).tenant(TENANT_ID).vserver(server2.getId())), uris.get(1)); } @Test diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java index 85442675c0..e081902381 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java @@ -25,10 +25,10 @@ package org.onap.so.asdc.tenantIsolation; import java.util.HashMap; import java.util.List; import java.util.Map; -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.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.data.repository.ServiceRepository; @@ -183,8 +183,8 @@ public class WatchdogDistribution { - AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, serviceModelInvariantUUID, - serviceModelVersionId); + AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation() + .model(serviceModelInvariantUUID).modelVer(serviceModelVersionId)); aaiUri.depth(Depth.ZERO); // Do not return relationships if any logger.debug("Target A&AI Resource URI: {}", aaiUri.build().toString()); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index d85c387029..fe3686713a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -22,25 +22,24 @@ package org.onap.so.bpmn.common.scripts -import org.onap.so.logger.LoggingAnchor -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.logging.filter.base.ErrorCode - import static org.apache.commons.lang3.StringUtils.isBlank; - import javax.ws.rs.NotFoundException import javax.ws.rs.core.UriBuilder - import org.apache.commons.lang.StringUtils import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.client.PreconditionFailedException import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.logging.filter.base.ErrorCode +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.PreconditionFailedException +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -115,7 +114,7 @@ class AllottedResourceUtils { public boolean ifExistsAR(DelegateExecution execution, String allottedResourceId) { logger.trace("ifExistsAR ") try { - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment(allottedResourceId)) AAIResultWrapper wrapper = getAAIClient().get(resourceUri) Optional<AllottedResource> allottedResource = wrapper.asBean(AllottedResource.class) if(allottedResource.isPresent()) { @@ -150,7 +149,7 @@ class AllottedResourceUtils { Optional<AllottedResource> allottedResource = Optional.empty() try { logger.debug("GET AR Aai Path is: \n" + link) - AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(link).build()) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(Types.ALLOTTED_RESOURCE, UriBuilder.fromPath(link).build()) allottedResource = getAAIClient().get(AllottedResource.class,uri); if(allottedResource.isPresent()) { if (!isBlank(role)) { @@ -193,7 +192,7 @@ class AllottedResourceUtils { allottedResource.setOrchestrationStatus(status) logger.debug('AAI AR URI: ' + aaiARPath) - AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build()) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(Types.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build()) getAAIClient().update(uri,allottedResource) }catch(Exception e){ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), @@ -208,7 +207,7 @@ class AllottedResourceUtils { logger.trace(" deleteAR - aaiARPath:" + aaiARPath) try { - AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build()) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(Types.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build()) getAAIClient().delete(uri); }catch(NotFoundException ex){ logger.debug(" Delete AR Received a Not Found (404) Response") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy index c5a0e46fe5..2f09ca2aa0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy @@ -29,6 +29,8 @@ import org.onap.aai.domain.yang.VolumeGroup import org.onap.aaiclient.client.aai.AAIObjectType 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.constants.Defaults import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor @@ -74,7 +76,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ execution.setVariable("CVGN_volumeGroupName", volumeGroupName) execution.setVariable("CVGN_aicCloudRegion", aicCloudRegion) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId)) execution.setVariable("CVGN_volumeGroupGetEndpoint", uri) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index f5cf541076..fce9286164 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -31,6 +31,7 @@ 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.logging.filter.base.ErrorCode import org.onap.so.constants.Defaults import org.onap.so.logger.LoggingAnchor @@ -62,7 +63,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ String incomingGroupName = execution.getVariable("volumeGroupName") String incomingTenantId = execution.getVariable("tenantId") String aicCloudRegion = execution.getVariable("aicCloudRegion") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId)) AAIResultWrapper wrapper = getAAIClient().get(uri); Optional<VolumeGroup> volumeGroup = wrapper.asBean(VolumeGroup.class) Optional<Relationships> relationships = wrapper.getRelationships() @@ -70,7 +71,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ execution.setVariable("queryAAIVolumeGroupResponse", volumeGroup.get()) String volumeGroupTenantId = "" if(relationships.isPresent()){ - List<AAIResourceUri> tenantUris = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) + List<AAIResourceUri> tenantUris = relationships.get().getRelatedUris(Types.TENANT) for (AAIResourceUri tenantURI: tenantUris){ volumeGroupTenantId = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy index 9758c126a9..40b9388418 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -26,14 +26,13 @@ import org.apache.commons.lang.StringUtils import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.GenericVnfs -import org.onap.so.bpmn.core.RollbackData -import org.onap.aaiclient.client.aai.AAIObjectPlurals -import org.onap.aaiclient.client.aai.AAIObjectType 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.graphinventory.entities.uri.Depth -import org.onap.so.db.catalog.beans.OrchestrationStatus import org.onap.logging.filter.base.ErrorCode +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.db.catalog.beans.OrchestrationStatus import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger @@ -154,9 +153,9 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ def vnfName = execution.getVariable("CAAIVfMod_vnfName") Optional<GenericVnf> genericVnfOp if (vnfId == null || vnfId.isEmpty()) { - genericVnfOp = getAAIClient().getFirst(GenericVnfs.class, GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE)) + genericVnfOp = getAAIClient().getFirst(GenericVnfs.class, GenericVnf.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()).queryParam("vnf-name", vnfName).depth(Depth.ONE)) } else { - genericVnfOp = getAAIClient().get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + genericVnfOp = getAAIClient().get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))) } try { if(genericVnfOp.isPresent()){ @@ -214,7 +213,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ genericVnf.setModelVersionId(execution.getVariable("CAAIVfMod_vnfPersonaVer")) try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, newVnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(newVnfId)) getAAIClient().create(uri,genericVnf) execution.setVariable("CAAIVfMod_createGenericVnfResponseCode", 201) execution.setVariable("CAAIVfMod_createGenericVnfResponse", "Vnf Created") @@ -266,7 +265,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, newModuleId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(newModuleId)) getAAIClient().create(uri,vfModule) def statusCode = 201 execution.setVariable("CAAIVfMod_createVfModuleResponseCode", statusCode) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy index 8a74307df6..511cd8d6e6 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy @@ -27,6 +27,8 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aaiclient.client.aai.AAIObjectType 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.slf4j.Logger import org.slf4j.LoggerFactory @@ -111,7 +113,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('CAAIVfModVG_vnfId') def vfModuleId = execution.getVariable('CAAIVfModVG_vfModuleId') try { - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)); Optional<org.onap.aai.domain.yang.VfModule> vfModule = getAAIClient().get(org.onap.aai.domain.yang.VfModule.class, resourceUri) if(vfModule.isPresent()){ execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', 200) @@ -164,8 +166,8 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { def volumeGroupId = execution.getVariable('CAAIVfModVG_volumeGroupId') try { - AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId,vfModuleId); - AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, aicCloudRegion,volumeGroupId); + AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)); + AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, aicCloudRegion).volumeGroup(volumeGroupId)); logger.debug("Creating relationship between Vf Module: " + vfModuleUri.build().toString() + " and Volume Group: " + volumeGroupUri.build().toString()) getAAIClient().connect(vfModuleUri,volumeGroupUri) execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', 200) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy index 8c6ebefc49..02d0cd0287 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -28,6 +28,8 @@ import org.onap.aai.domain.yang.GenericVnf import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum @@ -83,7 +85,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ try { AaiUtil aaiUriUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) uri.depth(Depth.ONE) Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class, uri) @@ -109,7 +111,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ try { String vnfId = execution.getVariable("DAAIVfMod_vnfId") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) getAAIClient().delete(uri) execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", 200) execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", "Vnf Deleted") @@ -126,7 +128,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ String vnfId = execution.getVariable("DAAIVfMod_vnfId") String vfModuleId = execution.getVariable("DAAIVfMod_vfModuleId") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)) getAAIClient().delete(uri) execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", 200) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy index 9593aa15be..63dd9af117 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -41,6 +41,8 @@ import org.onap.so.client.HttpClient import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.logging.filter.base.ONAPComponents; import org.onap.so.logger.MessageEnum @@ -85,7 +87,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ def personaModelId = execution.getVariable('personaModelId') AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) uri.depth(Depth.ONE) String endPoint = aaiUtil.createAaiUri(uri) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy index 051f69381a..f7fbc3a371 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy @@ -35,6 +35,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.aaiclient.client.graphinventory.entities.uri.Depth import org.springframework.web.util.UriUtils import org.onap.so.logger.MessageEnum @@ -123,7 +125,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.ONE), NotFoundException.class) GenericVnf responseData = wrapper.asBean(GenericVnf.class).get() @@ -167,7 +169,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { def vnfName = genericVnf.getVnfName() execution.setVariable('PUAAIVfMod_vnfName', vnfName) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)) AAIResourcesClient resourceClient = new AAIResourcesClient() @@ -224,7 +226,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { vfModule.setOrchestrationStatus(orchestrationStatus) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)) client.update(uri, vfModule) execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 200) // Set the output for this flow. The updated VfModule is an output, the generic VNF name, and for diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 9a78472540..b68bf7bfab 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -30,6 +30,8 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum @@ -134,7 +136,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { try { def vnfId = execution.getVariable('UAAIGenVnf_vnfId') - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) uri.depth(Depth.ONE) try { Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri) @@ -223,7 +225,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { payload.setManagementV6Address(managementV6AddressEntry) payload.setOrchestrationStatus(orchestrationStatusEntry) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) try { getAAIClient().update(uri,payload) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy index 20f9721b2e..a8a289d4cb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -30,6 +30,8 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.aaiclient.client.aai.AAIObjectType 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.slf4j.Logger import org.slf4j.LoggerFactory @@ -106,7 +108,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('UAAIVfMod_vnfId') def vfModuleId = execution.getVariable('UAAIVfMod_vfModuleId') try { - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)); Optional<org.onap.aai.domain.yang.VfModule> vfModule = getAAIClient().get(org.onap.aai.domain.yang.VfModule.class, resourceUri) if (vfModule.isPresent()) { execution.setVariable('UAAIVfMod_getVfModuleResponseCode', 200) @@ -185,7 +187,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { payload.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdnEntry) try { - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)) getAAIClient().update(resourceUri, payload) execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 200) execution.setVariable('UAAIVfMod_updateVfModuleResponse', "Success") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index b181a60f74..8923051f84 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -35,12 +35,12 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.javatuples.Pair; import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -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.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -54,6 +54,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -62,7 +63,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; @@ -496,7 +496,7 @@ public class BBInputSetup implements JavaDelegate { } protected Vnfc getVnfcToConfiguration(String vnfcName) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfcName); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName)); Optional<org.onap.aai.domain.yang.Vnfc> vnfcOp = bbInputSetupUtils.getAAIResourceDepthOne(uri).asBean(org.onap.aai.domain.yang.Vnfc.class); if (vnfcOp.isPresent()) { @@ -1883,15 +1883,13 @@ public class BBInputSetup implements JavaDelegate { } private void mapRelationship(ServiceInstance serviceInstance, Relationships relationships) { - this.mapProject(relationships.getByType(AAIObjectType.PROJECT, uri -> uri.nodesOnly(true)), serviceInstance); - this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY, uri -> uri.nodesOnly(true)), - serviceInstance); - this.mapL3Networks(relationships.getRelatedAAIUris(AAIObjectType.L3_NETWORK), serviceInstance.getNetworks()); - this.mapGenericVnfs(relationships.getRelatedAAIUris(AAIObjectType.GENERIC_VNF), serviceInstance.getVnfs()); - this.mapPnfs(relationships.getRelatedAAIUris(AAIObjectType.PNF), serviceInstance.getPnfs()); - this.mapCollection(relationships.getByType(AAIObjectType.COLLECTION), serviceInstance); - this.mapConfigurations(relationships.getRelatedAAIUris(AAIObjectType.CONFIGURATION), - serviceInstance.getConfigurations()); + this.mapProject(relationships.getByType(Types.PROJECT, uri -> uri.nodesOnly(true)), serviceInstance); + this.mapOwningEntity(relationships.getByType(Types.OWNING_ENTITY, uri -> uri.nodesOnly(true)), serviceInstance); + this.mapL3Networks(relationships.getRelatedUris(Types.L3_NETWORK), serviceInstance.getNetworks()); + this.mapGenericVnfs(relationships.getRelatedUris(Types.GENERIC_VNF), serviceInstance.getVnfs()); + this.mapPnfs(relationships.getRelatedUris(Types.PNF), serviceInstance.getPnfs()); + this.mapCollection(relationships.getByType(Types.COLLECTION), serviceInstance); + this.mapConfigurations(relationships.getRelatedUris(Types.CONFIGURATION), serviceInstance.getConfigurations()); } protected void mapConfigurations(List<AAIResourceUri> relatedAAIUris, List<Configuration> configurations) { @@ -1930,11 +1928,10 @@ public class BBInputSetup implements JavaDelegate { Optional<Relationships> relationshipsOp = aaiGenericVnfWrapper.getRelationships(); if (relationshipsOp.isPresent()) { Relationships relationships = relationshipsOp.get(); - this.mapPlatform(relationships.getByType(AAIObjectType.PLATFORM), genericVnf); - this.mapLineOfBusiness(relationships.getByType(AAIObjectType.LINE_OF_BUSINESS), genericVnf); - genericVnf.getVolumeGroups().addAll(mapVolumeGroups(relationships.getByType(AAIObjectType.VOLUME_GROUP))); - genericVnf.getInstanceGroups() - .addAll(mapInstanceGroups(relationships.getByType(AAIObjectType.INSTANCE_GROUP))); + this.mapPlatform(relationships.getByType(Types.PLATFORM), genericVnf); + this.mapLineOfBusiness(relationships.getByType(Types.LINE_OF_BUSINESS), genericVnf); + genericVnf.getVolumeGroups().addAll(mapVolumeGroups(relationships.getByType(Types.VOLUME_GROUP))); + genericVnf.getInstanceGroups().addAll(mapInstanceGroups(relationships.getByType(Types.INSTANCE_GROUP))); } return genericVnf; @@ -2041,8 +2038,7 @@ public class BBInputSetup implements JavaDelegate { } private void setInstanceGroupForCollection(Collection collection, Relationships relationships) { - List<InstanceGroup> instanceGroupsList = - mapInstanceGroups(relationships.getByType(AAIObjectType.INSTANCE_GROUP)); + List<InstanceGroup> instanceGroupsList = mapInstanceGroups(relationships.getByType(Types.INSTANCE_GROUP)); if (!instanceGroupsList.isEmpty()) { collection.setInstanceGroup(instanceGroupsList.get(0)); } @@ -2079,9 +2075,8 @@ public class BBInputSetup implements JavaDelegate { Optional<Relationships> relationshipsOp = aaiNetworkWrapper.getRelationships(); if (relationshipsOp.isPresent()) { Relationships relationships = relationshipsOp.get(); - this.mapNetworkPolicies(relationships.getByType(AAIObjectType.NETWORK_POLICY), - network.getNetworkPolicies()); - mapRouteTableReferences(relationships.getByType(AAIObjectType.ROUTE_TABLE_REFERENCE), + this.mapNetworkPolicies(relationships.getByType(Types.NETWORK_POLICY), network.getNetworkPolicies()); + mapRouteTableReferences(relationships.getByType(Types.ROUTE_TABLE_REFERENCE), network.getContrailNetworkRouteTableReferences()); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 4e0b5634ea..9205cae5ed 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -43,19 +43,20 @@ import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; import org.onap.aai.domain.yang.VpnBinding; -import org.onap.so.bpmn.common.InjectionHelper; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; -import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; -import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; -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.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.uri.AAIFluentSingleType; 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; @@ -237,7 +238,7 @@ public class BBInputSetupUtils { } public Map<String, String> getURIKeysFromServiceInstance(String serviceInstanceId) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); return uri.getURIKeys(); } @@ -266,8 +267,10 @@ public class BBInputSetupUtils { String cloudRegionId = cloudConfiguration.getLcpCloudRegionId(); String cloudOwner = cloudConfiguration.getCloudOwner(); if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) { - return injectionHelper.getAaiClient().get(CloudRegion.class, AAIUriFactory - .createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, cloudRegionId).depth(Depth.TWO)) + return injectionHelper.getAaiClient() + .get(CloudRegion.class, AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId)) + .depth(Depth.TWO)) .orElse(null); } else { @@ -279,13 +282,17 @@ public class BBInputSetupUtils { } public InstanceGroup getAAIInstanceGroup(String instanceGroupId) { - return injectionHelper.getAaiClient().get(InstanceGroup.class, - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId)).orElse(null); + return injectionHelper.getAaiClient() + .get(InstanceGroup.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroupId))) + .orElse(null); } public org.onap.aai.domain.yang.Customer getAAICustomer(String globalSubscriberId) { - return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Customer.class, - AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId)).orElse(null); + return injectionHelper.getAaiClient() + .get(org.onap.aai.domain.yang.Customer.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId))) + .orElse(null); } public ServiceSubscription getAAIServiceSubscription(String globalSubscriberId, String subscriptionServiceType) { @@ -294,8 +301,9 @@ public class BBInputSetupUtils { || subscriptionServiceType.equals("")) { return null; } else { - return injectionHelper.getAaiClient().get(ServiceSubscription.class, AAIUriFactory - .createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId, subscriptionServiceType)) + return injectionHelper + .getAaiClient().get(ServiceSubscription.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType))) .orElse(null); } @@ -304,25 +312,25 @@ public class BBInputSetupUtils { public ServiceInstance getAAIServiceInstanceById(String serviceInstanceId) { return injectionHelper.getAaiClient() .get(ServiceInstance.class, AAIUriFactory - .createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId).depth(Depth.TWO)) + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)).depth(Depth.TWO)) .orElse(null); } protected ServiceInstance getAAIServiceInstanceByIdAndCustomer(String globalCustomerId, String serviceType, String serviceInstanceId) { - return injectionHelper.getAaiClient().get(ServiceInstance.class, AAIUriFactory - .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId) - .depth(Depth.TWO)).orElse(null); + return injectionHelper.getAaiClient().get(ServiceInstance.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustomerId) + .serviceSubscription(serviceType).serviceInstance(serviceInstanceId)).depth(Depth.TWO)) + .orElse(null); } public org.onap.aai.domain.yang.ServiceInstance getAAIServiceInstanceByName(String serviceInstanceName, Customer customer) throws Exception { - Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstance = - injectionHelper.getAaiClient() - .getOne(ServiceInstances.class, org.onap.aai.domain.yang.ServiceInstance.class, AAIUriFactory - .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(), - customer.getServiceSubscription().getServiceType()) - .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)); + Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstance = injectionHelper.getAaiClient().getOne( + ServiceInstances.class, org.onap.aai.domain.yang.ServiceInstance.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription(customer.getServiceSubscription().getServiceType()).serviceInstances()) + .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)); return aaiServiceInstance.orElse(null); } @@ -331,7 +339,9 @@ public class BBInputSetupUtils { String serviceInstanceName) { return injectionHelper.getAaiClient().getOne(ServiceInstances.class, ServiceInstance.class, - AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, globalCustomerId, serviceType) + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustomerId) + .serviceSubscription(serviceType).serviceInstances()) .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)); } @@ -356,43 +366,46 @@ public class BBInputSetupUtils { } public Configuration getAAIConfiguration(String configurationId) { - return this.getConcreteAAIResource(Configuration.class, AAIObjectType.CONFIGURATION, configurationId); + return this.getConcreteAAIResource(Configuration.class, + AAIFluentTypeBuilder.network().configuration(configurationId)); } public GenericVnf getAAIGenericVnf(String vnfId) { - return getConcreteAAIResource(GenericVnf.class, AAIObjectType.GENERIC_VNF, vnfId); + return getConcreteAAIResource(GenericVnf.class, AAIFluentTypeBuilder.network().genericVnf(vnfId)); } public VpnBinding getAAIVpnBinding(String vpnBindingId) { - return getConcreteAAIResource(VpnBinding.class, AAIObjectType.VPN_BINDING, vpnBindingId); + return getConcreteAAIResource(VpnBinding.class, AAIFluentTypeBuilder.network().vpnBinding(vpnBindingId)); } public VolumeGroup getAAIVolumeGroup(String cloudOwnerId, String cloudRegionId, String volumeGroupId) { - return getConcreteAAIResource(VolumeGroup.class, AAIObjectType.VOLUME_GROUP, cloudOwnerId, cloudRegionId, - volumeGroupId); + return getConcreteAAIResource(VolumeGroup.class, AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwnerId, cloudRegionId).volumeGroup(volumeGroupId)); } public VfModule getAAIVfModule(String vnfId, String vfModuleId) { - return getConcreteAAIResource(VfModule.class, AAIObjectType.VF_MODULE, vnfId, vfModuleId); + return getConcreteAAIResource(VfModule.class, + AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)); } public L3Network getAAIL3Network(String networkId) { - return getConcreteAAIResource(L3Network.class, AAIObjectType.L3_NETWORK, networkId); + return getConcreteAAIResource(L3Network.class, AAIFluentTypeBuilder.network().l3Network(networkId)); } - private <T> T getConcreteAAIResource(Class<T> clazz, AAIObjectType objectType, Object... ids) { - return injectionHelper.getAaiClient() - .get(clazz, AAIUriFactory.createResourceUri(objectType, ids).depth(Depth.ONE)).orElseGet(() -> { - logger.debug("No resource of type: {} matched by ids: {}", objectType.typeName(), - Arrays.toString(ids)); + private <T> T getConcreteAAIResource(Class<T> clazz, AAIFluentSingleType type) { + return injectionHelper.getAaiClient().get(clazz, AAIUriFactory.createResourceUri(type).depth(Depth.ONE)) + .orElseGet(() -> { + logger.debug("No resource of type: {} matched by ids: {}", type.build().typeName(), + Arrays.toString(type.values())); return null; }); } public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId) throws Exception { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId) - .relatedTo(AAIObjectPlurals.SERVICE_INSTANCE); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroupId)) + .relatedTo(Types.SERVICE_INSTANCES.getFragment()); Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri); ServiceInstance serviceInstance = null; if (!serviceInstances.isPresent()) { @@ -414,8 +427,9 @@ public class BBInputSetupUtils { public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws MultipleObjectsFoundException { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - .relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + .relatedTo(Types.L3_NETWORKS.getFragment()).queryParam("network-name", networkName); Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri); L3Network network = null; if (!networks.isPresent()) { @@ -435,34 +449,37 @@ public class BBInputSetupUtils { } public Optional<GenericVnf> getRelatedVnfByNameFromServiceInstance(String serviceInstanceId, String vnfName) { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - .relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + .relatedTo(Types.GENERIC_VNFS.getFragment()).queryParam("vnf-name", vnfName); return injectionHelper.getAaiClient().getOne(GenericVnfs.class, GenericVnf.class, uri); } public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVnf(String vnfId, String volumeGroupName) { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - .relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) + .relatedTo(Types.VOLUME_GROUPS.getFragment()).queryParam("volume-group-name", volumeGroupName); return injectionHelper.getAaiClient().getOne(VolumeGroups.class, VolumeGroup.class, uri); } public Optional<VolumeGroup> getRelatedVolumeGroupByIdFromVnf(String vnfId, String volumeGroupId) { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - .relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-id", volumeGroupId); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) + .relatedTo(Types.VOLUME_GROUPS.getFragment()).queryParam("volume-group-id", volumeGroupId); return injectionHelper.getAaiClient().getOne(VolumeGroups.class, VolumeGroup.class, uri); } public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVfModule(String vnfId, String vfModuleId, String volumeGroupName) throws Exception { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - .relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)) + .relatedTo(Types.VOLUME_GROUPS.getFragment()).queryParam("volume-group-name", volumeGroupName); return injectionHelper.getAaiClient().getOne(VolumeGroups.class, VolumeGroup.class, uri); } public Optional<VolumeGroup> getRelatedVolumeGroupFromVfModule(String vnfId, String vfModuleId) throws Exception { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - .relatedTo(AAIObjectPlurals.VOLUME_GROUP); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)) + .relatedTo(Types.VOLUME_GROUPS.getFragment()); return injectionHelper.getAaiClient().getOne(VolumeGroups.class, VolumeGroup.class, uri); } @@ -470,9 +487,9 @@ public class BBInputSetupUtils { org.onap.aai.domain.yang.L3Network aaiLocalNetwork) { AAIResultWrapper networkWrapper = new AAIResultWrapper(aaiLocalNetwork); if (networkWrapper.getRelationships().isPresent() - && !networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING).isEmpty()) { + && !networkWrapper.getRelationships().get().getRelatedUris(Types.VPN_BINDING).isEmpty()) { return getAAIResourceDepthOne( - networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING).get(0)) + networkWrapper.getRelationships().get().getRelatedUris(Types.VPN_BINDING).get(0)) .asBean(org.onap.aai.domain.yang.VpnBinding.class); } return Optional.empty(); @@ -481,7 +498,7 @@ public class BBInputSetupUtils { public ServiceInstances getAAIServiceInstancesGloballyByName(String serviceInstanceName) { return injectionHelper.getAaiClient() - .get(ServiceInstances.class, AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE) + .get(ServiceInstances.class, AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCES.getFragment()) .queryParam("service-instance-name", serviceInstanceName)) .orElseGet(() -> { logger.debug("No Service Instance matched by name"); @@ -491,26 +508,27 @@ public class BBInputSetupUtils { public boolean existsAAINetworksGloballyByName(String networkName) { - AAIPluralResourceUri l3networkUri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); + AAIPluralResourceUri l3networkUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Networks()) + .queryParam("network-name", networkName); AAIResourcesClient aaiRC = injectionHelper.getAaiClient(); return aaiRC.exists(l3networkUri); } public boolean existsAAIVfModuleGloballyByName(String vfModuleName) { AAIPluralResourceUri vfModuleUri = - AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE).queryParam("vf-module-name", vfModuleName); + AAIUriFactory.createNodesUri(Types.VF_MODULES.getFragment()).queryParam("vf-module-name", vfModuleName); return injectionHelper.getAaiClient().exists(vfModuleUri); } public boolean existsAAIConfigurationGloballyByName(String configurationName) { - AAIPluralResourceUri configUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) - .queryParam("configuration-name", configurationName); + AAIPluralResourceUri configUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configurations()) + .queryParam("configuration-name", configurationName); return injectionHelper.getAaiClient().exists(configUri); } public boolean existsAAIVolumeGroupGloballyByName(String volumeGroupName) { - AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(Types.VOLUME_GROUPS.getFragment()) .queryParam("volume-group-name", volumeGroupName); return injectionHelper.getAaiClient().exists(volumeGroupUri); } @@ -519,7 +537,7 @@ public class BBInputSetupUtils { return injectionHelper.getAaiClient() .get(GenericVnfs.class, - AAIUriFactory.createNodesUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)) + AAIUriFactory.createNodesUri(Types.GENERIC_VNFS.getFragment()).queryParam("vnf-name", vnfName)) .orElseGet(() -> { logger.debug("No GenericVnfs matched by name"); return null; @@ -528,8 +546,9 @@ public class BBInputSetupUtils { public Optional<Configuration> getRelatedConfigurationByNameFromServiceInstance(String serviceInstanceId, String configurationName) { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - .relatedTo(AAIObjectPlurals.CONFIGURATION).queryParam("configuration-name", configurationName); + AAIPluralResourceUri uri = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + .relatedTo(Types.CONFIGURATIONS.getFragment()).queryParam("configuration-name", configurationName); return injectionHelper.getAaiClient().getOne(Configurations.class, Configuration.class, uri); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java index c7e3234a56..cae18a1da0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java @@ -24,14 +24,14 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import java.util.List; import java.util.Optional; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -88,8 +88,8 @@ public class CloudInfoFromAAI { protected Optional<CloudRegion> getRelatedCloudRegionAndTenant(Relationships relationships) { CloudRegion cloudRegion = new CloudRegion(); - List<AAIResultWrapper> cloudRegions = relationships.getByType(AAIObjectType.CLOUD_REGION); - List<AAIResultWrapper> tenants = relationships.getByType(AAIObjectType.TENANT); + List<AAIResultWrapper> cloudRegions = relationships.getByType(Types.CLOUD_REGION); + List<AAIResultWrapper> tenants = relationships.getByType(Types.TENANT); if (!cloudRegions.isEmpty()) { AAIResultWrapper cloudRegionWrapper = cloudRegions.get(0); Optional<org.onap.aai.domain.yang.CloudRegion> aaiCloudRegionOp = diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index 948c9326d8..843cca0848 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -30,6 +30,9 @@ import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.Vserver; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.onap.logging.filter.base.ErrorCode; import org.onap.logging.filter.base.ONAPComponents; import org.onap.logging.filter.base.ONAPComponentsList; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -38,9 +41,6 @@ import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; -import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.objects.audit.AAIObjectAudit; @@ -280,20 +280,19 @@ public class ExceptionBuilder { + auditList.getAuditType() + "d in AAI: "); Stream<AAIObjectAudit> vServerLInterfaceAuditStream = auditList.getAuditList().stream() - .filter(auditObject -> auditObject.getAaiObjectType().equals(AAIObjectType.VSERVER.typeName()) - || auditObject.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())); + .filter(auditObject -> auditObject.getAaiObjectType().equals(Types.VSERVER.typeName()) + || auditObject.getAaiObjectType().equals(Types.L_INTERFACE.typeName())); List<AAIObjectAudit> filteredAuditStream = vServerLInterfaceAuditStream.filter(a -> !a.isDoesObjectExist()).collect(Collectors.toList()); for (AAIObjectAudit object : filteredAuditStream) { - if (object.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())) { + if (object.getAaiObjectType().equals(Types.L_INTERFACE.typeName())) { LInterface li = objectMapper.getMapper().convertValue(object.getAaiObject(), LInterface.class); - errorMessage = errorMessage - .append(AAIObjectType.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", "); + errorMessage = + errorMessage.append(Types.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", "); } else { Vserver vs = objectMapper.getMapper().convertValue(object.getAaiObject(), Vserver.class); - errorMessage = - errorMessage.append(AAIObjectType.VSERVER.typeName() + " " + vs.getVserverId() + ", "); + errorMessage = errorMessage.append(Types.VSERVER.typeName() + " " + vs.getVserverId() + ", "); } } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy index f0b1bfe047..7509233ffa 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy @@ -20,30 +20,26 @@ package org.onap.so.bpmn.common.scripts -import org.camunda.bpm.engine.delegate.DelegateExecution +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.any +import static org.mockito.Mockito.atLeastOnce +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import javax.ws.rs.core.UriBuilder import org.junit.Before import org.junit.Ignore import org.junit.Test -import org.mockito.Mockito import org.mockito.internal.stubbing.answers.DoesNothing import org.onap.aai.domain.yang.AllottedResource 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.aai.entities.uri.AAIUriFactory -import javax.ws.rs.core.UriBuilder -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertTrue -import static org.mockito.ArgumentMatchers.any -import static org.mockito.ArgumentMatchers.anyObject -import static org.mockito.ArgumentMatchers.isA -import static org.mockito.Mockito.atLeastOnce -import static org.mockito.Mockito.doNothing -import static org.mockito.Mockito.doThrow -import static org.mockito.Mockito.mock -import static org.mockito.Mockito.spy -import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types class AllottedResourceUtilsTest extends MsoGroovyTest{ @@ -67,7 +63,7 @@ class AllottedResourceUtilsTest extends MsoGroovyTest{ expectedAllottedResource.setId("ID") expectedAllottedResource.setResourceVersion("1.2") when(client.get(any(AAIResourceUri.class))).thenReturn(new AAIResultWrapper(expectedAllottedResource)) - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment(allottedResourceId)) when(allottedResourceUtils.setExecutionVariables(mockExecution,expectedAllottedResource,resourceUri)).thenAnswer(new DoesNothing()) boolean allottedResource = allottedResourceUtils.ifExistsAR(mockExecution,allottedResourceId) assertTrue(allottedResource) @@ -79,7 +75,7 @@ class AllottedResourceUtilsTest extends MsoGroovyTest{ AllottedResource expectedAllottedResource = new AllottedResource() expectedAllottedResource.setId("ID") - AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(ALLOTTED_RESOURSE_URI).build()) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(Types.ALLOTTED_RESOURCE, UriBuilder.fromPath(ALLOTTED_RESOURSE_URI).build()) when(client.get(AllottedResource.class, uri)).thenReturn(Optional.of(expectedAllottedResource)) Optional<AllottedResource> allottedResource = allottedResourceUtils.getARbyLink(mockExecution, ALLOTTED_RESOURSE_URI,"") assertEquals(expectedAllottedResource.getId(),allottedResource.get().getId()) diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy index 8a80d79cf9..df4d371fa5 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy @@ -22,6 +22,13 @@ package org.onap.so.bpmn.common.scripts +import static org.assertj.core.api.Assertions.catchThrowableOfType +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertFalse +import static org.junit.Assert.assertTrue +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.when +import javax.ws.rs.core.UriBuilder import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake @@ -31,29 +38,18 @@ import org.mockito.Mock import org.mockito.MockitoAnnotations import org.onap.aai.domain.yang.RelationshipList import org.onap.aai.domain.yang.VolumeGroup -import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupName -import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupNameFactory -import org.onap.so.bpmn.common.scripts.ExceptionUtil -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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.constants.Defaults import org.springframework.http.HttpStatus -import javax.ws.rs.core.UriBuilder - -import static org.assertj.core.api.Assertions.catchThrowableOfType -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertFalse -import static org.junit.Assert.assertTrue -import static org.mockito.Mockito.spy -import static org.mockito.Mockito.when - class ConfirmVolumeGroupNameTest { private static final AAIResourceUri RESOURCE_URI = AAIUriFactory.createResourceFromExistingURI( - AAIObjectType.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build()) + Types.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build()) private ConfirmVolumeGroupName confirmVolumeGroupName @Mock @@ -79,7 +75,7 @@ class ConfirmVolumeGroupNameTest { String volumeGroupId = "volume-group-id-1" String volumeGroupName = "volume-group-name-1" String aicCloudRegion = "aic-cloud-region-1" - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER, aicCloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId)) delegateExecution.setVariable("ConfirmVolumeGroupName_volumeGroupId", volumeGroupId) delegateExecution.setVariable("ConfirmVolumeGroupName_volumeGroupName", volumeGroupName) diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy index cd57434d5f..3b7179df6c 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy @@ -40,6 +40,8 @@ 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.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.constants.Defaults class ConfirmVolumeGroupTenantTest extends MsoGroovyTest { @@ -79,7 +81,7 @@ class ConfirmVolumeGroupTenantTest extends MsoGroovyTest { when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner') when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - AAIResourceUri arURI = AAIUriFactory. createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), "aicCloudRegionId","volumeGroupId") + AAIResourceUri arURI = AAIUriFactory. createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), "aicCloudRegionId").volumeGroup("volumeGroupId")) AAIResultWrapper wrapper = new AAIResultWrapper(expectedVolumeGroup) when(client.get(arURI)).thenReturn(wrapper) confirmVolumeGroupTenant.preProcessRequest(mockExecution) diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroupTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroupTest.groovy index 4f36aec827..cd9061cd19 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroupTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroupTest.groovy @@ -31,6 +31,8 @@ import org.mockito.Spy import org.onap.aaiclient.client.aai.AAIObjectType 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.constants.Defaults class CreateAAIVfModuleVolumeGroupTest extends MsoGroovyTest{ @@ -50,7 +52,7 @@ class CreateAAIVfModuleVolumeGroupTest extends MsoGroovyTest{ when(mockExecution.getVariable("CAAIVfModVG_vfModuleId")).thenReturn("VfModule123") org.onap.aai.domain.yang.VfModule vfModuleExpected = new org.onap.aai.domain.yang.VfModule() vfModuleExpected.setVfModuleId("VfModule123") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123"); + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("Vnf123").vfModule("VfModule123")); when(client.get(org.onap.aai.domain.yang.VfModule.class,resourceUri)).thenReturn(Optional.of(vfModuleExpected)) createAAIVfModuleVolumeGroup.getVfModule(mockExecution) Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponseCode", 200) @@ -61,7 +63,7 @@ class CreateAAIVfModuleVolumeGroupTest extends MsoGroovyTest{ void testGetVfModuleNotFound (){ when(mockExecution.getVariable("CAAIVfModVG_vnfId")).thenReturn("Vnf123") when(mockExecution.getVariable("CAAIVfModVG_vfModuleId")).thenReturn("VfModule123") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123"); + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("Vnf123").vfModule("VfModule123")); when(client.get(org.onap.aai.domain.yang.VfModule.class,resourceUri)).thenReturn(Optional.empty()) createAAIVfModuleVolumeGroup.getVfModule(mockExecution) Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponseCode", 404) @@ -72,7 +74,7 @@ class CreateAAIVfModuleVolumeGroupTest extends MsoGroovyTest{ void testGetVfModuleException (){ when(mockExecution.getVariable("CAAIVfModVG_vnfId")).thenReturn("Vnf123") when(mockExecution.getVariable("CAAIVfModVG_vfModuleId")).thenReturn("VfModule123") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123"); + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("Vnf123").vfModule("VfModule123")); when(client.get(org.onap.aai.domain.yang.VfModule.class,resourceUri)).thenThrow(new NullPointerException("Error in AAI client")) createAAIVfModuleVolumeGroup.getVfModule(mockExecution) Mockito.verify(mockExecution).setVariable("CAAIVfModVG_getVfModuleResponseCode", 500) @@ -90,8 +92,8 @@ class CreateAAIVfModuleVolumeGroupTest extends MsoGroovyTest{ vfModuleExpected.setVfModuleId("VfModule123") vfModuleExpected.setResourceVersion("12345") when(mockExecution.getVariable("CAAIVfModVG_getVfModuleResponse")).thenReturn(vfModuleExpected) - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123"); - AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(),"CloudRegion1", "VolumeGroup1") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("Vnf123").vfModule("VfModule123")); + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), "CloudRegion1").volumeGroup("VolumeGroup1")) doNothing().when(client).connect(resourceUri ,resourceUri1 ) createAAIVfModuleVolumeGroup.updateVfModule(mockExecution) Mockito.verify(mockExecution).setVariable("CAAIVfModVG_updateVfModuleResponseCode", 200) @@ -109,8 +111,8 @@ class CreateAAIVfModuleVolumeGroupTest extends MsoGroovyTest{ vfModuleExpected.setResourceVersion("12345") when(mockExecution.getVariable("CAAIVfModVG_cloudOwner")).thenReturn("cloudOwner") when(mockExecution.getVariable("CAAIVfModVG_getVfModuleResponse")).thenReturn(vfModuleExpected) - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "Vnf123", "VfModule123"); - AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, 'cloudOwner',"CloudRegion1", "VolumeGroup1") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("Vnf123").vfModule("VfModule123")); + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion('cloudOwner', "CloudRegion1").volumeGroup("VolumeGroup1")) doThrow(new NullPointerException("Error in AAI client")).when(client).connect(resourceUri ,resourceUri1 ) createAAIVfModuleVolumeGroup.updateVfModule(mockExecution) Mockito.verify(mockExecution).setVariable("CAAIVfModVG_updateVfModuleResponseCode", 500) diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy index c8eeb0a957..77e4374921 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy @@ -31,16 +31,15 @@ import org.junit.rules.ExpectedException import org.junit.runner.RunWith import org.mockito.junit.MockitoJUnitRunner import org.onap.aai.domain.yang.GenericVnf -import org.onap.so.bpmn.mock.FileUtil -import org.onap.so.client.HttpClient -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.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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.aaiclient.client.graphinventory.entities.uri.Depth +import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.client.HttpClient import org.onap.so.constants.Defaults @RunWith(MockitoJUnitRunner.Silent.class) @@ -111,8 +110,8 @@ abstract class MsoGroovyTest { } protected Optional<GenericVnf> mockAAIGenericVnf(String vnfId,String file){ - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE) Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,file); when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf) when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf) @@ -120,8 +119,8 @@ abstract class MsoGroovyTest { } protected Optional<GenericVnf> mockAAIGenericVnfByName(String vnfName){ - AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) - AAIPluralResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()).queryParam("vnf-name", vnfName) + AAIPluralResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()).queryParam("vnf-name", vnfName).depth(Depth.ONE) Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnf.json"); when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf) when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf) @@ -129,21 +128,21 @@ abstract class MsoGroovyTest { } protected void mockAAIGenericVnfNotFound(String vnfId){ - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) - AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE) when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty()) when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty()) } protected void mockAAIGenericVnfByNameNotFound(String vnfName){ - AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) - AAIPluralResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()).queryParam("vnf-name", vnfName) + AAIPluralResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()).queryParam("vnf-name", vnfName).depth(Depth.ONE) when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty()) when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty()) } protected AAIResultWrapper mockVolumeGroupWrapper(String region, String volumeGroupId, String file){ - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, region,volumeGroupId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, region).volumeGroup(volumeGroupId)) String json = FileUtil.readResourceFile(file) AAIResultWrapper resultWrapper = new AAIResultWrapper(json) when(client.get(resourceUri)).thenReturn(resultWrapper) diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy index 1918d10fe7..94317f49ae 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy @@ -38,6 +38,8 @@ import org.mockito.Spy import org.onap.aaiclient.client.aai.AAIObjectType 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.aai.domain.yang.VfModule import com.github.tomakehurst.wiremock.junit.WireMockRule @@ -67,7 +69,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") VfModule vfModule = new VfModule() vfModule.setVfModuleId("supercool") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "skask", "supercool"); + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("skask").vfModule("supercool")); when(client.get(VfModule.class,resourceUri)).thenReturn(Optional.of(vfModule)) updateAAIVfModule.getVfModule(mockExecution) verify(mockExecution).setVariable(prefix + "getVfModuleResponseCode", 200) @@ -79,7 +81,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { when(mockExecution.getVariable("prefix")).thenReturn(prefix) when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "skask", "supercool"); + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("skask").vfModule("supercool")); when(client.get(VfModule.class,resourceUri)).thenReturn(Optional.empty()) updateAAIVfModule.getVfModule(mockExecution) verify(mockExecution).setVariable(prefix + "getVfModuleResponseCode", 404) @@ -91,7 +93,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest { when(mockExecution.getVariable("prefix")).thenReturn(prefix) when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "skask", "supercool"); + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("skask").vfModule("supercool")); when(client.get(VfModule.class,resourceUri)).thenThrow(new NullPointerException("Error from AAI client")) updateAAIVfModule.getVfModule(mockExecution) verify(mockExecution).setVariable(prefix + "getVfModuleResponseCode", 500) diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 70bce65f5b..127253a72e 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -59,7 +59,6 @@ import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -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.aai.entities.uri.AAIUriFactory; @@ -69,12 +68,12 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -1830,7 +1829,8 @@ public class BBInputSetupTest { expectedAAI.setRelationshipList(relationshipList); Configuration expected = new Configuration(); - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "configurationId"); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration("configurationId")); AAIResultWrapper configurationWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI)); @@ -1854,7 +1854,8 @@ public class BBInputSetupTest { expectedAAI.setRelationshipList(relationshipList); GenericVnf expected = new GenericVnf(); - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId"); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")); AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI)); @@ -1884,7 +1885,7 @@ public class BBInputSetupTest { expectedAAI.setRelationshipList(relationshipList); Pnf expected = new Pnf(); - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, "pnfId"); + AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf("pnfId")); AAIResultWrapper pnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI)); @@ -2008,7 +2009,8 @@ public class BBInputSetupTest { List<L3Network> l3Networks = new ArrayList<>(); AAIResultWrapper l3NetworksWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI)); - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, "networkId"); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network("networkId")); doReturn(l3NetworksWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthTwo(aaiResourceUri); doReturn(expected).when(bbInputSetupMapperLayer).mapAAIL3Network(isA(org.onap.aai.domain.yang.L3Network.class)); @@ -3422,7 +3424,7 @@ public class BBInputSetupTest { String vnfcName = "vnfcName"; org.onap.aai.domain.yang.Configuration expectedAAI = new org.onap.aai.domain.yang.Configuration(); - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfcName); + AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName)); AAIResultWrapper configurationWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI)); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index f6615e52c8..c65b36a40c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -64,12 +64,12 @@ import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; import org.onap.aai.domain.yang.VpnBinding; -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.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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -179,8 +179,10 @@ public class BBInputSetupUtilsTest { Optional<CloudRegion> expected = Optional.of(new CloudRegion()); doReturn(expected).when(MOCK_aaiResourcesClient).get(CloudRegion.class, - AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), - cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO)); + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId())) + .depth(Depth.TWO)); assertThat(bbInputSetupUtils.getCloudRegion(cloudConfig), sameBeanAs(expected.get())); } @@ -208,7 +210,7 @@ public class BBInputSetupUtilsTest { expected.get().setId(instanceGroupId); doReturn(expected).when(MOCK_aaiResourcesClient).get(InstanceGroup.class, - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroupId))); assertThat(bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId), sameBeanAs(expected.get())); } @@ -225,7 +227,7 @@ public class BBInputSetupUtilsTest { expected.get().setGlobalCustomerId(globalSubscriberId); doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Customer.class, - AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId))); assertThat(bbInputSetupUtils.getAAICustomer(globalSubscriberId), sameBeanAs(expected.get())); } @@ -244,8 +246,8 @@ public class BBInputSetupUtilsTest { expected.get().setServiceType(subscriptionServiceType); doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.ServiceSubscription.class, - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId, - subscriptionServiceType)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType))); assertThat(bbInputSetupUtils.getAAIServiceSubscription(globalSubscriberId, subscriptionServiceType), sameBeanAs(expected.get())); @@ -286,9 +288,12 @@ public class BBInputSetupUtilsTest { ServiceInstance expected = new ServiceInstance(); expected.setServiceInstanceId(serviceInstanceId); - doReturn(Optional.of(expected)).when(MOCK_aaiResourcesClient).get(ServiceInstance.class, AAIUriFactory - .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId) - .depth(Depth.TWO)); + doReturn(Optional.of(expected)).when(MOCK_aaiResourcesClient) + .get(ServiceInstance.class, + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustomerId) + .serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) + .depth(Depth.TWO)); assertThat(bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(globalCustomerId, serviceType, serviceInstanceId), sameBeanAs(expected)); @@ -320,8 +325,8 @@ public class BBInputSetupUtilsTest { serviceInstances.getServiceInstance().add(expectedServiceInstance); AAIPluralResourceUri expectedUri = AAIUriFactory - .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(), - customer.getServiceSubscription().getServiceType()) + .createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription(customer.getServiceSubscription().getServiceType()).serviceInstances()) .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO); bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer); @@ -402,14 +407,15 @@ public class BBInputSetupUtilsTest { mapper.readValue(new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), GenericVnf.class); doReturn(Optional.of(expectedAaiVnf)).when(MOCK_aaiResourcesClient).get(isA(Class.class), - eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE))); + eq(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE))); assertThat(bbInputSetupUtils.getAAIGenericVnf(vnfId), sameBeanAs(expectedAaiVnf)); } @Test public void getAAIResourceDepthOneTest() { - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "anyVnfId"); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("anyVnfId")); AAIResourceUri expectedUri = aaiResourceUri.clone().depth(Depth.ONE); AAIResourceUri aaiResourceUriClone = aaiResourceUri.clone(); @@ -421,7 +427,8 @@ public class BBInputSetupUtilsTest { @Test public void getAAIResourceDepthTwoTest() { - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "anyVnfId"); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("anyVnfId")); AAIResourceUri expectedUri = aaiResourceUri.clone().depth(Depth.TWO); AAIResourceUri aaiResourceUriClone = aaiResourceUri.clone(); @@ -516,8 +523,8 @@ public class BBInputSetupUtilsTest { vnf.setVnfId(vnfId); vnf.setVnfName(vnfName); doReturn(Optional.of(vnf)).when(MOCK_aaiResourcesClient).getOne(GenericVnfs.class, GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - .relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + .relatedTo(Types.GENERIC_VNFS.getFragment()).queryParam("vnf-name", vnfName)); Optional<GenericVnf> actual = this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName); assertTrue(actual.isPresent()); @@ -545,8 +552,8 @@ public class BBInputSetupUtilsTest { volumeGroup.setVolumeGroupId(volumeGroupId); volumeGroup.setVolumeGroupName(volumeGroupName); doReturn(Optional.of(volumeGroup)).when(MOCK_aaiResourcesClient).getOne(VolumeGroups.class, VolumeGroup.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - .relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) + .relatedTo(Types.VOLUME_GROUPS.getFragment()).queryParam("volume-group-name", volumeGroupName)); Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName); assertEquals(volumeGroup.getVolumeGroupId(), actual.get().getVolumeGroupId()); @@ -572,8 +579,10 @@ public class BBInputSetupUtilsTest { volumeGroup.setVolumeGroupId("id123"); volumeGroup.setVolumeGroupName("name123"); doReturn(Optional.of(volumeGroup)).when(MOCK_aaiResourcesClient).getOne(VolumeGroups.class, VolumeGroup.class, - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnf-id123", "vf-module-id123") - .relatedTo(AAIObjectPlurals.VOLUME_GROUP) + AAIUriFactory + .createResourceUri( + AAIFluentTypeBuilder.network().genericVnf("vnf-id123").vfModule("vf-module-id123")) + .relatedTo(Types.VOLUME_GROUPS.getFragment()) .queryParam("volume-group-name", "volume-group-name123")); Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule("vnf-id123", "vf-module-id123", "volume-group-name123"); @@ -620,8 +629,10 @@ public class BBInputSetupUtilsTest { VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("id123"); doReturn(Optional.of(volumeGroup)).when(MOCK_aaiResourcesClient).getOne(VolumeGroups.class, VolumeGroup.class, - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnf-id123", "vf-module-id123") - .relatedTo(AAIObjectPlurals.VOLUME_GROUP)); + AAIUriFactory + .createResourceUri( + AAIFluentTypeBuilder.network().genericVnf("vnf-id123").vfModule("vf-module-id123")) + .relatedTo(Types.VOLUME_GROUPS.getFragment())); Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupFromVfModule("vnf-id123", "vf-module-id123"); assertTrue(actual.isPresent()); @@ -679,8 +690,8 @@ public class BBInputSetupUtilsTest { configuration.setConfigurationId("id123"); doReturn(Optional.of(configuration)).when(MOCK_aaiResourcesClient).getOne(Configurations.class, Configuration.class, - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "service-instance-id123") - .relatedTo(AAIObjectPlurals.CONFIGURATION) + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment("service-instance-id123")) + .relatedTo(Types.CONFIGURATIONS.getFragment()) .queryParam("configuration-name", "configuration-name123")); Optional<Configuration> actual = this.bbInputSetupUtils .getRelatedConfigurationByNameFromServiceInstance("service-instance-id123", "configuration-name123"); @@ -690,8 +701,8 @@ public class BBInputSetupUtilsTest { @Test public void existsAAIVfModuleGloballyByNameTest() { - AAIPluralResourceUri expectedUri = - AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE).queryParam("vf-module-name", "testVfModule"); + AAIPluralResourceUri expectedUri = AAIUriFactory.createNodesUri(Types.VF_MODULES.getFragment()) + .queryParam("vf-module-name", "testVfModule"); bbInputSetupUtils.existsAAIVfModuleGloballyByName("testVfModule"); verify(MOCK_aaiResourcesClient, times(1)).exists(expectedUri); @@ -699,8 +710,9 @@ public class BBInputSetupUtilsTest { @Test public void existsAAIConfigurationGloballyByNameTest() { - AAIPluralResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) - .queryParam("configuration-name", "testConfig"); + AAIPluralResourceUri expectedUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configurations()) + .queryParam("configuration-name", "testConfig"); bbInputSetupUtils.existsAAIConfigurationGloballyByName("testConfig"); verify(MOCK_aaiResourcesClient, times(1)).exists(expectedUri); @@ -708,8 +720,8 @@ public class BBInputSetupUtilsTest { @Test public void existsAAINetworksGloballyByNameTest() { - AAIPluralResourceUri expectedUri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "testNetwork"); + AAIPluralResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Networks()) + .queryParam("network-name", "testNetwork"); bbInputSetupUtils.existsAAINetworksGloballyByName("testNetwork"); verify(MOCK_aaiResourcesClient, times(1)).exists(expectedUri); @@ -717,7 +729,7 @@ public class BBInputSetupUtilsTest { @Test public void existsAAIVolumeGroupGloballyByNameTest() { - AAIPluralResourceUri expectedUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + AAIPluralResourceUri expectedUri = AAIUriFactory.createNodesUri(Types.VOLUME_GROUPS.getFragment()) .queryParam("volume-group-name", "testVoumeGroup"); bbInputSetupUtils.existsAAIVolumeGroupGloballyByName("testVoumeGroup"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java index edd214f85f..4d034a19e8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import java.io.File; @@ -38,14 +37,14 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.runners.MockitoJUnitRunner; +import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -143,14 +142,14 @@ public class CloudInfoFromAAITest { new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(cloudRegion)); cloudRegions.add(cloudRegionWrapper); - doReturn(cloudRegions).when(relationships).getByType(AAIObjectType.CLOUD_REGION); + doReturn(cloudRegions).when(relationships).getByType(Types.CLOUD_REGION); List<AAIResultWrapper> tenants = new ArrayList<>(); org.onap.aai.domain.yang.Tenant tenant = new org.onap.aai.domain.yang.Tenant(); tenant.setTenantId(tenantId); AAIResultWrapper tenantWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(tenant)); tenants.add(tenantWrapper); - doReturn(tenants).when(relationships).getByType(AAIObjectType.TENANT); + doReturn(tenants).when(relationships).getByType(Types.TENANT); Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getRelatedCloudRegionAndTenant(relationships); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java index e05a3bda8f..fff495f9a8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java @@ -34,14 +34,14 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; import org.onap.aai.domain.yang.Vserver; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.BaseTest; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.mock.FileUtil; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import org.springframework.beans.BeanUtils; @@ -71,7 +71,7 @@ public class ExceptionBuilderTest extends BaseTest { auditList.setAuditType("create"); auditList.setHeatStackName("testStackName"); AAIObjectAudit vserver = new AAIObjectAudit(); - vserver.setAaiObjectType(AAIObjectType.VSERVER.typeName()); + vserver.setAaiObjectType(Types.VSERVER.typeName()); vserver.setDoesObjectExist(false); Vserver vs = new Vserver(); vs.setVserverId("testVServerId"); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy index 8e3bef69de..11301587e2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy @@ -20,12 +20,20 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang3.StringUtils.isBlank +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.RelationshipData import org.onap.aai.domain.yang.RelationshipList import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -33,19 +41,10 @@ import org.onap.so.bpmn.common.scripts.RequestDBUtil import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.NotFoundException - -import static org.apache.commons.lang3.StringUtils.isBlank - class ActivateCommunicationService extends AbstractServiceTaskProcessor { String Prefix="ACS_" @@ -130,8 +129,7 @@ class ActivateCommunicationService extends AbstractServiceTaskProcessor { //check the cms status try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") @@ -394,8 +392,7 @@ class ActivateCommunicationService extends AbstractServiceTaskProcessor { // create service ServiceInstance csi = new ServiceInstance() csi.setOrchestrationStatus(orchestrationStatus) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) client.update(uri, csi) } catch (BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy index 334f5b4e4f..36d579c7ab 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy @@ -20,11 +20,20 @@ package org.onap.so.bpmn.infrastructure.scripts -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken +import static org.apache.commons.lang3.StringUtils.isBlank +import java.lang.reflect.Type +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.* +import org.onap.aaiclient.client.aai.AAIResourcesClient +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.logging.filter.base.ErrorCode import org.onap.so.beans.nsmf.NSSI import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -32,22 +41,13 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus -import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory - -import javax.ws.rs.NotFoundException -import java.lang.reflect.Type - -import static org.apache.commons.lang3.StringUtils.isBlank +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken /** * This groovy class supports the <class>ActivateSliceService.bpmn</class> process. @@ -248,8 +248,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { String subscriptionServiceType = execution.getVariable("subscriptionServiceType") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, NSIServiceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(NSIServiceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } @@ -271,8 +270,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { } for (String snssi : SNSSIList) { AAIResourcesClient client01 = new AAIResourcesClient() - AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, snssi) + AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(snssi)) if (!client.exists(uri01)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") @@ -339,8 +337,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalCustId, serviceType, serviceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } @@ -392,8 +389,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { try { //get the TN NSSI id by NSI id, active NSSI TN slicing AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, NSIserviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(NSIserviceInstanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } @@ -410,8 +406,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) AAIResourcesClient client01 = new AAIResourcesClient() - AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, nssiserviceid) + AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiserviceid)) if (!client.exists(uri01)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") @@ -477,8 +472,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { try { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") @@ -516,8 +510,8 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { //get the allotted-resources by e2e slice id AAIResourcesClient client_allotted = new AAIResourcesClient() - AAIResourceUri uri_allotted = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE_ALL, - globalSubscriberId, subscriptionServiceType, serviceInstanceId) + AAIPluralResourceUri uri_allotted = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId).allottedResources() + ) if (!client_allotted.exists(uri_allotted)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } @@ -536,8 +530,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { try { //get the NSI id by e2e slice id AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, nsiserviceid) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nsiserviceid)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy index d59f865b01..4108ccecff 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy @@ -20,6 +20,7 @@ package org.onap.so.bpmn.infrastructure.scripts + import com.google.gson.JsonArray import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -42,6 +43,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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 javax.ws.rs.NotFoundException import org.onap.so.beans.nsmf.AllocateTnNssi import org.onap.so.beans.nsmf.DeAllocateNssi @@ -53,6 +56,7 @@ import org.onap.aai.domain.yang.SliceProfile import org.onap.aai.domain.yang.SliceProfiles import org.onap.aai.domain.yang.Relationship + class AnNssmfUtils { private static final Logger logger = LoggerFactory.getLogger(AnNssmfUtils.class) @@ -228,13 +232,13 @@ public void createSliceProfilesInAai(DelegateExecution execution) { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ANNF_sliceProfileInstanceId) + AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ANNF_sliceProfileInstanceId)) client.create(sliceProfileUri, ANNF_sliceProfileInstance) - AAIResourceUri sliceProfileUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), TNFH_sliceProfileInstanceId) + AAIResourceUri sliceProfileUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(TNFH_sliceProfileInstanceId)) client.create(sliceProfileUri1, TNFH_sliceProfileInstance) - AAIResourceUri sliceProfileUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), TNMH_sliceProfileInstanceId) + AAIResourceUri sliceProfileUri2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(TNMH_sliceProfileInstanceId)) client.create(sliceProfileUri2, TNMH_sliceProfileInstance) } catch (BpmnError e) { @@ -303,10 +307,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe String msg AAIResourcesClient client = new AAIResourcesClient() try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - instanceId).relationshipAPI() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId).relationshipAPI()) client.create(uri, relationship) } catch (BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy index be5a029062..7b8b79f35f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy @@ -22,43 +22,28 @@ package org.onap.so.bpmn.infrastructure.scripts -import com.google.gson.JsonObject +import static org.apache.commons.lang3.StringUtils.* +import javax.ws.rs.core.Response +import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray import org.json.JSONObject -import org.json.XML -import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory - -import static org.apache.commons.lang3.StringUtils.* -import groovy.xml.XmlUtil -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.scripts.ExternalAPIUtil -import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.aai.domain.yang.SpPartner -import org.onap.so.bpmn.common.recipe.ResourceInput -import org.onap.so.bpmn.common.resource.ResourceRequestBuilder -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder -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.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory -import java.util.Map -import java.util.UUID -import javax.ws.rs.core.Response +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.recipe.ResourceInput +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtil +import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.camunda.bpm.engine.runtime.Execution -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64 - /** * This groovy class supports the <class>Create3rdONAPE2EServiceInstance.bpmn</class> process. @@ -604,12 +589,12 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso partner.setModelCustomizationId(resourceModelCustomizationUuid) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().spPartner(sppartnerId)) logger.info("sending request to create sp-partner: " + uri.toString()) logger.info("requestbody: " + partner) client.create(uri, partner) - AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) + AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) client.connect(uri, siUri) } catch (Exception ex) { String msg = "Exception in Create3rdONAPE2EServiceInstance.saveSPPartnerInAAI. " + ex.getMessage() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index f8eafe7e98..e253855ab3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -20,12 +20,16 @@ package org.onap.so.bpmn.infrastructure.scripts -import groovy.json.JsonSlurper +import static org.apache.commons.lang3.StringUtils.isBlank import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONObject import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.ServiceInstance +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.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -36,16 +40,11 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceInfo import org.onap.so.bpmn.core.domain.ServiceProxy import org.onap.so.bpmn.core.json.JsonUtils -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.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils - -import static org.apache.commons.lang3.StringUtils.isBlank +import groovy.json.JsonSlurper /** * This groovy class supports the <class>DoCreateCommunicationService.bpmn</class> process. @@ -538,10 +537,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { String msg try { String serviceInstanceId = execution.getVariable("serviceInstanceId") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - serviceInstanceId).relationshipAPI() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(serviceInstanceId)).relationshipAPI() client.create(uri, relationship) } catch (BpmnError e) { @@ -633,8 +629,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { // create service ServiceInstance csi = new ServiceInstance() csi.setOrchestrationStatus(orchestrationStatus) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) client.update(uri, csi) logger.debug(Prefix + "updateFinishStatusInAAI update communication service status to deactivated") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index c9ad18b0be..b7edc026be 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -39,6 +39,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum @@ -361,7 +363,7 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor si.setOrchestrationStatus("Pending") } AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) client.update(uri, si) } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index 56a97bc271..eb67b8fa4c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -32,20 +32,19 @@ import org.onap.aai.domain.yang.ServiceInstance import org.onap.aai.domain.yang.ServiceInstances import org.onap.aai.domain.yang.v13.Metadata import org.onap.aai.domain.yang.v13.Metadatum +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.recipe.ResourceInput import org.onap.so.bpmn.common.resource.ResourceRequestBuilder import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.domain.ModelInfo -import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.aaiclient.client.aai.AAIObjectPlurals -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -142,8 +141,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { AAIResourcesClient client = new AAIResourcesClient() // think how AAI queried for PNF name using the name - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE_METADATA, - customerId, serviceType, serId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customerId).serviceSubscription(serviceType).serviceInstance(serId).metadata()) logger.debug("uri for pnf get:" + uri.toString()) Metadata metadata = client.get(uri).asBean(Metadata.class).get() @@ -294,7 +292,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { AAIResourcesClient client = new AAIResourcesClient() logger.info("sending request to resolve vpn-name:" + vpnName) - AAIResourceUri uri = AAIUriFactory.createResourceUri(new AAIObjectPlurals("/nodes", "/service-instances", "queryByName")).queryParam("service-instance-name", parentServiceName) + AAIResourceUri uri = AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCES.getFragment()).queryParam("service-instance-name", parentServiceName) Optional<ServiceInstances> serviceInstancesOpt = client.get(ServiceInstances.class, uri) if(serviceInstancesOpt.isPresent()) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index 342fce75a5..65398eb658 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -20,37 +20,33 @@ package org.onap.so.bpmn.infrastructure.scripts -import com.fasterxml.jackson.databind.ObjectMapper +import static org.apache.commons.lang3.StringUtils.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance -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.so.beans.nsmf.EsrInfo -import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.logging.filter.base.ErrorCode +import org.onap.so.beans.nsmf.SliceTaskParams import org.onap.so.beans.nsmf.SliceTaskParamsAdapter import org.onap.so.beans.nsmf.oof.TemplateInfo -import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils -import org.onap.so.bpmn.core.domain.ServiceDecomposition - -import static org.apache.commons.lang3.StringUtils.* -import org.springframework.web.util.UriUtils -import groovy.json.JsonSlurper -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.beans.nsmf.SliceTaskParams -import org.onap.so.db.request.beans.OrchestrationTask import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.common.scripts.OofUtils import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.db.request.beans.OrchestrationTask import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory +import org.springframework.web.util.UriUtils +import com.fasterxml.jackson.databind.ObjectMapper +import groovy.json.JsonSlurper public class CreateSliceService extends AbstractServiceTaskProcessor { String Prefix = "CRESS_" @@ -409,7 +405,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) client.update(uri, si) } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy index 80b6641bb7..4cebb9286f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy @@ -26,6 +26,8 @@ import org.onap.so.client.HttpClientFactory import org.onap.aaiclient.client.aai.AAIObjectType 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.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -245,8 +247,8 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { String serviceType = execution.getVariable("serviceType") String serviceId = execution.getVariable("serviceInstanceId") - AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,nsInstanceId) - AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,serviceId) + AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nsInstanceId)) + AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceId)) try{ getAAIClient().connect(nsUri,relatedServiceUri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index 1dfe13738e..4725f9a66d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -22,21 +22,21 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; import org.onap.so.bpmn.common.scripts.ExceptionUtil; import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory - import groovy.json.JsonOutput import groovy.json.JsonSlurper @@ -324,7 +324,7 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() try { - AAIResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE,serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) if(getAAIClient().exists(uri)){ logger.debug('Service instance ' + serviceInstanceId + ' found in AAI.') }else{ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy index 057863be28..3062b1ca32 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy @@ -45,6 +45,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -473,7 +475,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso String id = execution.getVariable(Prefix + "SppartnerId") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, id) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().spPartner(id)) SpPartner sp = client.get(uri).asBean(SpPartner.class).get() logger.debug("GET sppartner Received a Good Response") @@ -508,7 +510,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso String sppartnerId = execution.getVariable(Prefix + "SppartnerId") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().spPartner(sppartnerId)) client.delete(uri) logger.debug("Delete sppartner Received a Good Response") execution.setVariable(Prefix + "SuccessIndicator", true) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy index 26936bfd71..8cab146006 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy @@ -20,12 +20,23 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang3.StringUtils.isBlank +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.Relationship -import org.onap.aai.domain.yang.ServiceInstance import org.onap.aai.domain.yang.CommunicationServiceProfile import org.onap.aai.domain.yang.CommunicationServiceProfiles +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectName +import org.onap.aaiclient.client.aai.AAIObjectType +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -35,21 +46,10 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.NotFoundException -import javax.ws.rs.core.Response - -import static org.apache.commons.lang3.StringUtils.isBlank - class DeleteCommunicationService extends AbstractServiceTaskProcessor { private final String PREFIX ="DeleteCommunicationService" private final Long TIMEOUT = 60 * 60 * 1000 @@ -147,7 +147,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceId") String errorMsg = "query communication service from aai failed" - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) if(si.isPresent()) { @@ -177,16 +177,16 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { /** * query AAI * @param execution - * @param aaiObjectType + * @param aaiObjectName * @param instanceId * @return AAIResultWrapper */ - private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectName aaiObjectName, String instanceId, String errorMsg) { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(instanceId)) if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } @@ -310,7 +310,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String profileId try { - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId) + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).communicationServiceProfiles()) AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) Optional<CommunicationServiceProfiles> csProfilesOpt = wrapper.asBean(CommunicationServiceProfiles.class) if(csProfilesOpt.isPresent()){ @@ -318,7 +318,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { CommunicationServiceProfile csProfile = csProfiles.getCommunicationServiceProfile().get(0) profileId = csProfile ? csProfile.getProfileId() : "" } - resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId) + resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).communicationServiceProfile(profileId)) if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "communication service profile was not found in aai") } @@ -344,7 +344,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { try { LOGGER.debug("start delete communication service from AAI") - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId")) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(execution.getVariable("serviceInstanceId"))) getAAIClient().delete(serviceInstanceUri) execution.setVariable("progress", "100") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy index 99289b85b1..036fa51482 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy @@ -41,6 +41,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils @@ -115,7 +117,7 @@ public class DeleteDeviceResource extends AbstractServiceTaskProcessor { String deviceId = execution.getVariable(Prefix + "DeviceId") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.DEVICE, deviceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().device(deviceId)) Device dev = client.get(uri).asBean(Device.class).get() String devClass = dev.getClass () diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy index cc5b8cf1e8..6d699d351d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -43,6 +43,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.slf4j.Logger import org.slf4j.LoggerFactory @@ -149,7 +151,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { try { String parentServiceId = ""; AAIResourcesClient resourceClient = new AAIResourcesClient(); - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, globalCustId, serviceType, serviceInstanceId, allotedResourceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).allottedResource(allotedResourceId)) AAIResultWrapper aaiResult = resourceClient.get(serviceInstanceUri, NotFoundException.class) Optional<AllottedResource> si = aaiResult.asBean(AllottedResource.class) if((si.present) && (null != si.get().getRelationshipList()) && (null != si.get().getRelationshipList().getRelationship())) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy index d22ee5e82f..4c008a2eb9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy @@ -20,29 +20,28 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang3.StringUtils.isBlank +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceProfile import org.onap.aai.domain.yang.ServiceProfiles +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.NotFoundException - -import static org.apache.commons.lang3.StringUtils.isBlank - class DeleteSliceService extends AbstractServiceTaskProcessor { private final String PREFIX ="DeleteSliceService" @@ -122,7 +121,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { LOGGER.trace("${PREFIX} Start deleteSliceServiceInstance") try { - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId")) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(execution.getVariable("serviceInstanceId"))) getAAIClient().delete(serviceInstanceUri) execution.setVariable("progress", "100") @@ -169,7 +168,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { try { - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId) + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).serviceProfiles()) AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) Optional<ServiceProfiles> serviceProfilesOpt =wrapper.asBean(ServiceProfiles.class) if(serviceProfilesOpt.isPresent()){ @@ -177,7 +176,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0) profileId = serviceProfile ? serviceProfile.getProfileId() : "" } - resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId) + resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).serviceProfile(profileId)) if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index 005f0f3c6b..1bcf615cd2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -31,6 +31,7 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AaiUtil; import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; @@ -197,7 +198,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion)) def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable("DELVfModVol_queryCloudRegionRequest", queryCloudRegionRequest) @@ -240,7 +241,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion') try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion).volumeGroup(volumeGroupId)) AAIResultWrapper volumeGroupWrapper = getAAIClient().get(uri) if (!volumeGroupWrapper.isEmpty()) { @@ -249,7 +250,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { def heatStackId = volumeGroupOp.get().getHeatStackId() ?: "" execution.setVariable('DELVfModVol_volumeGroupHeatStackId', heatStackId) - if ( volumeGroupWrapper.getRelationships().isPresent() && !volumeGroupWrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.VF_MODULE).isEmpty()) { + if ( volumeGroupWrapper.getRelationships().isPresent() && !volumeGroupWrapper.getRelationships().get().getRelatedUris(Types.VF_MODULE).isEmpty()) { logger.debug('Volume Group ' + volumeGroupId + ' currently in use') exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") } @@ -283,7 +284,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { */ private String getTenantIdFromVolumeGroup(AAIResultWrapper wrapper) { if(wrapper.getRelationships().isPresent()) { - List<AAIResourceUri> tenantURIList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.TENANT) + List<AAIResourceUri> tenantURIList = wrapper.getRelationships().get().getRelatedUris(Types.TENANT) if(!tenantURIList.isEmpty()){ return tenantURIList.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } @@ -356,7 +357,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, groupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion).volumeGroup(groupId)) getAAIClient().delete(uri) logger.debug("Volume group $groupId deleted.") }catch(NotFoundException e){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy index 4d86fb4cd9..9ccc6951ea 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateAccessNSSI.groovy @@ -19,7 +19,6 @@ */ package org.onap.so.bpmn.infrastructure.scripts - import static org.apache.commons.lang3.StringUtils.isBlank import javax.ws.rs.NotFoundException @@ -33,6 +32,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.beans.nsmf.ActDeActNssi import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.ServiceInfo @@ -49,6 +50,7 @@ import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.JsonObject + /** * Internal AN NSSMF to handle NSSI Activation/Deactivation * @@ -421,8 +423,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, serviceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } @@ -488,8 +489,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { Map<String,ServiceInstance> relatedInstances = new HashMap<>() AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, instanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") } @@ -504,8 +504,7 @@ class DoActivateAccessNSSI extends AbstractServiceTaskProcessor { String relatioshipurl = relationship.getRelatedLink() String serviceInstanceId = relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) - uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, serviceInstanceId) + uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy index 306c53a73c..5e50b9d52d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSI.groovy @@ -20,15 +20,31 @@ package org.onap.so.bpmn.infrastructure.scripts +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.RelatedToProperty +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipData +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectName +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.CatalogDbUtils import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.db.request.beans.ResourceOperationStatus import org.onap.so.serviceinstancebeans.CloudConfiguration import org.onap.so.serviceinstancebeans.LineOfBusiness import org.onap.so.serviceinstancebeans.ModelInfo @@ -36,37 +52,14 @@ import org.onap.so.serviceinstancebeans.ModelType import org.onap.so.serviceinstancebeans.OwningEntity import org.onap.so.serviceinstancebeans.Platform import org.onap.so.serviceinstancebeans.Project -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.rest.catalog.beans.Vnf import org.onap.so.serviceinstancebeans.RequestDetails import org.onap.so.serviceinstancebeans.RequestInfo import org.onap.so.serviceinstancebeans.RequestParameters import org.onap.so.serviceinstancebeans.SubscriberInfo -import org.onap.aai.domain.yang.GenericVnf -import org.onap.aai.domain.yang.RelatedToProperty -import org.onap.aai.domain.yang.Relationship -import org.onap.aai.domain.yang.RelationshipData -import org.onap.aai.domain.yang.RelationshipList -import org.onap.aai.domain.yang.ServiceInstance -import org.onap.aai.domain.yang.v19.SliceProfile -import org.onap.aai.domain.yang.v19.SliceProfiles import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory -import org.onap.so.db.request.beans.OperationStatus -import org.onap.so.db.request.beans.ResourceOperationStatus -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import com.fasterxml.jackson.databind.ObjectMapper -import javax.ws.rs.NotFoundException -import javax.ws.rs.core.Response - class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { String Prefix="DACTCNSSI_" private static final Logger logger = LoggerFactory.getLogger(DoActivateCoreNSSI.class); @@ -117,7 +110,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { //NSSI Id as service Instance Id to get from Request String serviceInstanceId = execution.getVariable("serviceInstanceID") String errorMsg = "query Network Service Instance from AAI failed" - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> nsi = wrapper.asBean(ServiceInstance.class) String networkServiceInstanceName = "" String networkServiceInstanceId ="" @@ -156,7 +149,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { String errorSliceProfileMsg = "Slice Profile Service Instance was not found in aai" //Query Slice Profile Service Instance From AAI by sliceProfileServiceInstanceId - AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) + AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, Types.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class) if (sliceProfileServiceInstance.isPresent()) { String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus() @@ -205,7 +198,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("networkServiceInstanceId") logger.debug("**** serviceInstanceId :: getServiceInstanceRelationships :: "+serviceInstanceId) String errorMsg = "query Network Service Instance from AAI failed" - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) String networkServiceModelInvariantUuid = si.get().getModelInvariantId() @@ -251,7 +244,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: getVnfRelationships ****") String msg = "query Generic Vnf from AAI failed" try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(execution.getVariable('vnfId'))) if (!getAAIClient().exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) } @@ -313,13 +306,13 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { * @param instanceId * @return AAIResultWrapper */ - private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) { + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectName aaiObjectName, String instanceId, String errorMsg) { logger.debug(Prefix +" **** Enter DoActivateCoreNSSI ::: queryAAI ****") String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(instanceId)) if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } @@ -615,8 +608,7 @@ class DoActivateCoreNSSI extends AbstractServiceTaskProcessor { String sliceProfileInstanceId = si.getServiceInstanceId() si.setOrchestrationStatus(oStatus) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalCustId, serviceType, sliceProfileInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(sliceProfileInstanceId)) try { Response response = getAAIClient().update(uri, si) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy index 04fe161295..0900863a62 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateTnNssi.groovy @@ -29,6 +29,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.RequestDBUtil @@ -37,6 +39,7 @@ import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory + public class DoActivateTnNssi extends AbstractServiceTaskProcessor { String Prefix = "TNACT_" @@ -124,7 +127,7 @@ public class DoActivateTnNssi extends AbstractServiceTaskProcessor { ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, tnNssiId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(tnNssiId)) client.update(uri, si) } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy index 3df0d3d6f0..fc14da3a7d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -47,6 +47,8 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceInstance import org.onap.so.bpmn.core.domain.ServiceProxy 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.aaiclient.client.aai.AAINamespaceConstants import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aai.domain.yang.NetworkPolicy @@ -549,7 +551,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANServiceInstanceId")) + AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId"))) client.create(nssiServiceUri, ANServiceInstance) } catch (BpmnError e) { @@ -630,10 +632,10 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANServiceInstanceId")) + AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANServiceInstanceId"))) client.create(nssiServiceUri, ANServiceInstance) - AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("RANNFServiceInstanceId")) + AAIResourceUri nssiServiceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("RANNFServiceInstanceId"))) client.create(nssiServiceUri1, ANNFServiceInstance) } catch (BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy index 2a31997cd5..b5e1e6b82a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy @@ -54,6 +54,8 @@ import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel 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.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceProxy import org.onap.so.bpmn.core.json.JsonUtils @@ -125,7 +127,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { si.setEnvironmentContext(environmentContext) si.setWorkloadContext(workloadContext) logger.debug("AAI service Instance Request Payload : "+si.toString()) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), serviceType, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) Response response = getAAIClient().create(uri, si) if(response.getStatus()!=200) { exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "AAI instance creation failed") @@ -353,8 +355,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { ServiceInstance si = execution.getVariable("nssiServiceInstance") si.setOrchestrationStatus("activated") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalCustId, serviceType, networkServiceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(networkServiceInstanceId)) try { getAAIClient().update(uri, si) } catch (Exception e) { @@ -364,10 +365,10 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { } //URI for NSSI - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId); + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)); //URI for Network Service Instance - AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkServiceInstanceId) + AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstanceId)) // Update Relationship in AAI Response response = getAAIClient().connect(nssiUri, networkServiceInstanceUri, AAIEdgeLabel.COMPOSED_OF); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy index 6367341228..5ecfc9a872 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSlice.groovy @@ -20,15 +20,32 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang3.StringUtils.isBlank +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject +import org.onap.aai.domain.yang.GenericVnf +import org.onap.aai.domain.yang.RelatedToProperty +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipData +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectName +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.CatalogDbUtils import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.RequestDBUtil +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.db.request.beans.ResourceOperationStatus import org.onap.so.serviceinstancebeans.CloudConfiguration import org.onap.so.serviceinstancebeans.LineOfBusiness import org.onap.so.serviceinstancebeans.ModelInfo @@ -36,36 +53,14 @@ import org.onap.so.serviceinstancebeans.ModelType import org.onap.so.serviceinstancebeans.OwningEntity import org.onap.so.serviceinstancebeans.Platform import org.onap.so.serviceinstancebeans.Project -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.rest.catalog.beans.Vnf import org.onap.so.serviceinstancebeans.RequestDetails import org.onap.so.serviceinstancebeans.RequestInfo import org.onap.so.serviceinstancebeans.RequestParameters import org.onap.so.serviceinstancebeans.SubscriberInfo -import org.onap.aai.domain.yang.GenericVnf -import org.onap.aai.domain.yang.RelatedToProperty -import org.onap.aai.domain.yang.Relationship -import org.onap.aai.domain.yang.RelationshipData -import org.onap.aai.domain.yang.RelationshipList -import org.onap.aai.domain.yang.ServiceInstance import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.onap.so.client.HttpClient -import org.onap.so.client.HttpClientFactory -import org.onap.so.db.request.beans.OperationStatus -import org.onap.so.db.request.beans.ResourceOperationStatus -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import com.fasterxml.jackson.databind.ObjectMapper -import static org.apache.commons.lang3.StringUtils.isBlank - -import javax.ws.rs.NotFoundException -import javax.ws.rs.core.Response class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { @@ -123,7 +118,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceID") String errorMsg = "query Network Service Instance from AAI failed" - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> nsi = wrapper.asBean(ServiceInstance.class) String networkServiceInstanceName = "" @@ -163,7 +158,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { String errorSliceProfileMsg = "Slice Profile Service Instance was not found in aai" //Query Slice Profile Service Instance From AAI by sliceProfileServiceInstanceId - AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) + AAIResultWrapper sliceProfileInstanceWrapper = queryAAI(execution, Types.SERVICE_INSTANCE, sliceProfileServiceInstanceId, errorSliceProfileMsg) Optional<ServiceInstance> sliceProfileServiceInstance = sliceProfileInstanceWrapper.asBean(ServiceInstance.class) if (sliceProfileServiceInstance.isPresent()) { String orchestrationStatus= sliceProfileServiceInstance.get().getOrchestrationStatus() @@ -204,7 +199,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("networkServiceInstanceId") String errorMsg = "query Network Service Instance from AAI failed" - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) String networkServiceModelInvariantUuid = si.get().getModelInvariantId() @@ -256,7 +251,7 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: getVnfRelationships ****") String msg = "query Generic Vnf from AAI failed" try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(execution.getVariable('vnfId'))) if (!getAAIClient().exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) } @@ -313,15 +308,15 @@ class DoAllocateCoreSharedSlice extends AbstractServiceTaskProcessor { /** * query AAI * @param execution - * @param aaiObjectType + * @param aaiObjectName * @param instanceId * @return AAIResultWrapper */ - private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) { + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectName aaiObjectName, String instanceId, String errorMsg) { logger.debug(Prefix+" **** Enter DoAllocateCoreSharedSlice ::: queryAAI ****") String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(instanceId)) if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy index c4068d2d5e..c497fc4517 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -20,16 +20,18 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang3.StringUtils.isBlank +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.ServiceInstance import org.onap.aai.domain.yang.SliceProfile -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.beans.nsmf.AllocateAnNssi import org.onap.so.beans.nsmf.AllocateCnNssi import org.onap.so.beans.nsmf.AllocateTnNssi @@ -43,17 +45,12 @@ import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.beans.nsmf.SliceTaskInfo import org.onap.so.beans.nsmf.SliceTaskParamsAdapter import org.onap.so.beans.nsmf.TnSliceProfile -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.NotFoundException - -import static org.apache.commons.lang3.StringUtils.isBlank - -class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ +class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger(DoAllocateNSIandNSSI.class); @@ -146,10 +143,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String msg try { - AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - sliceInstanceId) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceInstanceId)) client.create(nsiServiceUri, nsi) execution.setVariable("nsiServiceUri", nsiServiceUri) @@ -179,12 +173,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ AAIResourceUri nsiServiceUri = execution.getVariable("nsiServiceUri") as AAIResourceUri logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri) - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri( - AAIObjectType.ALLOTTED_RESOURCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - sliceParams.suggestNsiId, - allottedResourceId) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceParams.suggestNsiId).allottedResource(allottedResourceId)) client.connect(allottedResourceUri, nsiServiceUri) } @@ -205,10 +194,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String nsiServiceInstanceID = sliceParams.getSuggestNsiId() //sliceParams.setServiceId(nsiServiceInstanceID) - AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - nsiServiceInstanceID) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(nsiServiceInstanceID)) try { AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class) @@ -220,12 +206,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri( - AAIObjectType.ALLOTTED_RESOURCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - sliceParams.suggestNsiId, //nsiId - allottedResourceId) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceParams.suggestNsiId).allottedResource(allottedResourceId)) client.connect(allottedResourceUri, nsiServiceUri) @@ -277,10 +258,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ execution.setVariable("communicationServiceInstance", rspi) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, - subscriptionServiceType, - serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) client.create(uri, rspi) execution.setVariable("sliceTaskParams", sliceParams) @@ -308,11 +286,11 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ sliceProfile.setProfileId(profileId) sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList as String) //todo:... - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, - globalSubscriberId, - subscriptionServiceType, - sliceTaskInfo.sliceInstanceId, - profileId + AAIResourceUri uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(sliceTaskInfo.sliceInstanceId) + .sliceProfile(profileId) ) client.create(uri, sliceProfile) execution.setVariable("sliceTaskParams", sliceParams) @@ -400,10 +378,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ execution.setVariable("communicationServiceInstance", rspi) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, - subscriptionServiceType, - serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) client.create(uri, rspi) execution.setVariable("sliceTaskParams", sliceParams) } @@ -431,12 +406,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ sliceProfile.setProfileId(profileId) sliceProfile.setCoverageAreaTAList(cnSliceProfile.coverageAreaTAList as String) //todo:... - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, - globalSubscriberId, - subscriptionServiceType, - sliceTaskInfo.sliceInstanceId, - profileId - ) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceTaskInfo.sliceInstanceId).sliceProfile(profileId)) client.create(uri, sliceProfile) execution.setVariable("sliceTaskParams", sliceParams) } @@ -524,10 +494,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ execution.setVariable("communicationServiceInstance", rspi) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, - subscriptionServiceType, - serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) client.create(uri, rspi) execution.setVariable("sliceTaskParams", sliceParams) @@ -554,12 +521,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ SliceProfile sliceProfile = new SliceProfile() sliceProfile.setProfileId(profileId) //todo:... - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, - globalSubscriberId, - subscriptionServiceType, - sliceTaskInfo.sliceInstanceId, - profileId - ) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceTaskInfo.sliceInstanceId).sliceProfile(profileId)) client.create(uri, sliceProfile) execution.setVariable("sliceTaskParams", sliceParams) @@ -706,20 +668,14 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ //relation ship Relationship relationship = new Relationship() - AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - targetId) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(targetId)) logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri) relationship.setRelatedLink(nsiServiceUri.build().toString()) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - sourceId).relationshipAPI() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sourceId).relationshipAPI()) client.create(uri, relationship) } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 9aa044a649..35f725738d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -14,6 +14,13 @@ import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.http.ResponseEntity diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy index 00746d4e65..e225c360ed 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy @@ -36,6 +36,8 @@ 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.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -103,7 +105,7 @@ import javax.ws.rs.core.Response String nssiId = currentNSSI['nssiId'] - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, nssiUri) if (nssiOpt.isPresent()) { @@ -139,7 +141,7 @@ import javax.ws.rs.core.Response Optional<Relationships> relationships = wrapper.getRelationships() if (relationships.isPresent()) { - for (AAIResourceUri networkServiceInstanceUri : relationships.get().getRelatedAAIUris(AAIObjectType.SERVICE_INSTANCE)) { + for (AAIResourceUri networkServiceInstanceUri : relationships.get().getRelatedUris(Types.SERVICE_INSTANCE)) { Optional<ServiceInstance> networkServiceInstanceOpt = client.get(ServiceInstance.class, networkServiceInstanceUri) if (networkServiceInstanceOpt.isPresent()) { networkServiceInstance = networkServiceInstanceOpt.get() @@ -187,7 +189,7 @@ import javax.ws.rs.core.Response AAIResultWrapper wrapper = client.get(networkServiceInstanceUri); Optional<Relationships> relationships = wrapper.getRelationships() if (relationships.isPresent()) { - for (AAIResourceUri constituteVnfUri : relationships.get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF)) { + for (AAIResourceUri constituteVnfUri : relationships.get().getRelatedUris(Types.GENERIC_VNF)) { currentNSSI['constituteVnfUri'] = constituteVnfUri Optional<GenericVnf> constituteVnfOpt = client.get(GenericVnf.class, constituteVnfUri) if(constituteVnfOpt.isPresent()) { @@ -407,7 +409,7 @@ import javax.ws.rs.core.Response AAIResourcesClient client = getAAIClient() - AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, networkServiceInstance.getModelInvariantId(), networkServiceInstance.getModelVersionId()) + AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(networkServiceInstance.getModelInvariantId()).modelVer(networkServiceInstance.getModelVersionId())) Optional<ModelVer> modelVerOpt = client.get(ModelVer.class, modelVerUrl) if (modelVerOpt.isPresent()) { @@ -445,7 +447,7 @@ import javax.ws.rs.core.Response AAIResultWrapper wrapper = client.get(networkServiceInstanceUri) Optional<Relationships> serviceSubscriptionRelationshipsOps = wrapper.getRelationships() if(serviceSubscriptionRelationshipsOps.isPresent()) { - List<AAIResourceUri> serviceSubscriptionRelatedAAIUris = serviceSubscriptionRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.SERVICE_SUBSCRIPTION) + List<AAIResourceUri> serviceSubscriptionRelatedAAIUris = serviceSubscriptionRelationshipsOps.get().getRelatedUris(Types.SERVICE_SUBSCRIPTION) if(!(serviceSubscriptionRelatedAAIUris == null || serviceSubscriptionRelatedAAIUris.isEmpty())) { AAIResourceUri serviceSubscriptionUri = serviceSubscriptionRelatedAAIUris.get(0) // Many-To-One relation Optional<ServiceSubscription> serviceSubscriptionOpt = client.get(ServiceSubscription.class, serviceSubscriptionUri) @@ -457,7 +459,7 @@ import javax.ws.rs.core.Response wrapper = client.get(serviceSubscriptionUri) Optional<Relationships> customerRelationshipsOps = wrapper.getRelationships() if(customerRelationshipsOps.isPresent()) { - List<AAIResourceUri> customerRelatedAAIUris = customerRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.CUSTOMER) + List<AAIResourceUri> customerRelatedAAIUris = customerRelationshipsOps.get().getRelatedUris(Types.CUSTOMER) if(!(customerRelatedAAIUris == null || customerRelatedAAIUris.isEmpty())) { Optional<Customer> customerOpt = client.get(Customer.class, customerRelatedAAIUris.get(0)) // Many-To-One relation if(customerOpt.isPresent()) { @@ -532,7 +534,7 @@ import javax.ws.rs.core.Response Optional<Relationships> cloudRegionRelationshipsOps = wrapper.getRelationships() if(cloudRegionRelationshipsOps.isPresent()) { - List<AAIResourceUri> cloudRegionRelatedAAIUris = cloudRegionRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) + List<AAIResourceUri> cloudRegionRelatedAAIUris = cloudRegionRelationshipsOps.get().getRelatedUris(Types.CLOUD_REGION) if (!(cloudRegionRelatedAAIUris == null || cloudRegionRelatedAAIUris.isEmpty())) { AAIResourceUri cloudRegionRelatedAAIUri = cloudRegionRelatedAAIUris.get(0) currentNSSI['cloudRegionRelatedAAIUri'] = cloudRegionRelatedAAIUri @@ -574,7 +576,7 @@ import javax.ws.rs.core.Response vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId()) vfModuleModelInfo.setModelCustomizationId(vfModule.getModelCustomizationId()) - AAIResourceUri vfModuleUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, vfModule.getModelInvariantId(), vfModule.getModelVersionId()) + AAIResourceUri vfModuleUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(vfModule.getModelInvariantId()).modelVer(vfModule.getModelVersionId())) Optional<ModelVer> vfModuleModelVerOpt = client.get(ModelVer.class, vfModuleUrl) @@ -609,7 +611,7 @@ import javax.ws.rs.core.Response vnfModelInfo.setModelCustomizationId(constituteVnf.getModelCustomizationId()) vnfModelInfo.setModelInstanceName(constituteVnf.getVnfName()) - AAIResourceUri vnfModelUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, constituteVnf.getModelInvariantId(), constituteVnf.getModelVersionId()) + AAIResourceUri vnfModelUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(constituteVnf.getModelInvariantId()).modelVer(constituteVnf.getModelVersionId())) Optional<ModelVer> vnfModelVerOpt = client.get(ModelVer.class, vnfModelUrl) @@ -779,7 +781,7 @@ import javax.ws.rs.core.Response AAIResultWrapper wrapper = client.get(networkServiceInstanceUri) Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships() if (owningEntityRelationshipsOps.isPresent()) { - List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.OWNING_ENTITY) + List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedUris(Types.OWNING_ENTITY) if (!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) { Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation @@ -813,7 +815,7 @@ import javax.ws.rs.core.Response AAIResultWrapper wrapper = client.get(cloudRegionRelatedAAIUri) Optional<Relationships> cloudRegionOps = wrapper.getRelationships() if (cloudRegionOps.isPresent()) { - List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedAAIUris(AAIObjectType.PROJECT) + List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedUris(Types.PROJECT) if (!(projectAAIUris == null || projectAAIUris.isEmpty())) { Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0)) if (projectOpt.isPresent()) { @@ -928,7 +930,7 @@ import javax.ws.rs.core.Response ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi'] String nssiId = currentNSSI['nssiId'] - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile() @@ -964,7 +966,7 @@ import javax.ws.rs.core.Response String nssiId = currentNSSI['nssiId'] // global-customer-id, service-type, service-instance-id, profile-id - AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiId, sliceProfileContainsSNSSAI.getProfileId()) + AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId())) try { getAAIClient().delete(sliceProfileUri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy index 8cd9dee011..47e059c665 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy @@ -42,6 +42,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.slf4j.Logger import org.slf4j.LoggerFactory @@ -142,7 +144,7 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce String serviceType = execution.getVariable('serviceType') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy index 7cdb084b7f..9f2ad5b537 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy @@ -31,6 +31,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -123,12 +125,7 @@ class DoCreateCommunicationService extends AbstractServiceTaskProcessor{ execution.setVariable("communicationServiceInstanceProfile", csp) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, - globalSubscriberId, - subscriptionServiceType, - serviceInstanceId, - profileId - ) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId).communicationServiceProfile(profileId)) client.create(uri, csp) @@ -188,7 +185,7 @@ class DoCreateCommunicationService extends AbstractServiceTaskProcessor{ execution.setVariable("communicationServiceInstance", csi) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, subscriptionServiceType, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) client.create(uri, csi) } catch (BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index b90a34ea94..d1e61ac174 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -22,40 +22,36 @@ */ package org.onap.so.bpmn.infrastructure.scripts -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.SerializationFeature - -import org.onap.so.logger.LoggingAnchor -import org.onap.logging.filter.base.ErrorCode - import static org.apache.commons.lang3.StringUtils.* - import javax.ws.rs.NotFoundException - import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.Resource import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory - import org.springframework.web.util.UriUtils -import org.onap.so.bpmn.core.UrnPropertiesReader +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.SerializationFeature /** * This groovy class supports the <class>DoCreateServiceInstance.bpmn</class> process. @@ -272,7 +268,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(serviceInstanceId)) client.create(uri, si) } catch (BpmnError e) { @@ -345,7 +341,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { try { String serviceInstanceId = execution.getVariable("serviceInstanceId") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), serviceInstanceId).relationshipAPI() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(serviceInstanceId)).relationshipAPI() client.create(uri, relationship) } catch (BpmnError e) { @@ -402,7 +398,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { String serviceType = execution.getVariable('subscriptionServiceType') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy index 3638d89faa..bb6697bfc9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy @@ -40,6 +40,8 @@ import org.onap.so.logger.MessageEnum import org.onap.so.bpmn.common.scripts.ExceptionUtil; 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.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient @@ -190,7 +192,7 @@ public class DoCreateE2EServiceInstanceRollback extends AbstractServiceTaskProce String serviceInstanceId = execution.getVariable("serviceInstanceId") AAIResourcesClient resourceClient = new AAIResourcesClient(); - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) resourceClient.delete(serviceInstanceUri) logger.trace("Completed Delete Service Instance") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 22e5819068..cc142ca36d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -33,7 +33,6 @@ import org.onap.aai.domain.yang.RouteTableReference import org.onap.aai.domain.yang.RouteTarget import org.onap.aai.domain.yang.Subnet import org.onap.aai.domain.yang.VpnBinding -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.AAIResultWrapper @@ -42,6 +41,7 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -335,7 +335,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable('CRENWKI_serviceInstanceId') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) if(!resourceClient.exists(uri)){ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") @@ -367,7 +367,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String networkName = utils.getNodeText(networkInputs, "network-name") AAIResourcesClient client = new AAIResourcesClient() - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Networks()).queryParam("network-name", networkName) L3Networks networks = client.get(uri, NotFoundException.class).asBean(L3Networks.class).get() L3Network network = networks.getL3Network().get(0) @@ -405,7 +405,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // Prepare AA&I url AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion)) def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) @@ -478,7 +478,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkName", networkName) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)).depth(Depth.ONE) L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get() execution.setVariable(Prefix + "queryIdAAIResponse", network) @@ -514,7 +514,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String netId = networkId AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)).depth(Depth.ONE) L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get() execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200") @@ -553,10 +553,10 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(execution.getVariable(Prefix + "networkId"))) Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() if(relationships.isPresent()){ - List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING) + List<AAIResourceUri> uris = relationships.get().getRelatedUris(Types.VPN_BINDING) logger.debug(Prefix + "vpnCount - " + uris.size()) @@ -625,10 +625,10 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(execution.getVariable(Prefix + "networkId"))) Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() if(relationships.isPresent()){ - List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY) + List<AAIResourceUri> uris = relationships.get().getRelatedUris(Types.NETWORK_POLICY) execution.setVariable(Prefix + "networkPolicyCount", uris.size()) logger.debug(Prefix + "networkPolicyCount - " + uris.size()) @@ -692,10 +692,10 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(execution.getVariable(Prefix + "networkId"))) Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() if(relationships.isPresent()){ - List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE) + List<AAIResourceUri> uris = relationships.get().getRelatedUris(Types.ROUTE_TABLE_REFERENCE) execution.setVariable(Prefix + "networkTableRefCount", uris.size()) logger.debug(Prefix + "networkTableRefCount - " + uris.size()) @@ -791,7 +791,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { logger.debug("Updating l3-network in AAI" ) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)) client.update(uri, l3Network) if(requeryIdAAIResponse.getSubnets() != null){ @@ -807,7 +807,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } logger.debug("Updating subnet in AAI" ) - AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId) + AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId).subnet(subnetId)) client.update(subUri, subnet) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy index fce12e56b0..94aca5f72f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -44,6 +44,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -291,7 +293,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { String globalCustomerId = execution.getVariable("globalSubscriberId") //VID to AAI name map logger.debug(" ***** getAAICustomerById ***** globalCustomerId:" + globalCustomerId) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalCustomerId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustomerId)) if(!getAAIClient().exists(uri)){ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "GlobalCustomerId:" + globalCustomerId + " not found (404) in AAI") } @@ -352,7 +354,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { si.setWorkloadContext(workloadContext) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(serviceInstanceId)) client.create(uri, si) } catch (BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy index 181e9d062a..f64f5e8ebf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy @@ -20,22 +20,22 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.ServiceProfile; +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.beans.nsmf.SliceTaskParamsAdapter -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.aai.domain.yang.ServiceProfile import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils -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.slf4j.Logger import org.slf4j.LoggerFactory @@ -121,10 +121,7 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ ss.setEnvironmentContext(snssai) ss.setServiceRole(serviceRole) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - ssInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId)) client.create(uri, ss) } catch (BpmnError e) { throw e @@ -188,11 +185,11 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ serviceProfile.setTrafficDensity(0) serviceProfile.setConnDensity(0) try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - serviceProfileInstanceId, - serviceProfileId) + AAIResourceUri uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(serviceProfileInstanceId) + .serviceProfile(serviceProfileId)) client.create(uri, serviceProfile) execution.setVariable("sliceTaskParams", sliceParams) @@ -221,11 +218,7 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ for(org.onap.so.bpmn.core.domain.AllottedResource allottedResource : allottedResourceList) { String allottedResourceId = UUID.randomUUID().toString() - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - execution.getVariable("serviceInstanceId"), - allottedResourceId) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("serviceInstanceId")).allottedResource(allottedResourceId)) execution.setVariable("allottedResourceUri", allottedResourceUri) String arType = allottedResource.getAllottedResourceType() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 5cde856251..161b92080b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -42,7 +42,15 @@ import org.onap.so.bpmn.core.domain.AllottedResource import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils - +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.http.ResponseEntity diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy index 534467f6ab..0f1bf0d8b4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateTnNssiInstance.groovy @@ -27,6 +27,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils @@ -81,9 +83,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { sliceProfile.setReliability(new Object()) try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, execution.getVariable - ("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, sliceProfileId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceserviceInstanceId).sliceProfile(sliceProfileId)) client.create(uri, sliceProfile) } catch (BpmnError e) { @@ -120,7 +120,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { ss.setEnvironmentContext(snssai) ss.setServiceRole(serviceRole) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ssInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId)) client.create(uri, ss) } catch (BpmnError e) { throw e @@ -136,16 +136,14 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable('sliceServiceInstanceId') AAIResourcesClient resourceClient = getAAIClient() - AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) try { List<String> networkStrList = jsonUtil.StringArrayToList(execution.getVariable("transportSliceNetworks")) for (String networkStr : networkStrList) { String allottedResourceId = UUID.randomUUID().toString() - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, - execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), - execution.getVariable("sliceserviceInstanceId"), allottedResourceId) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("sliceserviceInstanceId")).allottedResource(allottedResourceId)) execution.setVariable("allottedResourceUri", allottedResourceUri) String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") @@ -157,7 +155,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setModelInvariantId(modelInvariantId) resource.setModelVersionId(modelVersionId) getAAIClient().create(allottedResourceUri, resource) - //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build()) + //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build()) //getAAIClient().connect(allottedResourceUri,ssServiceuri) //execution.setVariable("aaiARPath", allottedResourceUri.build().toString()); @@ -191,7 +189,7 @@ class DoCreateTnNssiInstance extends AbstractServiceTaskProcessor { resource.setModelInvariantId(modelInvariantId) resource.setModelVersionId(modelVersionId) - AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIObjectType.LOGICAL_LINK, logicalLinkId) + AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) getAAIClient().create(logicalLinkUri, resource) } } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy index d5469c81a2..8eded75e44 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy @@ -26,7 +26,9 @@ import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +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.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -228,8 +230,8 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces String serviceType = execution.getVariable("serviceType") String serviceId = execution.getVariable("serviceId") - AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,nsInstanceId) - AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,serviceId) + AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nsInstanceId)) + AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceId)) try{ getAAIClient().connect(nsUri,relatedServiceUri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index 366cdfdb09..f19d064c8e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -32,6 +32,14 @@ import org.json.JSONArray import org.json.JSONObject import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aaiclient.client.aai.AAIResourcesClient +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.logging.filter.base.ErrorCode import org.onap.logging.filter.base.ONAPComponents; import org.onap.so.bpmn.common.scripts.AaiUtil @@ -51,14 +59,6 @@ import org.onap.so.bpmn.core.json.DecomposeJsonUtil import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -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.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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.onap.so.db.catalog.beans.HomingInstance import org.onap.so.logger.LoggingAnchor @@ -303,7 +303,7 @@ public class DoCreateVfModule extends VfModuleBase { } try{ - AAIResourceUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) AAIResourcesClient aaiRC = new AAIResourcesClient() AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI) Map<String, Object> aaiJson = aaiRW.asMap() @@ -690,7 +690,7 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleId = execution.getVariable('DCVFM_vfModuleId') AaiUtil aaiUriUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE) String endPoint = aaiUriUtil.createAaiUri(uri) try { @@ -774,7 +774,7 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleName = execution.getVariable('DCVFM_vfModuleName') AaiUtil aaiUriUtil = new AaiUtil(this) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, vnfId).queryParam("vf-module-name",vfModuleName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModules()).queryParam("vf-module-name",vfModuleName) String endPoint = aaiUriUtil.createAaiUri(uri) HttpClient client = httpClientFactory.newXmlClient(new URL(endPoint), ONAPComponents.AAI) @@ -909,7 +909,7 @@ public class DoCreateVfModule extends VfModuleBase { String serviceOperation = "" if (element.equals("vnf")) { AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('DCVFM_vnfId')) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(execution.getVariable('DCVFM_vnfId'))) AAIResultWrapper wrapper = resourceClient.get(uri) Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class) @@ -1792,7 +1792,7 @@ public class DoCreateVfModule extends VfModuleBase { // Prepare AA&I url AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion)) def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable("DCVFM_queryCloudRegionRequest", queryCloudRegionRequest) @@ -1923,7 +1923,7 @@ public class DoCreateVfModule extends VfModuleBase { String fqdn = fqdnList[i] // Query AAI for this network policy FQDN - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", fqdn) AAIResourcesClient resourceClient = new AAIResourcesClient() @@ -1944,8 +1944,8 @@ public class DoCreateVfModule extends VfModuleBase { policy.setNetworkPolicyId(networkPolicyId) policy.setNetworkPolicyFqdn(fqdn) policy.setHeatStackId(execution.getVariable("DCVFM_heatStackId")) - - AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + + AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)) resourceClient.create(netUri, policy) rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index b3c4698ab8..4b495e314e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -34,11 +34,12 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.aaiclient.client.aai.AAIObjectPlurals import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger @@ -507,7 +508,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ try { // Query AAI for this network policy FQDN - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", fqdn) Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri) @@ -516,7 +517,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ NetworkPolicy networkPolicy = networkPolicies.get().getNetworkPolicy().get(0) try{ - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId()) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicy.getNetworkPolicyId())) getAAIClient().delete(delUri) execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", 200) logger.debug("AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + 200) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy index 80f6e0edb2..0e153b73e6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy @@ -23,24 +23,24 @@ package org.onap.so.bpmn.infrastructure.scripts +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroups +import org.onap.aaiclient.client.aai.AAIObjectType +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectPlurals -import org.onap.aaiclient.client.aai.AAIObjectType -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.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.NotFoundException - public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( DoCreateVfModuleVolumeRollback.class); @@ -133,7 +133,7 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor volumeGroupName = testVolumeGroupName } - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion).volumeGroups()).queryParam("volume-group-name", volumeGroupName) try { Optional<VolumeGroups> volumeGroups = getAAIClient().get(VolumeGroups.class, uri) if (volumeGroups.isPresent()) { @@ -154,7 +154,7 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor String cloudRegion = execution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId") String volumeGroupId = callRESTQueryAAIVolGrpName(execution, cloudRegion) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion).volumeGroup(volumeGroupId)) try { getAAIClient().delete(uri) }catch(NotFoundException ignored){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy index b1d909b6b4..d65f144b3d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy @@ -28,6 +28,12 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.VolumeGroup import org.onap.aai.domain.yang.VolumeGroups +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -36,11 +42,6 @@ import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -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.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults import org.onap.so.db.catalog.beans.OrchestrationStatus import org.slf4j.Logger @@ -148,7 +149,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { String serviceInstanceId = execution.getVariable('serviceInstanceId') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) if(!resourceClient.exists(uri)){ (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") @@ -174,7 +175,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion)) def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -215,7 +216,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { def cloudRegion = execution.getVariable('lcpCloudRegionId') try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion).volumeGroups()).queryParam("volume-group-name", volumeGroupName) Optional<VolumeGroups> volumeGroups = getAAIClient().get(VolumeGroups.class,uri) if(volumeGroups.isPresent()){ VolumeGroup volumeGroup = volumeGroups.get().getVolumeGroup().get(0); @@ -292,9 +293,9 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { logger.debug("volumeGroupId to be used: " + volumeGroupId) - AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, cloudRegion, volumeGroupId) - AAIResourceUri tenantUri = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId) - AAIResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).volumeGroup(volumeGroupId)) + AAIResourceUri tenantUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId)) + AAIResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) try { getAAIClient().create(volumeGroupUri, volumeGroup) getAAIClient().connect(volumeGroupUri, vnfUri) @@ -504,7 +505,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { String cloudOwner = execution.getVariable('cloudOwner') String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse") def heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, cloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).volumeGroup(volumeGroupId)) execution.setVariable(prefix+"heatStackId", heatStackID) @@ -534,7 +535,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { public void callRESTQueryAAIGenericVnf(DelegateExecution execution, isDebugEnabled) { def vnfId = execution.getVariable('vnfId') - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) try { Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class, uri) if (genericVnf.isPresent()) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index 488f2d85ac..1bb5ad1787 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -30,6 +30,7 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -109,7 +110,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { String vnfName = execution.getVariable("vnfName") if (vnfName.equals("") || vnfName.equals("null")) { AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable("vnfId")) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(execution.getVariable("vnfId"))) if(resourceClient.exists(uri)){ exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.") } @@ -281,7 +282,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) if(resourceClient.exists(uri)){ Map<String, String> keys = uri.getURIKeys() @@ -355,10 +356,10 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { payload.put("nf-naming-code", nfNamingCode); AAIResourcesClient resourceClient = new AAIResourcesClient(); - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) resourceClient.create(uri, payload) - AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) resourceClient.connect(uri, siUri) }catch(Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy index 76629dd1ba..4a555503a3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy @@ -52,6 +52,8 @@ import org.w3c.dom.NodeList import org.xml.sax.InputSource 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.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient @@ -453,7 +455,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess String serviceInstanceId = execution.getVariable("serviceInstanceId") AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) resourceClient.delete(serviceInstanceUri) logger.trace("Exited deleteServiceInstance") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy index 53a98c2ec6..b9a3eab28a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy @@ -22,35 +22,32 @@ */ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor -import org.onap.aai.domain.yang.AllottedResource -import org.onap.logging.filter.base.ErrorCode - -import javax.ws.rs.core.UriBuilder - import static org.apache.commons.lang3.StringUtils.*; - +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.UriBuilder import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray +import org.json.JSONObject +import org.onap.aai.domain.yang.AllottedResource +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory - import org.springframework.web.util.UriUtils; -import org.onap.aaiclient.client.aai.AAIResourcesClient -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.aai.entities.uri.AAIUriFactory -import org.json.JSONObject -import javax.ws.rs.NotFoundException import groovy.json.* @@ -174,7 +171,7 @@ public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProce String serviceType = execution.getVariable('serviceType') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) String json = wrapper.getJson() @@ -582,7 +579,7 @@ public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProce private Optional<AllottedResource> getAaiAr(DelegateExecution execution, String relink) { def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')' logger.info("Entered " + method) - AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(relink).build()) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(Types.ALLOTTED_RESOURCE, UriBuilder.fromPath(relink).build()) return getAAIClient().get(AllottedResource.class,uri) } /** diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy index 2ca0da4cbb..10a559475f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeAllocateAccessNSSI.groovy @@ -33,6 +33,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.logging.filter.base.ONAPComponents import org.onap.so.beans.nsmf.DeAllocateNssi import org.onap.so.beans.nsmf.EsrInfo @@ -54,6 +56,7 @@ import org.slf4j.LoggerFactory import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.JsonObject + /** * Internal AN NSSMF to handle NSSI Deallocation */ @@ -274,8 +277,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { String subscriptionServiceType = execution.getVariable("subscriptionServiceType") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, anNfNssiId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(anNfNssiId)) if (!client.exists(uri)) { logger.debug("AN NF Service Instance was not found in aai : ${anNfNssiId}") }else { @@ -294,8 +296,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { String subscriptionServiceType = execution.getVariable("subscriptionServiceType") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, anNfNssiId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(anNfNssiId)) if (!client.exists(uri)) { logger.debug("AN NF Service Instance was not found in aai : ${anNfNssiId}") }else { @@ -455,8 +456,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { Map<String,ServiceInstance> relatedInstances = new HashMap<>() AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, instanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") } @@ -470,8 +470,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { String relatioshipurl = relationship.getRelatedLink() String serviceInstanceId = relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) - uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, serviceInstanceId) + uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") @@ -545,7 +544,7 @@ class DoDeAllocateAccessNSSI extends AbstractServiceTaskProcessor { private void deleteServiceInstanceInAAI(DelegateExecution execution,String instanceId) { try { - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), instanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(instanceId)) getAAIClient().delete(serviceInstanceUri) logger.debug("${Prefix} Exited deleteServiceInstance") }catch(Exception e){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy index 5dd70a0ab9..c94e2dd67d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy @@ -33,12 +33,13 @@ import org.onap.aai.domain.yang.ServiceInstance import org.onap.aai.domain.yang.Tenant import org.onap.aai.domain.yang.VfModule import org.onap.aaiclient.client.aai.AAIClient -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient 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.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -356,8 +357,8 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { String nssiId = currentNSSI['nssiId'] String nsiId = currentNSSI['nsiId'] - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) - AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nsiId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId)) try { client.disconnect(nssiUri, nsiUri) @@ -381,7 +382,7 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI { def currentNSSI = execution.getVariable("currentNSSI") String nssiId = currentNSSI['nssiId'] - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) try { getAAIClient().delete(nssiUri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index 0c795b3bd1..9d6c4a1b2a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -19,34 +19,26 @@ */ package org.onap.so.bpmn.infrastructure.scripts -import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.logging.filter.base.ONAPComponents +import org.json.JSONObject +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.beans.nsmf.DeAllocateNssi -import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.beans.nsmf.EsrInfo -import org.onap.so.beans.nsmf.JobStatusRequest -import org.onap.so.beans.nsmf.JobStatusResponse import org.onap.so.beans.nsmf.NetworkType -import org.onap.so.beans.nsmf.NssiDeAllocateRequest import org.onap.so.beans.nsmf.NssiResponse +import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils import org.onap.so.bpmn.common.scripts.RequestDBUtil -import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.domain.ServiceArtifact import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.json.JSONObject -import javax.ws.rs.core.Response class DoDeallocateNSSI extends AbstractServiceTaskProcessor @@ -322,7 +314,8 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor try { LOGGER.debug("delete nssiServiceInstanceId:${nssiServiceInstanceId}, profileId:${profileId}") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiServiceInstanceId, profileId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiServiceInstanceId).sliceProfile(profileId)) if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy index 7681bf9346..a410b93d16 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssi.groovy @@ -29,6 +29,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.RequestDBUtil @@ -111,10 +113,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { void deleteServiceInstance(DelegateExecution execution) { try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - execution.getVariable("serviceInstanceID")) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("serviceInstanceID"))) client.delete(uri) } catch (BpmnError e) { throw e @@ -134,7 +133,7 @@ class DoDeallocateTnNssi extends AbstractServiceTaskProcessor { ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, tnNssiId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(tnNssiId)) client.update(uri, si) } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index 0a7753e9e5..ef94ff1d16 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -52,6 +52,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.logging.filter.base.ONAPComponents; @@ -176,7 +178,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable('globalSubscriberId') String serviceType = execution.getVariable('serviceType') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) if (!resourceClient.exists(serviceInstanceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } @@ -658,7 +660,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceId") AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) resourceClient.delete(serviceInstanceUri) logger.trace("Exited deleteServiceInstance") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index bee9ad260b..02200284df 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -32,6 +32,7 @@ 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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.logging.filter.base.ErrorCode import org.onap.logging.filter.base.ONAPComponents; @@ -256,7 +257,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() Boolean isVfRelationshipExist = false try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)).depth(Depth.ALL) Optional<L3Network> l3Network = getAAIClient().get(L3Network.class,uri); AAIResultWrapper wrapper = getAAIClient().get(uri); Optional<Relationships> relationships = wrapper.getRelationships() @@ -266,13 +267,13 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryAAIResponse", l3Network.get()) execution.setVariable(Prefix + "isAAIGood", true) if (relationships.isPresent()){ - if(!relationships.get().getRelatedAAIUris(AAIObjectType.VF_MODULE).isEmpty()){ + if(!relationships.get().getRelatedUris(Types.VF_MODULE).isEmpty()){ execution.setVariable(Prefix + "isVfRelationshipExist", true) isVfRelationshipExist = true String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage) }else{ - List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) + List<AAIResourceUri> tenantURIList = relationships.get().getRelatedUris(Types.TENANT) for(AAIResourceUri tenantURI: tenantURIList){ if(execution.getVariable(Prefix + "tenantId") == null) { String tenantId = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) @@ -280,7 +281,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { logger.debug(" Get AAI getTenantId() : " + tenantId) } } - List<AAIResourceUri> cloudRegionURIList = relationships.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) + List<AAIResourceUri> cloudRegionURIList = relationships.get().getRelatedUris(Types.CLOUD_REGION) for(AAIResourceUri tenantURI: cloudRegionURIList){ if(execution.getVariable(Prefix + "lcpCloudRegion") == null) { String lcpCloudRegion = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId) @@ -322,7 +323,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { // Prepare AA&I url AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion)) def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index cda7c321ac..85cbf32989 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -32,6 +32,7 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -285,7 +286,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable('serviceInstanceId') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) if(resourceClient.exists(uri)){ execution.setVariable("GENGS_FoundIndicator", true) @@ -307,9 +308,9 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { AAIResultWrapper wrapper = resourceClient.get(uri) if(wrapper.getRelationships().isPresent()){ - List<AAIResourceUri> uriList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE) - uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF)) - uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.L3_NETWORK)) + List<AAIResourceUri> uriList = wrapper.getRelationships().get().getRelatedUris(Types.ALLOTTED_RESOURCE) + uriList.addAll(wrapper.getRelationships().get().getRelatedUris(Types.GENERIC_VNF)) + uriList.addAll(wrapper.getRelationships().get().getRelatedUris(Types.L3_NETWORK)) if(uriList.isEmpty()){ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) @@ -372,7 +373,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceId") AAIResourcesClient resourceClient = new AAIResourcesClient(); - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) resourceClient.delete(serviceInstanceUri) logger.trace("Exited deleteServiceInstance") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy index 2f78c3d551..c4321220fd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy @@ -19,6 +19,9 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang3.StringUtils.isBlank +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource @@ -27,21 +30,20 @@ import org.onap.aai.domain.yang.Relationship import org.onap.aai.domain.yang.ServiceInstance import org.onap.aai.domain.yang.ServiceProfile import org.onap.aai.domain.yang.ServiceProfiles +import org.onap.aaiclient.client.aai.AAIObjectName +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.OofUtils -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.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.core.Response -import javax.ws.rs.NotFoundException - -import static org.apache.commons.lang3.StringUtils.isBlank /** * This groovy class supports the <class>DoDeleteSliceService.bpmn</class> process. @@ -104,7 +106,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { try { String errorMsg = "query e2e slice service from aai failed" - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, serviceInstanceId, errorMsg) Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class) if(si.isPresent()) { @@ -121,7 +123,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { if (relatedTo.toLowerCase() == "service-instance") { String relatioshipurl = relationship.getRelatedLink() String instanceId = relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) - AAIResultWrapper wrapper1 = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, instanceId, errorMsg) + AAIResultWrapper wrapper1 = queryAAI(execution, Types.SERVICE_INSTANCE, instanceId, errorMsg) Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) if (serviceInstance.isPresent()) { ServiceInstance instance = serviceInstance.get() @@ -156,7 +158,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { try { String errorMsg = "query allotted resource from aai failed." - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.ALLOTTED_RESOURCE_ALL, serviceInstanceId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.ALLOTTED_RESOURCES, serviceInstanceId, errorMsg) Optional<AllottedResources> ars = wrapper?.asBean(AllottedResources.class) if(ars.isPresent() && ars.get().getAllottedResource()) { @@ -191,7 +193,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { try { String errorMsg = "query nsi from aai failed." - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, nsiId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, nsiId, errorMsg) Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class) List<String> nssiIdList = [] String msg = "nsiId:${nsiId},nssiIdList:" @@ -205,7 +207,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { { String relatedLink = relationship.getRelatedLink()?:"" String instanceId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : "" - AAIResultWrapper wrapper1 = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, instanceId, errorMsg) + AAIResultWrapper wrapper1 = queryAAI(execution, Types.SERVICE_INSTANCE, instanceId, errorMsg) Optional<ServiceInstance> serviceInstance = wrapper1.asBean(ServiceInstance.class) if (serviceInstance.isPresent()) { ServiceInstance instance = serviceInstance.get() @@ -245,7 +247,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String errorMsg = "query nssi list from aai failed" for(String nssiId : nssiIdList) { - AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, nssiId, errorMsg) + AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, nssiId, errorMsg) Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class) if(si.isPresent()) { @@ -329,21 +331,30 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { /** * query AAI * @param execution - * @param aaiObjectType + * @param aaiObjectName * @param instanceId * @return AAIResultWrapper */ - private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg) + private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectName aaiObjectName, String instanceId, String errorMsg) { LOGGER.trace(" *****${PREFIX} Start queryAAI *****") String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) - if (!getAAIClient().exists(resourceUri)) { + org.onap.aaiclient.client.generated.fluentbuilders.ServiceInstance serviceInstanceType = AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(instanceId) + def type + if (aaiObjectName == Types.ALLOTTED_RESOURCES) { + type = serviceInstanceType.allottedResources() + } else if (aaiObjectName == Types.SLICE_PROFILES) { + type = serviceInstanceType.sliceProfiles() + } else { + type = serviceInstanceType + } + def uri = AAIUriFactory.createResourceUri(type) + if (!getAAIClient().exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } - AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(uri, NotFoundException.class) LOGGER.trace(" *****${PREFIX} Exit queryAAI *****") return wrapper } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy index 42f4cb7bd7..1ec11c67e9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy @@ -32,6 +32,8 @@ import org.onap.so.client.HttpClientFactory import org.onap.aaiclient.client.aai.AAIObjectType 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.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.logging.filter.base.ONAPComponents; @@ -121,8 +123,8 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") String serviceId = execution.getVariable("serviceId") - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceId) - AAIResourceUri nsServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nsInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceId)) + AAIResourceUri nsServiceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nsInstanceId)) try { getAAIClient().disconnect(serviceInstanceUri, nsServiceInstanceUri) }catch(Exception e){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index 33a1ece091..3bc8daa98c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -39,11 +39,12 @@ import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectPlurals import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -486,7 +487,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ for (i in 0..fqdnCount-1) { String fqdn = fqdnList[i] // Query AAI for this network policy FQDN - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", fqdn) try { Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri) @@ -498,7 +499,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ def networkPolicyId = networkPolicy.getNetworkPolicyId() logger.debug("Deleting network-policy with network-policy-id " + networkPolicyId) try { - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)) getAAIClient().delete(delUri) execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", 200) } catch (Exception e) { @@ -606,7 +607,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ def vnfId = execution.getVariable('vnfId') def vfModuleId = execution.getVariable('vfModuleId') - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)) try { Optional<org.onap.aai.domain.yang.VfModule> vfModule = getAAIClient().get(org.onap.aai.domain.yang.VfModule.class, uri); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index 786cd3d747..00bebdf54a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -41,11 +41,12 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.aaiclient.client.graphinventory.entities.uri.Depth -import org.onap.aaiclient.client.aai.AAIObjectPlurals import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -142,7 +143,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { try { def vnfId = execution.getVariable('vnfId') - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE) try { Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri) @@ -514,7 +515,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { // Query AAI for this network policy FQDN - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", fqdn) try { @@ -530,7 +531,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { // Retrieve the resource version for this network policy try { - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)) getAAIClient().delete(delUri) execution.setVariable("DDVFMV_aaiDeleteNetworkPolicyReturnCode", 200) logger.debug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + 200) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy index 355b5f77c0..22b16d0e82 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -32,6 +32,7 @@ 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.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -122,7 +123,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ String cloudRegion = execution.getVariable('lcpCloudRegionId') AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion)) def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -159,7 +160,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ String cloudRegion = execution.getVariable(prefix+'aicCloudRegion') try { - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP , Defaults.CLOUD_OWNER.toString(), cloudRegion,volumeGroupId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion).volumeGroup(volumeGroupId)) Optional<VolumeGroup> volumeGroupOps = getAAIClient().get(VolumeGroup.class,resourceUri) if(volumeGroupOps.present) { VolumeGroup volumeGroup = volumeGroupOps.get() @@ -173,11 +174,11 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ String volumeGroupTenantId = null if(relationships.isPresent()){ - if(relationships.get().getRelatedAAIUris(AAIObjectType.VF_MODULE)){ + if(relationships.get().getRelatedUris(Types.VF_MODULE)){ logger.debug('Volume Group ' + volumeGroupId + ' currently in use') exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") } - for(AAIResourceUri aaiResourceUri: relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)){ + for(AAIResourceUri aaiResourceUri: relationships.get().getRelatedUris(Types.TENANT)){ volumeGroupTenantId = aaiResourceUri.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } @@ -264,7 +265,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ String cloudRegion = execution.getVariable(prefix+'aicCloudRegion') try { - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion).volumeGroup(volumeGroupId)) getAAIClient().delete(resourceUri) logger.debug("Volume group $volumeGroupId deleted.") }catch (NotFoundException ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy index 25fbc93c0a..181e62ee4c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy @@ -40,6 +40,8 @@ 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.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.Node @@ -104,14 +106,14 @@ class DoDeleteVnf extends AbstractServiceTaskProcessor { try { AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(execution.getVariable('vnfId'))) if(resourceClient.exists(uri)){ execution.setVariable("GENGV_FoundIndicator", true) AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.ONE)) if(wrapper.getRelationships().isPresent()){ - List<AAIResourceUri> relationships = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) - relationships.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.L3_NETWORK)) + List<AAIResourceUri> relationships = wrapper.getRelationships().get().getRelatedUris(Types.CLOUD_REGION) + relationships.addAll(wrapper.getRelationships().get().getRelatedUris(Types.L3_NETWORK)) if(!relationships.isEmpty()){ execution.setVariable("DoDVNF_vnfInUse", true) }else{ @@ -148,7 +150,7 @@ class DoDeleteVnf extends AbstractServiceTaskProcessor { String vnfId = execution.getVariable("DoDVNF_vnfId") AAIResourcesClient resourceClient = new AAIResourcesClient(); - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) resourceClient.delete(uri) logger.trace("COMPLETED deleteVnf") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index 2a0cb5e610..5d1e2a2eae 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -44,6 +44,8 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.aaiclient.client.graphinventory.entities.uri.Depth 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.aaiclient.client.aai.AAIObjectType import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum @@ -263,7 +265,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { try { def vnfId = execution.getVariable('vnfId') - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE) try { Optional<GenericVnf> genericVnfOp = getAAIClient().get(GenericVnf.class,uri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy index 2e7e728b44..f591855b5c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy @@ -51,6 +51,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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 javax.ws.rs.NotFoundException class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { @@ -588,8 +590,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { Map<String,ServiceInstance> relatedInstances = new HashMap<>() AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, instanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") } @@ -605,8 +606,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length()) AAIResourcesClient client01 = new AAIResourcesClient() - AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, serviceInstanceId) + AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) if (!client.exists(uri01)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai: ${serviceInstanceId} related to ${instanceId}") @@ -631,8 +631,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { String subscriptionServiceType = execution.getVariable("subscriptionServiceType") ServiceInstance serviceInstance = new ServiceInstance() AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, subscriptionServiceType, instanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(instanceId)) if (!client.exists(uri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai : ${instanceId}") } @@ -646,7 +645,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { } private void deleteServiceInstanceInAAI(DelegateExecution execution,String instanceId) { try { - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), instanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(instanceId)) getAAIClient().delete(serviceInstanceUri) logger.debug("${Prefix} Exited deleteServiceInstance") }catch(Exception e){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy index 1f25c733cd..ebeab3eb7d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy @@ -39,6 +39,8 @@ 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.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -78,7 +80,6 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class) - /** * Creates Slice Profile Instance * @param execution @@ -118,7 +119,7 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiId, sliceProfileID) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID)) client.create(uri, sliceProfile) currentNSSI['createdSliceProfile'] = sliceProfile @@ -145,8 +146,8 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI { String serviceType = currentNSSI['serviceType'] String nssiId = currentNSSI['nssiId'] - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) - AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiId, sliceProfileID) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileID)) try { SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile'] diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy index 0b7a5ff59b..03a726c52c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssi.groovy @@ -30,6 +30,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.RequestDBUtil @@ -132,10 +134,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { void deleteServiceInstance(DelegateExecution execution) { try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - execution.getVariable("serviceInstanceID")) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("serviceInstanceID"))) client.delete(uri) } catch (BpmnError e) { throw e @@ -151,7 +150,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable("serviceInstanceID") AAIResourcesClient resourceClient = getAAIClient() - AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) try { if (resourceClient.exists(ssServiceuri)) { @@ -214,7 +213,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { ss.setEnvironmentContext(snssai) ss.setServiceRole(serviceRole) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ssInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ssInstanceId)) client.update(uri, ss) } catch (BpmnError e) { throw e @@ -243,9 +242,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { sliceProfile.setReliability(new Object()) try { AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, execution.getVariable - ("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, sliceProfileId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceserviceInstanceId).sliceProfile(sliceProfileId)) client.update(uri, sliceProfile) } catch (BpmnError e) { @@ -263,9 +260,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { List<String> arIdList = execution.getVariable("arIdList") try { for (String arId : arIdList) { - AAIResourceUri arUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, - execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), - serviceInstanceId, arId) + AAIResourceUri arUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(serviceInstanceId).allottedResource(arId)) getAAIClient().delete(arUri) } @@ -274,9 +269,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { for (String networkStr : networkStrList) { String allottedResourceId = UUID.randomUUID().toString() - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, - execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), - execution.getVariable("sliceserviceInstanceId"), allottedResourceId) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(execution.getVariable("sliceserviceInstanceId")).allottedResource(allottedResourceId)) execution.setVariable("allottedResourceUri", allottedResourceUri) String modelInvariantId = execution.getVariable("modelInvariantUuid") String modelVersionId = execution.getVariable("modelUuid") @@ -319,7 +312,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { resource.setModelInvariantId(modelInvariantId) resource.setModelVersionId(modelVersionId) - AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIObjectType.LOGICAL_LINK, logicalLinkId) + AAIResourceUri logicalLinkUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLink(logicalLinkId)) getAAIClient().create(logicalLinkUri, resource) } } catch (Exception ex) { @@ -365,7 +358,7 @@ public class DoModifyTnNssi extends AbstractServiceTaskProcessor { ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) AAIResourcesClient client = getAAIClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceServiceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceServiceInstanceId)) client.update(uri, si) } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy index 6b91fec03e..615afcb8d7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy @@ -41,6 +41,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.springframework.web.util.UriUtils; import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -315,7 +317,7 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor { org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) client.update(uri, si) } catch (BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy index 154de6b887..5b16838c6a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy @@ -37,6 +37,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.bpmn.common.scripts.ExceptionUtil; @@ -241,7 +243,7 @@ public class DoUpdateE2EServiceInstanceRollback extends AbstractServiceTaskProce org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) client.update(uri, si) } catch (BpmnError e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index cf7bb22442..be82562898 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -37,6 +37,7 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -328,7 +329,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable('serviceInstanceId') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) if(!resourceClient.exists(uri)){ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Service Instance not found in aai") @@ -361,7 +362,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion)) def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) @@ -409,7 +410,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkId", networkId) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)).depth(Depth.ONE) AAIResultWrapper network = client.get(uri, NotFoundException.class) execution.setVariable(Prefix + "aaiIdReturnCode", "200") @@ -442,7 +443,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String networkId = utils.getNodeText(networkRequest, "network-id") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)).depth(Depth.ONE) AAIResultWrapper network = client.get(uri, NotFoundException.class) execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200") @@ -483,7 +484,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // get variables AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") if(queryIdAAIResponse.getRelationships().isPresent()){ - List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.VPN_BINDING) + List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedUris(Types.VPN_BINDING) logger.debug(Prefix + "vpnCount - " + uris.size()) @@ -555,7 +556,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // get variables AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") if(queryIdAAIResponse.getRelationships().isPresent()){ - List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY) + List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedUris(Types.NETWORK_POLICY) execution.setVariable(Prefix + "networkPolicyCount", uris.size()) logger.debug(Prefix + "networkPolicyCount - " + uris.size()) @@ -620,7 +621,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") if(queryIdAAIResponse.getRelationships().isPresent()){ - List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE) + List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedUris(Types.ROUTE_TABLE_REFERENCE) execution.setVariable(Prefix + "networkTableRefCount", uris.size()) logger.debug(Prefix + "networkTableRefCount - " + uris.size()) @@ -717,7 +718,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)) client.update(uri, l3Network) List<Subnet> subnets = oldL3Network.getSubnets().getSubnet() @@ -734,7 +735,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { subnet.setOrchestrationStatus("Active") } - AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId) + AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId).subnet(subnetId)) client.update(subUri, subnet) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index 00cf2a3ff1..b7bbbf91a5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -25,6 +25,14 @@ package org.onap.so.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.CatalogDbUtils @@ -37,12 +45,6 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum @@ -273,7 +275,7 @@ public class DoUpdateVfModule extends VfModuleBase { } try{ - AAIResourceUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) AAIResourcesClient aaiRC = new AAIResourcesClient() AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI) Map<String, Object> aaiJson = aaiRW.asMap() @@ -411,7 +413,7 @@ public class DoUpdateVfModule extends VfModuleBase { // Prepare AA&I url AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegion)) def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest) @@ -1018,7 +1020,7 @@ public class DoUpdateVfModule extends VfModuleBase { try { def vnfId = execution.getVariable('DOUPVfMod_vnfId') - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE) try { Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy index 7e180ca542..0285ae219c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -41,7 +41,9 @@ import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.client.HttpClient import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +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.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -159,7 +161,7 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUriUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE) String endPoint = aaiUriUtil.createAaiUri(uri) logger.debug("AAI endPoint: " + endPoint) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 3367920064..7d2e536af9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -31,6 +31,8 @@ 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.RequestDBUtil @@ -302,7 +304,7 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceServiceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceServiceInstanceId)) client.update(uri, si) } catch (BpmnError e) { throw e diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy index 282e9611fd..3a199216da 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy @@ -44,6 +44,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.springframework.web.util.UriUtils import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -178,7 +180,7 @@ public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor String serviceType = execution.getVariable('serviceType') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)) AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy index 148ab1898f..a50f96adab 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -33,6 +33,7 @@ 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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -185,7 +186,7 @@ class UpdateVfModuleVolume extends VfModuleBase { try { def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(),aicCloudRegion,volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId)) AAIResultWrapper wrapper = getAAIClient().get(uri) Optional<VolumeGroup> volumeGroup = wrapper.asBean(VolumeGroup.class) if(volumeGroup.isPresent()){ @@ -193,7 +194,7 @@ class UpdateVfModuleVolume extends VfModuleBase { execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId) Optional<Relationships> relationships = wrapper.getRelationships() if(relationships.isPresent()){ - List<AAIResourceUri> resourceUriList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) + List<AAIResourceUri> resourceUriList = relationships.get().getRelatedUris(Types.TENANT) if(CollectionUtils.isNotEmpty(resourceUriList)){ AAIResourceUri tenantUri = resourceUriList.get(0) String volumeGroupTenantId = tenantUri.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index b6873a19fe..b7757715e9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -29,12 +29,12 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.VfModule 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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -207,14 +207,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId)) AAIResultWrapper wrapper = getAAIClient().get(uri) Optional<VolumeGroup> volumeGroup = wrapper.asBean(VolumeGroup.class) if (volumeGroup.isPresent()) { execution.setVariable('UPDVfModVol_aaiVolumeGroupResponse', volumeGroup.get()) Optional<Relationships> relationships = wrapper.getRelationships() if (relationships.isPresent()) { - List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) + List<AAIResourceUri> tenantURIList = relationships.get().getRelatedUris(Types.TENANT) if (!isEmpty(tenantURIList)) { String volumeGroupTenantId = tenantURIList.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId) @@ -224,7 +224,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion) } - execution.setVariable('UPDVfModVol_relatedVfModuleLink', relationships.get().getRelatedLinks(AAIObjectType.VF_MODULE).get(0)) + execution.setVariable('UPDVfModVol_relatedVfModuleLink', relationships.get().getRelatedLinks(Types.VF_MODULE).get(0)) } else { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId @@ -249,7 +249,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def vnfId = execution.getVariable('vnfId') - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) try { Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class, uri) if (genericVnf.isPresent()) { @@ -273,7 +273,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { String queryAAIVfModuleRequest = execution.getVariable('UPDVfModVol_relatedVfModuleLink') execution.setVariable('UPDVfModVol_personaModelId', '') - AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VF_MODULE, UriBuilder.fromPath(queryAAIVfModuleRequest).build()) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(Types.VF_MODULE, UriBuilder.fromPath(queryAAIVfModuleRequest).build()) try{ Optional<VfModule> vfModule = getAAIClient().get(VfModule.class,uri) if(vfModule.isPresent()){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy index aa3512379a..c797f924b7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy @@ -32,6 +32,7 @@ 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.appc.client.lcm.model.Action import org.onap.appc.client.lcm.model.ActionIdentifiers import org.onap.appc.client.lcm.model.Flags @@ -218,7 +219,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { logger.debug("cloudRegionId is: {}", cloudRegionId) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) // Check if this VNF exists if (!client.exists(genericVnfUri)) { logger.debug("VNF with vnfId {} does not exist in A&AI", vnfId) @@ -243,7 +244,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { Relationships relationships = aaiRW.getRelationships().get() if (relationships != null) { - List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER) + List<AAIResourceUri> vserverUris = relationships.getRelatedUris(Types.VSERVER) JSONArray vserverIds = new JSONArray() JSONArray vserverSelfLinks = new JSONArray() @@ -436,7 +437,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable("vnfId") logger.debug("vnfId is: {}", vnfId) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) AAIResultWrapper aaiRW = client.get(genericVnfUri) Map<String, Object> result = aaiRW.asMap() boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) @@ -488,7 +489,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { def transactionLoggingUuid = UUID.randomUUID().toString() def vnfId = execution.getVariable("vnfId") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) Map<String, Boolean> request = new HashMap<>() request.put("is-closed-loop-disabled", setDisabled) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy index ddc80f6a50..ee173caeb1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy @@ -32,6 +32,8 @@ import org.onap.aaiclient.client.aai.* import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -360,7 +362,7 @@ public class VnfConfigUpdate extends VnfCmBase { def vnfId = execution.getVariable("vnfId") logger.debug("vnfId is: {}", vnfId) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) AAIResultWrapper aaiRW = client.get(genericVnfUri) Map<String, Object> result = aaiRW.asMap() boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) @@ -412,7 +414,7 @@ public class VnfConfigUpdate extends VnfCmBase { def transactionLoggingUuid = UUID.randomUUID().toString() def vnfId = execution.getVariable("vnfId") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) Map<String, Boolean> request = new HashMap<>() request.put("is-closed-loop-disabled", setDisabled) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy index 603d5e4dd9..4fad3c33b4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy @@ -35,6 +35,8 @@ import org.onap.aaiclient.client.aai.* import org.onap.aaiclient.client.aai.entities.AAIResultWrapper 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.client.appc.ApplicationControllerClient import org.onap.so.client.appc.ApplicationControllerSupport import org.onap.so.logger.LoggingAnchor @@ -380,7 +382,7 @@ public class VnfInPlaceUpdate extends VnfCmBase { def vnfId = execution.getVariable("vnfId") logger.debug("vnfId is: " + vnfId) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) AAIResultWrapper aaiRW = client.get(genericVnfUri) Map<String, Object> result = aaiRW.asMap() boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) @@ -431,7 +433,7 @@ public class VnfInPlaceUpdate extends VnfCmBase { def transactionLoggingUuid = UUID.randomUUID().toString() def vnfId = execution.getVariable("vnfId") AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) Map<String, Boolean> request = new HashMap<>() request.put("is-closed-loop-disabled", setDisabled) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index dd1dae6edd..236e9d6266 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -31,6 +31,7 @@ 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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -205,7 +206,7 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { String serviceInstanceId = execution.getVariable('serviceInstanceId') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) if(resourceClient.exists(uri)){ AAIResultWrapper wrapper = resourceClient.get(uri, NotFoundException.class) @@ -217,13 +218,13 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { if(relationships.isPresent()){ - List<AAIResourceUri> vnfUris = relationships.get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF) + List<AAIResourceUri> vnfUris = relationships.get().getRelatedUris(Types.GENERIC_VNF) for(AAIResourceUri u:vnfUris){ Map<String, String> keys = u.getURIKeys() String vnfId = keys.get(AAIFluentTypeBuilder.Types.GENERIC_VNF.getUriParams().vnfId) relatedVnfIdList.add(vnfId) } - List<AAIResourceUri> arUris = relationships.get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE) + List<AAIResourceUri> arUris = relationships.get().getRelatedUris(Types.ALLOTTED_RESOURCE) for(AAIResourceUri u:arUris){ String ar = resourceClient.get(u).getJson() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy index 683b82e4a7..87c2f673ff 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -27,16 +27,17 @@ import javax.ws.rs.core.UriBuilder import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.* import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -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.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger @@ -168,7 +169,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ String serviceInstanceId = execution.getVariable('serviceInstanceId') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) if(resourceClient.exists(uri)){ execution.setVariable("CSI_resourceLink", uri.build().toString()) @@ -230,7 +231,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ String serviceInstanceId = execution.getVariable('parentServiceInstanceId') AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) //just to make sure the serviceInstance exists if (resourceClient.exists(uri)) { @@ -265,7 +266,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink") - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(siResourceLink, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(siResourceLink, Types.ALLOTTED_RESOURCE.getFragment(allottedResourceId)) execution.setVariable("aaiARPath", allottedResourceUri.build().toString()); String arType = execution.getVariable("allottedResourceType") @@ -283,7 +284,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ resource.setModelInvariantId(modelInvariantId) resource.setModelVersionId(modelVersionId) getAAIClient().create(allottedResourceUri, resource) - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(CSI_resourceLink).build()) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath(CSI_resourceLink).build()) getAAIClient().connect(allottedResourceUri,serviceInstanceUri) }catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy index 9782440e85..69ce713b71 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -22,26 +22,26 @@ package org.onap.so.bpmn.vcpe.scripts -import org.onap.so.logger.LoggingAnchor +import static org.apache.commons.lang3.StringUtils.isBlank +import javax.ws.rs.core.UriBuilder import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource +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.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.*; import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.logging.filter.base.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.core.UriBuilder -import static org.apache.commons.lang3.StringUtils.isBlank - /** * This groovy class supports the <class>DoCreateAllottedResourceTXC.bpmn</class> process. * @@ -206,7 +206,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink") - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(siResourceLink, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(siResourceLink, Types.ALLOTTED_RESOURCE.getFragment(allottedResourceId)) execution.setVariable("aaiARPath", allottedResourceUri.build().toString()); String arType = execution.getVariable("allottedResourceType") @@ -224,7 +224,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ resource.setModelInvariantId(modelInvariantId) resource.setModelVersionId(modelVersionId) getAAIClient().create(allottedResourceUri, resource) - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(CSI_resourceLink).build()) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath(CSI_resourceLink).build()) getAAIClient().connect(allottedResourceUri,serviceInstanceUri) }catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java index 1cc68953f8..3021852734 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java @@ -23,11 +23,12 @@ package org.onap.so.bpmn.infrastructure.aai; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -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.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.servicedecomposition.bbobjects.GenericVnf; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,17 +37,19 @@ public class AAICreateResources extends AAIResource { private static final Logger logger = LoggerFactory.getLogger(AAICreateResources.class); public void createAAIProject(String projectName, String serviceInstance) { - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); + AAIResourceUri projectURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().project(projectName)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance)); getAaiClient().createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI); } public void createAAIOwningEntity(String owningEntityId, String owningEntityName, String serviceInstance) { - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri owningEntityURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntityId)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance)); Map<String, String> hashMap = new HashMap<>(); hashMap.put("owning-entity-name", owningEntityName); getAaiClient().createIfNotExists(owningEntityURI, Optional.of(hashMap)).connect(owningEntityURI, @@ -54,39 +57,44 @@ public class AAICreateResources extends AAIResource { } public boolean existsOwningEntity(String owningEntityId) { - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri owningEntityURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntityId)); return getAaiClient().exists(owningEntityURI); } public void connectOwningEntityandServiceInstance(String owningEntityId, String serviceInstance) { - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri owningEntityURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntityId)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance)); getAaiClient().connect(owningEntityURI, serviceInstanceURI); } public void createAAIPlatform(String platformName, String vnfId) { - AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourceUri platformURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().platform(platformName)); + AAIResourceUri genericVnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); getAaiClient().createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI); } public void createAAILineOfBusiness(String lineOfBusiness, String vnfId) { AAIResourceUri lineOfBusinessURI = - AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().lineOfBusiness(lineOfBusiness)); + AAIResourceUri genericVnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI); } public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId) { - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalCustomerId, serviceType, serviceInstanceId); + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalCustomerId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); getAaiClient().createIfNotExists(serviceInstanceURI, Optional.empty()); } public Optional<GenericVnf> getVnfInstance(String vnfId) { try { - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); AAIResultWrapper aaiResponse = getAaiClient().get(vnfURI); Optional<GenericVnf> vnf = aaiResponse.asBean(GenericVnf.class); return vnf; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java index 22166483b1..97adc4d25f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java @@ -22,10 +22,10 @@ package org.onap.so.bpmn.infrastructure.aai; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.common.scripts.ExceptionUtil; -import org.onap.aaiclient.client.aai.AAIObjectType; 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.scripts.ExceptionUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ public class AAIDeleteServiceInstance extends AAIResource implements JavaDelegat try { String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); getAaiClient().delete(serviceInstanceURI); execution.setVariable("GENDS_SuccessIndicator", true); } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java index c2e2a3c258..cc7eefcbd9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java @@ -27,11 +27,11 @@ import java.util.Map; import java.util.Optional; import org.onap.aai.domain.yang.OwningEntities; import org.onap.aai.domain.yang.OwningEntity; -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.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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,18 +40,20 @@ public class AAICreateResources { private static final Logger logger = LoggerFactory.getLogger(AAICreateResources.class); public void createAAIProject(String projectName, String serviceInstance) { - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); + AAIResourceUri projectURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().project(projectName)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance)); AAIResourcesClient aaiRC = new AAIResourcesClient(); aaiRC.createIfNotExists(projectURI, Optional.empty()).connect(projectURI, serviceInstanceURI); } public void createAAIOwningEntity(String owningEntityId, String owningEntityName, String serviceInstance) { - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri owningEntityURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntityId)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance)); Map<String, String> hashMap = new HashMap<>(); hashMap.put("owning-entity-name", owningEntityName); AAIResourcesClient aaiRC = new AAIResourcesClient(); @@ -59,7 +61,8 @@ public class AAICreateResources { } public boolean existsOwningEntity(String owningEntityId) { - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri owningEntityURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntityId)); AAIResourcesClient aaiRC = new AAIResourcesClient(); return aaiRC.exists(owningEntityURI); } @@ -67,8 +70,10 @@ public class AAICreateResources { protected OwningEntities getOwningEntityName(String owningEntityName) { AAIResourcesClient aaiRC = new AAIResourcesClient(); - return aaiRC.get(OwningEntities.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY) - .queryParam("owning-entity-name", owningEntityName)).orElseGet(() -> { + return aaiRC.get(OwningEntities.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntities()) + .queryParam("owning-entity-name", owningEntityName)) + .orElseGet(() -> { logger.debug("No Owning Entity matched by name"); return null; }); @@ -91,31 +96,35 @@ public class AAICreateResources { } public void connectOwningEntityandServiceInstance(String owningEntityId, String serviceInstance) { - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri owningEntityURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntityId)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance)); AAIResourcesClient aaiRC = new AAIResourcesClient(); aaiRC.connect(owningEntityURI, serviceInstanceURI); } public void createAAIPlatform(String platformName, String vnfId) { - AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourceUri platformURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().platform(platformName)); + AAIResourceUri genericVnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); AAIResourcesClient aaiRC = new AAIResourcesClient(); aaiRC.createIfNotExists(platformURI, Optional.empty()).connect(platformURI, genericVnfURI); } public void createAAILineOfBusiness(String lineOfBusiness, String vnfId) { AAIResourceUri lineOfBusinessURI = - AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().lineOfBusiness(lineOfBusiness)); + AAIResourceUri genericVnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); AAIResourcesClient aaiRC = new AAIResourcesClient(); aaiRC.createIfNotExists(lineOfBusinessURI, Optional.empty()).connect(lineOfBusinessURI, genericVnfURI); } public void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId) { - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalCustomerId, serviceType, serviceInstanceId); + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalCustomerId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); AAIResourcesClient aaiRC = new AAIResourcesClient(); aaiRC.createIfNotExists(serviceInstanceURI, Optional.empty()); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java index bb7415da93..df42e961bb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java @@ -22,11 +22,11 @@ package org.onap.so.bpmn.infrastructure.aai.groovyflows; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.common.scripts.ExceptionUtil; -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.Types; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +42,7 @@ public class AAIDeleteServiceInstance implements JavaDelegate { try { String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); AAIResourcesClient aaiRC = new AAIResourcesClient(); aaiRC.delete(serviceInstanceURI); execution.setVariable("GENDS_SuccessIndicator", true); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java index 001e166893..03ff55b90e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java @@ -22,11 +22,12 @@ package org.onap.so.bpmn.infrastructure.pnf.management; import java.util.Optional; import org.onap.aai.domain.yang.Pnf; -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.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.springframework.stereotype.Component; @Component @@ -52,8 +53,8 @@ public class PnfManagementImpl implements PnfManagement { @Override public void createRelation(String serviceInstanceId, String pnfName) { AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); - AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); + AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnfName)); new AAIResourcesClient().connect(serviceInstanceURI, pnfUri); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 99ed7b1e91..d1fc0a6353 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -54,19 +54,19 @@ import org.onap.aai.domain.yang.LogicalLinks; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.Pnf; import org.onap.aai.domain.yang.Relationship; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.onap.so.bpmn.core.domain.Resource; -import org.onap.so.bpmn.core.domain.ServiceDecomposition; -import org.onap.so.bpmn.core.json.JsonUtils; -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.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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.bpmn.core.domain.Resource; +import org.onap.so.bpmn.core.domain.ServiceDecomposition; +import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -448,7 +448,7 @@ public class ServicePluginFactory { public Map getTPsfromAAI(String serviceName) { Map<String, Object> tpInfo = new HashMap<>(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().logicalLinks()); AAIResourcesClient client = new AAIResourcesClient(); Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri); @@ -464,10 +464,10 @@ public class ServicePluginFactory { List<AAIResourceUri> pInterfaces = new ArrayList<>(); if (optRelationships.isPresent()) { Relationships relationships = optRelationships.get(); - if (!relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty()) { + if (!relationships.getRelatedUris(Types.EXT_AAI_NETWORK).isEmpty()) { isRemoteLink = true; } - pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE)); + pInterfaces.addAll(relationships.getRelatedUris(Types.P_INTERFACE)); if (isRemoteLink) { // find remote p interface AAIResourceUri localTP = null; @@ -502,8 +502,8 @@ public class ServicePluginFactory { tpInfo.put("local-access-node-id", localNodeId); logger.info("Get info for local TP :{}", localNodeId); - Optional<Pnf> optLocalPnf = - client.get(Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, localNodeId)); + Optional<Pnf> optLocalPnf = client.get(Pnf.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(localNodeId))); getTpInfoFromLocalTp(tpInfo, optLocalPnf); @@ -523,8 +523,8 @@ public class ServicePluginFactory { logger.info("Get info for remote TP:{}", remoteNodeId); String[] networkRefRemote = intfRemote.getNetworkRef().split("-"); - Optional<Pnf> optRemotePnf = - client.get(Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, remoteNodeId)); + Optional<Pnf> optRemotePnf = client.get(Pnf.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(remoteNodeId))); getTpInfoFromRemoteTp(tpInfo, networkRefRemote, optRemotePnf); @@ -584,14 +584,14 @@ public class ServicePluginFactory { if (uriString != null) { // get the pnfname String[] token = uriString.split("/"); - AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIObjectType.PNF, token[4]); + AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(token[4])); AAIResultWrapper wrapper = client.get(parent); Optional<Relationships> optRelationships = wrapper.getRelationships(); if (optRelationships.isPresent()) { Relationships relationships = optRelationships.get(); - return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty(); + return !relationships.getRelatedUris(Types.EXT_AAI_NETWORK).isEmpty(); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy index 1551533e53..61b4957310 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy @@ -30,6 +30,8 @@ import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.aaiclient.client.aai.AAIObjectType 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 javax.ws.rs.NotFoundException @@ -59,8 +61,8 @@ class CreateVFCNSResourceTest extends MsoGroovyTest{ when(mockExecution.getVariable("nsInstanceId")).thenReturn("nsInstanceId") doNothing().when(client).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class)) createVFCNSResource.addNSRelationship(mockExecution) - AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,"globalSubscriberId1","serviceType","nsInstanceId") - AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,"globalSubscriberId1","serviceType","serviceInstanceId") + AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("globalSubscriberId1").serviceSubscription("serviceType").serviceInstance("nsInstanceId")) + AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("globalSubscriberId1").serviceSubscription("serviceType").serviceInstance("serviceInstanceId")) Mockito.verify(client).connect(nsUri,relatedServiceUri) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy index 09b17701a6..c19cdfdb04 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy @@ -38,6 +38,8 @@ 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.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import static org.junit.Assert.assertEquals import static org.mockito.Mockito.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy index 39d0334bef..51d64af550 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy @@ -19,29 +19,29 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.Mockito.* +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before import org.junit.Test import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mockito +import org.onap.aaiclient.client.aai.AAIObjectType +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.logging.filter.base.ONAPComponents import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.core.WorkflowException import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -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.aai.entities.uri.AAIUriFactory - -import javax.ws.rs.NotFoundException -import javax.ws.rs.core.Response - -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertNotNull -import static org.mockito.ArgumentMatchers.eq -import static org.mockito.Mockito.* class DeleteCommunicationServiceTest extends MsoGroovyTest { @@ -96,7 +96,7 @@ class DeleteCommunicationServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") when(mockExecution.getVariable("serviceType")).thenReturn("5G") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be")) DeleteCommunicationService obj = spy(DeleteCommunicationService.class) AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceReturn()) @@ -126,8 +126,8 @@ class DeleteCommunicationServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("serviceType")).thenReturn("5G") AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceProfile()) - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") - AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-111111") + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be").communicationServiceProfiles()) + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be").communicationServiceProfile("5G-111111")) DeleteCommunicationService obj = spy(DeleteCommunicationService.class) when(obj.getAAIClient()).thenReturn(client) @@ -162,7 +162,7 @@ class DeleteCommunicationServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") when(mockExecution.getVariable("serviceType")).thenReturn("5G") - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be")) DeleteCommunicationService obj = spy(DeleteCommunicationService.class) when(obj.getAAIClient()).thenReturn(client) doNothing().when(client).delete(serviceInstanceUri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy index 1a9c6bb474..75b606c630 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy @@ -19,29 +19,27 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before import org.junit.Test import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mockito -import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.so.bpmn.core.WorkflowException -import org.onap.aaiclient.client.aai.AAIObjectType 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 javax.ws.rs.NotFoundException - -import static org.junit.Assert.assertNotNull -import static org.mockito.ArgumentMatchers.eq -import static org.mockito.Mockito.doNothing -import static org.mockito.Mockito.spy -import static org.mockito.Mockito.times -import static org.mockito.Mockito.when -import static org.mockito.Mockito.when -import static org.mockito.Mockito.when +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException class DeleteSliceServiceTest extends MsoGroovyTest { @Before @@ -86,7 +84,7 @@ class DeleteSliceServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("progress")).thenReturn("100") when(mockExecution.getVariable("operationContent")).thenReturn("NSMF completes slicing service termination.") - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be")) DeleteSliceService obj = spy(DeleteSliceService.class) when(obj.getAAIClient()).thenReturn(client) doNothing().when(client).delete(serviceInstanceUri) @@ -104,8 +102,8 @@ class DeleteSliceServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("serviceType")).thenReturn("5G") AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceProfile()) - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") - AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-2222222") + AAIPluralResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be").serviceProfiles()) + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be").serviceProfile("5G-2222222")) DeleteSliceService obj = spy(DeleteSliceService.class) when(obj.getAAIClient()).thenReturn(client) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy index 7137799433..0f0946dca2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy @@ -39,6 +39,8 @@ 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.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException import javax.ws.rs.NotFoundException @@ -251,7 +253,7 @@ class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest { volumeGroup.setVolumeGroupId("volumeGroupId1") when(mockExecution.getVariable("DELVfModVol_queryAAIVolGrpResponse")).thenReturn(volumeGroup) when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "region1","volumeGroupId1") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "region1").volumeGroup("volumeGroupId1")) doNothing().when(client).delete(resourceUri) deleteVfModuleVolumeInfraV1.deleteVolGrpId(mockExecution, true) verify(client).delete(resourceUri) @@ -263,7 +265,7 @@ class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest { volumeGroup.setVolumeGroupId("volumeGroupId1") when(mockExecution.getVariable("DELVfModVol_queryAAIVolGrpResponse")).thenReturn(volumeGroup) when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "region1","volumeGroupId1") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "region1").volumeGroup("volumeGroupId1")) doThrow(new NotFoundException("Not Found")).when(client).delete(resourceUri) try { deleteVfModuleVolumeInfraV1.deleteVolGrpId(mockExecution, true) @@ -282,7 +284,7 @@ class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest { volumeGroup.setVolumeGroupId("volumeGroupId1") when(mockExecution.getVariable("DELVfModVol_queryAAIVolGrpResponse")).thenReturn(volumeGroup) when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "region1","volumeGroupId1") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "region1").volumeGroup("volumeGroupId1")) doThrow(new GraphInventoryUriComputationException("Error")).when(client).delete(resourceUri) try { deleteVfModuleVolumeInfraV1.deleteVolGrpId(mockExecution, true) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy index a39ca04d71..69780939ef 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoActivateCoreNSSITest.groovy @@ -34,6 +34,8 @@ 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.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import static org.mockito.Mockito.spy import static org.mockito.Mockito.times @@ -81,7 +83,7 @@ class DoActivateCoreNSSITest extends MsoGroovyTest { DoActivateCoreNSSI obj = spy(DoActivateCoreNSSI.class) when(obj.getAAIClient()).thenReturn(client) - AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX")) when(client.exists(resourceUri1)).thenReturn(true) AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn()) when(client.get(resourceUri1, NotFoundException.class)).thenReturn(wrapper1) @@ -89,14 +91,14 @@ class DoActivateCoreNSSITest extends MsoGroovyTest { //networkServiceInstanceId when(mockExecution.getVariable("networkServiceInstanceId")).thenReturn("206535e7-77c9-4036-9387-3f1cf57b4379") - AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "206535e7-77c9-4036-9387-3f1cf57b4379") + AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("206535e7-77c9-4036-9387-3f1cf57b4379")) when(client.exists(resourceUri2)).thenReturn(true) AAIResultWrapper wrapper2 = new AAIResultWrapper(mockQueryNS()) when(client.get(resourceUri2, NotFoundException.class)).thenReturn(wrapper2) //Check Vnf when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") - AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("eeb66c6f-36bd-47ad-8294-48f46b1aa912")) when(client.exists(resourceUri3)).thenReturn(true) AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3) @@ -104,14 +106,14 @@ class DoActivateCoreNSSITest extends MsoGroovyTest { //Allotted Resources-1 //when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") - AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "0d3d3cce-46a8-486d-816a-954e71697c4e") + AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("0d3d3cce-46a8-486d-816a-954e71697c4e")) when(client.exists(resourceUri4)).thenReturn(true) AAIResultWrapper wrapper4 = new AAIResultWrapper(mockServiceProfile1()) when(client.get(resourceUri4, NotFoundException.class)).thenReturn(wrapper4) //Allotted Resources-2 //when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") - AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "1c7046f2-a5a3-4d7f-9da8-388ee641a795") + AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("1c7046f2-a5a3-4d7f-9da8-388ee641a795")) when(client.exists(resourceUri5)).thenReturn(true) AAIResultWrapper wrapper5 = new AAIResultWrapper(mockServiceProfile2()) when(client.get(resourceUri5, NotFoundException.class)).thenReturn(wrapper5) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy index e5799eca66..0ac48ad189 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreSharedSliceTest.groovy @@ -20,8 +20,6 @@ package org.onap.so.bpmn.infrastructure.scripts -import static org.junit.Assert.* - import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before import org.junit.Test @@ -33,6 +31,8 @@ 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.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import static org.mockito.Mockito.spy import static org.mockito.Mockito.times @@ -137,7 +137,7 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { DoAllocateCoreSharedSlice obj = spy(DoAllocateCoreSharedSlice.class) when(obj.getAAIClient()).thenReturn(client) - AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX") + AAIResourceUri resourceUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("NSSI-C-7Q4-HDBNJ-NSSMF-01-A-ZX")) when(client.exists(resourceUri1)).thenReturn(true) AAIResultWrapper wrapper1 = new AAIResultWrapper(mockQuerySliceServiceReturn()) when(client.get(resourceUri1, NotFoundException.class)).thenReturn(wrapper1) @@ -145,27 +145,27 @@ class DoAllocateCoreSharedSliceTest extends MsoGroovyTest { //networkServiceInstanceId when(mockExecution.getVariable("networkServiceInstanceId")).thenReturn("206535e7-77c9-4036-9387-3f1cf57b4379") - AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "206535e7-77c9-4036-9387-3f1cf57b4379") + AAIResourceUri resourceUri2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("206535e7-77c9-4036-9387-3f1cf57b4379")) when(client.exists(resourceUri2)).thenReturn(true) AAIResultWrapper wrapper2 = new AAIResultWrapper(mockQueryNS()) when(client.get(resourceUri2, NotFoundException.class)).thenReturn(wrapper2) //Check Vnf when(mockExecution.getVariable("vnfId")).thenReturn("eeb66c6f-36bd-47ad-8294-48f46b1aa912") - AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "eeb66c6f-36bd-47ad-8294-48f46b1aa912") + AAIResourceUri resourceUri3 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("eeb66c6f-36bd-47ad-8294-48f46b1aa912")) when(client.exists(resourceUri3)).thenReturn(true) AAIResultWrapper wrapper3 = new AAIResultWrapper(mockQueryVnf()) when(client.get(resourceUri3, NotFoundException.class)).thenReturn(wrapper3) //Allotted Resources-1 - AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "0d3d3cce-46a8-486d-816a-954e71697c4e") + AAIResourceUri resourceUri4 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("0d3d3cce-46a8-486d-816a-954e71697c4e")) when(client.exists(resourceUri4)).thenReturn(true) AAIResultWrapper wrapper4 = new AAIResultWrapper(mockServiceProfile1()) when(client.get(resourceUri4, NotFoundException.class)).thenReturn(wrapper4) //Allotted Resources-2 - AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "1c7046f2-a5a3-4d7f-9da8-388ee641a795") + AAIResourceUri resourceUri5 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("1c7046f2-a5a3-4d7f-9da8-388ee641a795")) when(client.exists(resourceUri5)).thenReturn(true) AAIResultWrapper wrapper5 = new AAIResultWrapper(mockServiceProfile2()) when(client.get(resourceUri5, NotFoundException.class)).thenReturn(wrapper5) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy index 33110b6e5b..6ea2be8e55 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateTnNssiTest.groovy @@ -29,6 +29,8 @@ import org.mockito.Mockito import org.onap.aaiclient.client.aai.AAIObjectType 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.common.scripts.MsoGroovyTest import static org.junit.Assert.assertNotNull @@ -82,7 +84,7 @@ class DoAllocateTnNssiTest extends MsoGroovyTest { // String sliceProfile = jsonUtil.getJsonValue(mockSliceParams(), "sliceProfile") // when(mockExecution.getVariable("sliceProfile")).thenReturn(sliceProfile) - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be")) DoCreateTnNssiInstance obj = spy(DoCreateTnNssiInstance.class) when(obj.getAAIClient()).thenReturn(client) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy index 5d29a72341..2c943ffc7c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy @@ -31,6 +31,8 @@ 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.AAISimpleUri 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.aaiclient.client.aai.entities.uri.ServiceInstanceUri import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.serviceinstancebeans.RequestDetails @@ -65,8 +67,8 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5G-999") - AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "NS-777") + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment("5G-999")) + AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment("NS-777")) ServiceInstance nssi = new ServiceInstance() nssi.setServiceInstanceId("5G-999") @@ -94,7 +96,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(client.get(nssiUri)).thenReturn(wrapperMock) when(wrapperMock.getRelationships()).thenReturn(orsMock) - when(rsMock.getRelatedAAIUris(AAIObjectType.SERVICE_INSTANCE)).thenReturn(arus) + when(rsMockgetRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(arus) when(client.get(ServiceInstance.class, aru)).thenReturn(networkServiceInstaneOpt) spy.getNetworkServiceInstance(mockExecution) @@ -125,10 +127,10 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { GenericVnf genericVNF = new GenericVnf() genericVNF.setVnfId("VNF-1") - AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkServiceInstance.getServiceInstanceId()) + AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstance.getServiceInstanceId())) Optional<GenericVnf> genericVnfOpt = Optional.of(genericVNF) - AAIResourceUri genericVNFUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVNF.getVnfId()) + AAIResourceUri genericVNFUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVNF.getVnfId())) currentNSSI.put("networkServiceInstanceUri", networkServiceInstanceUri) currentNSSI.put("networkServiceInstance", networkServiceInstance) @@ -143,7 +145,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock) when(wrapperMock.getRelationships()).thenReturn(orsMock) - when(rsMock.getRelatedAAIUris(AAIObjectType.GENERIC_VNF)).thenReturn(arus) + when(rsMockgetRelatedUris(Types.GENERIC_VNF)).thenReturn(arus) when(client.get(GenericVnf.class, genericVNFUri)).thenReturn(genericVnfOpt) spy.getConstituteVNFFromNetworkServiceInst(mockExecution) @@ -239,7 +241,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { currentNSSI.put("nssi", nssi) - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class) @@ -293,7 +295,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { sliceProfile.setSNssai(theSNSSAI) sliceProfile.setProfileId("prof-id") - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) currentNSSI.put("sliceProfileS-NSSAI", sliceProfile) @@ -344,9 +346,9 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { nssi.setServiceInstanceId("5G-999") nssi.setOrchestrationStatus("orchestration-status") - AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "networkServiceInstance.getServiceInstanceId()") + AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstance.getServiceInstanceId())) - AAIResourceUri cloudRegionAAIUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, "cloud-owner", "cloud-region-id") + AAIResourceUri cloudRegionAAIUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("cloud-owner", "cloud-region-id")) currentNSSI.put("networkServiceInstanceUri", networkServiceInstanceUri) @@ -402,7 +404,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { currentNSSI.put("constituteVnf", genericVnf) - AAIResourceUri constituteVNFURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId()) + AAIResourceUri constituteVNFURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnf.getVnfId())) currentNSSI.put("constituteVnfUri", constituteVNFURI) @@ -444,7 +446,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri) arus.add(aru) - when(rsMock.getRelatedAAIUris(AAIObjectType.PROJECT)).thenReturn(arus) + when(rsMockgetRelatedUris(Types.PROJECT)).thenReturn(arus) Optional<Project> projectOpt = Optional.of(project) @@ -470,7 +472,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { AAIResourceUri aru = new AAISimpleUri(networkServiceInstanceUri) arus.add(aru) - when(rsMock.getRelatedAAIUris(AAIObjectType.OWNING_ENTITY)).thenReturn(arus) + when(rsMockgetRelatedUris(Types.OWNING_ENTITY)).thenReturn(arus) Optional<OwningEntity> owningEntityOpt = Optional.of(owningEntity) @@ -492,7 +494,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri) arus.add(aru) - when(rsMock.getRelatedAAIUris(AAIObjectType.CLOUD_REGION)).thenReturn(arus) + when(rsMockgetRelatedUris(Types.CLOUD_REGION)).thenReturn(arus) CloudRegion cloudRegion = new CloudRegion() cloudRegion.setCloudRegionId("cloud-region-id") @@ -518,14 +520,14 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock) when(wrapperMock.getRelationships()).thenReturn(orsMock) - AAIResourceUri serviceSubscriptionUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, "global-customer-id", "service-type") + AAIResourceUri serviceSubscriptionUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-customer-id").serviceSubscription("service-type")) - AAIResourceUri customerUri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, "global-customer-id") + AAIResourceUri customerUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-customer-id")) List<AAIResourceUri> arus = new ArrayList<>() arus.add(serviceSubscriptionUri) - when(rsMock.getRelatedAAIUris(AAIObjectType.SERVICE_SUBSCRIPTION)).thenReturn(arus) + when(rsMockgetRelatedUris(Types.SERVICE_SUBSCRIPTION)).thenReturn(arus) ServiceSubscription serviceSubscription = new ServiceSubscription() serviceSubscription.setServiceType("service-type") @@ -535,7 +537,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock) - when(rsMock.getRelatedAAIUris(AAIObjectType.CUSTOMER)).thenReturn(arus) + when(rsMockgetRelatedUris(Types.CUSTOMER)).thenReturn(arus) Customer customer = new Customer() customer.setSubscriberName("subscriber-name") @@ -553,7 +555,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { Optional<ModelVer> modelVerOpt = Optional.of(modelVer) - AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, networkServiceInstance.getModelInvariantId(), networkServiceInstance.getModelVersionId()) + AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(networkServiceInstance.getModelInvariantId()).modelVer(networkServiceInstance.getModelVersionId())) when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt) } @@ -565,7 +567,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { Optional<ModelVer> modelVerOpt = Optional.of(modelVer) - AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, genericVnf.getModelInvariantId(), genericVnf.getModelVersionId()) + AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(genericVnf.getModelInvariantId()).modelVer(genericVnf.getModelVersionId())) when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt) } @@ -577,7 +579,7 @@ class DoCommonCoreNSSITest extends MsoGroovyTest { Optional<ModelVer> modelVerOpt = Optional.of(modelVer) - AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, vfModule.getModelInvariantId(), vfModule.getModelVersionId()) + AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(vfModule.getModelInvariantId()).modelVer(vfModule.getModelVersionId())) when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy index 32ebf09531..0de2c8c575 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy @@ -35,6 +35,8 @@ import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.aaiclient.client.aai.AAIObjectType 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 javax.ws.rs.NotFoundException import static org.junit.Assert.assertEquals import static org.mockito.ArgumentMatchers.isA @@ -65,8 +67,8 @@ class DoCreateVFCNetworkServiceInstanceTest extends MsoGroovyTest { when(mockExecution.getVariable("serviceId")).thenReturn("SER12345") doNothing().when(client).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class)) doCreateVFCNetworkServiceInstance.addNSRelationship(mockExecution); - AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,"MSO_dev","MSO-dev-service-type","NS12345") - AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,"MSO_dev","MSO-dev-service-type","SER12345") + AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("MSO_dev").serviceSubscription("MSO-dev-service-type").serviceInstance("NS12345")) + AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("MSO_dev").serviceSubscription("MSO-dev-service-type").serviceInstance("SER12345")) Mockito.verify(client).connect(nsUri,relatedServiceUri) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy index b2573f1b51..1a15f0eb14 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy @@ -43,11 +43,12 @@ import org.onap.so.bpmn.common.scripts.utils.XmlComparator import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.mock.FileUtil -import org.onap.aaiclient.client.aai.AAIObjectPlurals import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException import javax.ws.rs.NotFoundException @@ -169,7 +170,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ fqdnList.add("test") when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", "test") NetworkPolicies networkPolicies = new NetworkPolicies(); NetworkPolicy networkPolicy = new NetworkPolicy(); @@ -177,7 +178,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ networkPolicies.getNetworkPolicy().add(networkPolicy) when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies)) - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId()) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicy.getNetworkPolicyId())) doNothing().when(client).delete(delUri) doCreateVfModuleRollback.deleteNetworkPoliciesFromAAI(mockExecution) @@ -199,7 +200,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ fqdnList.add("test") when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", "test") NetworkPolicies networkPolicies = new NetworkPolicies(); NetworkPolicy networkPolicy = new NetworkPolicy(); @@ -207,7 +208,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ networkPolicies.getNetworkPolicy().add(networkPolicy) when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies)) - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId()) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicy.getNetworkPolicyId())) doThrow(new NotFoundException("Not Found!")).when(client).delete(delUri) doCreateVfModuleRollback.deleteNetworkPoliciesFromAAI(mockExecution) @@ -229,7 +230,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ fqdnList.add("test") when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", "test") NetworkPolicies networkPolicies = new NetworkPolicies(); NetworkPolicy networkPolicy = new NetworkPolicy(); @@ -237,7 +238,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{ networkPolicies.getNetworkPolicy().add(networkPolicy) when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies)) - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId()) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicy.getNetworkPolicyId())) doThrow(new GraphInventoryUriComputationException("Error!")).when(client).delete(delUri) try { doCreateVfModuleRollback.deleteNetworkPoliciesFromAAI(mockExecution) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy index cc522544de..1bc6fc5f66 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy @@ -20,21 +20,19 @@ package org.onap.so.bpmn.infrastructure.scripts; +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.when; import org.junit.Before; import org.junit.Test -import org.onap.aai.domain.yang.VfModule import org.onap.aai.domain.yang.VolumeGroup import org.onap.aai.domain.yang.VolumeGroups; -import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.aaiclient.client.aai.AAIObjectPlurals 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.constants.Defaults -import static org.mockito.Mockito.spy -import static org.mockito.Mockito.when; - public class DoCreateVfModuleVolumeRollbackTest extends MsoGroovyTest { private DoCreateVfModuleVolumeRollback doCreateVfModuleVolumeRollback; @@ -51,7 +49,7 @@ public class DoCreateVfModuleVolumeRollbackTest extends MsoGroovyTest { String cloudRegionId = "cloudRegionId" when(mockExecution.getVariable("DCVFMODVOLRBK_volumeGroupName")).thenReturn(volumeGroupName) when(mockExecution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId")).thenReturn(cloudRegionId) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegionId).queryParam("volume-group-name", volumeGroupName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), cloudRegionId).volumeGroups()).queryParam("volume-group-name", volumeGroupName) VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("volumeGroupId") VolumeGroups groups = new VolumeGroups(); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy index 7aa162cae7..d417abc671 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy @@ -20,39 +20,34 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.anyObject +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before -import org.junit.Rule import org.junit.Test -import org.junit.rules.ExpectedException -import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mockito import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner import org.onap.aai.domain.yang.GenericVnf -import org.onap.aai.domain.yang.Volume import org.onap.aai.domain.yang.VolumeGroup import org.onap.aai.domain.yang.VolumeGroups -import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.so.bpmn.core.RollbackData -import org.onap.aaiclient.client.aai.AAIObjectPlurals import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.RollbackData import org.onap.so.constants.Defaults -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertNotNull -import static org.mockito.ArgumentMatchers.anyObject -import static org.mockito.Mockito.spy -import static org.mockito.Mockito.times -import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when - class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { @@ -161,7 +156,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { String lcpCloudRegionId = "lcpCloudRegionId" when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName) when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).volumeGroups()).queryParam("volume-group-name", volumeGroupName) VolumeGroups volumeGroups = new VolumeGroups(); VolumeGroup volumeGroup = new VolumeGroup() volumeGroup.setVolumeGroupId("volumeGroupId") @@ -177,7 +172,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { String lcpCloudRegionId = "lcpCloudRegionId" when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName) when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).volumeGroups()).queryParam("volume-group-name", volumeGroupName) when(client.get(VolumeGroup.class,uri)).thenReturn(Optional.empty()) thrown.expect(BpmnError.class) doCreateVfModuleVolumeV2.callRESTQueryAAIVolGrpName(mockExecution,null) @@ -215,7 +210,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { void testcallRESTQueryAAIGenericVnf(){ String vnfId = "vnfId" when(mockExecution.getVariable(vnfId)).thenReturn(vnfId) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) GenericVnf genericVnf = new GenericVnf() genericVnf.setVnfId(vnfId) when(client.get(GenericVnf.class,uri)).thenReturn(Optional.of(genericVnf)) @@ -227,7 +222,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { void testcallRESTQueryAAIGenericVnf_NotFound(){ String vnfId = "vnfId" when(mockExecution.getVariable(vnfId)).thenReturn(vnfId) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) when(client.get(GenericVnf.class,uri)).thenReturn(Optional.empty()) thrown.expect(BpmnError.class) doCreateVfModuleVolumeV2.callRESTQueryAAIGenericVnf(mockExecution,null) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy index a3b2a1c8b9..2cb351c2b9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy @@ -20,19 +20,20 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when +import javax.ws.rs.core.UriBuilder import org.junit.Before import org.junit.Test import org.mockito.Mockito import org.mockito.Spy import org.onap.aai.domain.yang.AllottedResource -import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.so.bpmn.mock.FileUtil -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import javax.ws.rs.core.UriBuilder -import static org.mockito.Mockito.times -import static org.mockito.Mockito.when +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.mock.FileUtil class DoCustomDeleteE2EServiceInstanceV2Test extends MsoGroovyTest { @@ -49,7 +50,7 @@ class DoCustomDeleteE2EServiceInstanceV2Test extends MsoGroovyTest { void testPrepareServiceDeleteResource(){ when(mockExecution.getVariable("serviceInstance")).thenReturn(FileUtil.readResourceFile("__files/AAI/ServiceInstanceWithAR.json")) def relink = "/aai/v11/business/customers/customer/testCustIdInfra/service-subscriptions/service-subscription/HNPORTAL/service-instances/service-instance/testServiceInstanceIdPortalPri/allotted-resources/allotted-resource/testAllottedResourceIdPortalPri" - AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(relink).build()) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(Types.ALLOTTED_RESOURCE, UriBuilder.fromPath(relink).build()) AllottedResource ar = new AllottedResource(); ar.setId("ar1") ar.setType("ar") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy index 4a23e80feb..eae788666d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy @@ -29,6 +29,8 @@ import org.onap.aai.domain.yang.SliceProfiles import org.onap.aaiclient.client.aai.AAIObjectType 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.common.scripts.MsoGroovyTest import static org.junit.Assert.assertNotNull @@ -229,8 +231,8 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { currentNSSI.put("nssiId", nssiId) currentNSSI.put("nsiId", nsiId) - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) - AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nsiId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId)) doNothing().when(client).disconnect(nssiUri, nsiUri) @@ -249,7 +251,7 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest { currentNSSI.put("nssiId", nssiId) - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) DoDeallocateCoreNSSI spy = spy(DoDeallocateCoreNSSI.class) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy index 88140d83ce..852f053f11 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy @@ -38,6 +38,8 @@ import org.onap.so.client.HttpClientFactory import org.onap.aaiclient.client.aai.AAIObjectType 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 javax.ws.rs.core.Response @@ -137,7 +139,7 @@ class DoDeallocateNSSITest extends MsoGroovyTest { currentNSSI.put("serviceType","5G") when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) - AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, "5GCustomer", "5G", "5G-999", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5G-999").sliceProfile("ddf57704-fe8d-417b-882d-2f2a12ddb225")) DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) when(obj.getAAIClient()).thenReturn(client) when(client.exists(profileUri)).thenReturn(true) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy index eac79a9473..31bd3b56f5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateTnNssiTest.groovy @@ -29,12 +29,15 @@ import org.mockito.Mockito import org.onap.aaiclient.client.aai.AAIObjectType 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.common.scripts.MsoGroovyTest import static org.junit.Assert.assertNotNull import static org.mockito.ArgumentMatchers.eq import static org.mockito.Mockito.* + class DoDeallocateTnNssiTest extends MsoGroovyTest { @Before void init() throws IOException { @@ -124,7 +127,7 @@ class DoDeallocateTnNssiTest extends MsoGroovyTest { when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G") - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be")) DoDeallocateTnNssi obj = spy(DoDeallocateTnNssi.class) when(obj.getAAIClient()).thenReturn(client) doNothing().when(client).delete(serviceInstanceUri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy index 3b172f3015..85106111d0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy @@ -45,6 +45,8 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults @@ -1609,7 +1611,7 @@ String sdncAdapterWorkflowFormattedResponse_404 = Relationship relationship = new Relationship(); relationship.setRelatedTo("vf-module") l3Network.getRelationshipList().getRelationship().add(relationship) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)).depth(Depth.ALL) when(client.get(L3Network.class,uri)).thenReturn(Optional.of(l3Network)) doDeleteNetworkInstance.callRESTQueryAAI(mockExecution) @@ -1643,7 +1645,7 @@ String sdncAdapterWorkflowFormattedResponse_404 = DoDeleteNetworkInstance doDeleteNetworkInstance = spy(DoDeleteNetworkInstance.class) when(doDeleteNetworkInstance.getAAIClient()).thenReturn(client) L3Network l3Network = getL3Network() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)).depth(Depth.ALL) when(client.get(L3Network.class,uri)).thenReturn(Optional.of(l3Network)) doDeleteNetworkInstance.callRESTQueryAAI(mockExecution) @@ -1681,7 +1683,7 @@ String sdncAdapterWorkflowFormattedResponse_404 = relationship.setRelatedLink("http://localhost:18080/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER.toString() + "/lcpCloudRegion/") relationshipList.getRelationship().add(relationship) l3Network.setRelationshipList(relationshipList) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)).depth(Depth.ALL) when(client.get(L3Network.class,uri)).thenReturn(Optional.of(l3Network)) doDeleteNetworkInstance.callRESTQueryAAI(mockExecution) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy index 9dbb6a5a56..7b65d169a2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy @@ -19,6 +19,14 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before import org.junit.Test @@ -26,23 +34,13 @@ import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mockito import org.onap.aai.domain.yang.ServiceInstance -import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.aaiclient.client.aai.AAIObjectType 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 javax.ws.rs.NotFoundException - -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertNotNull -import static org.junit.Assert.assertTrue -import static org.mockito.ArgumentMatchers.eq -import static org.mockito.Mockito.doNothing -import static org.mockito.Mockito.spy -import static org.mockito.Mockito.times -import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types +import org.onap.so.bpmn.common.scripts.MsoGroovyTest class DoDeleteSliceServiceTest extends MsoGroovyTest { @Before @@ -73,7 +71,7 @@ class DoDeleteSliceServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") when(mockExecution.getVariable("serviceType")).thenReturn("5G") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be")) DoDeleteSliceService obj = spy(DoDeleteSliceService.class) AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceReturn()) @@ -92,8 +90,9 @@ class DoDeleteSliceServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") when(mockExecution.getVariable("serviceType")).thenReturn("5G") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") - DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be").allottedResources()) + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryAllottedResource()) when(obj.getAAIClient()).thenReturn(client) @@ -111,7 +110,7 @@ class DoDeleteSliceServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") when(mockExecution.getVariable("serviceType")).thenReturn("5G") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-888") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5G-888")) DoDeleteSliceService obj = spy(DoDeleteSliceService.class) AAIResultWrapper wrapper = new AAIResultWrapper(mockNSIReturn()) @@ -133,7 +132,7 @@ class DoDeleteSliceServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") when(mockExecution.getVariable("serviceType")).thenReturn("5G") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-999") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5G-999")) DoDeleteSliceService obj = spy(DoDeleteSliceService.class) AAIResultWrapper wrapper = new AAIResultWrapper(mockNSSIReturn()) @@ -181,7 +180,8 @@ class DoDeleteSliceServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("serviceType")).thenReturn("5G") AAIResultWrapper wrapper = new AAIResultWrapper(mockSliceProfile()) - AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE_ALL, "5GCustomer", "5G", "5G-999") + AAIPluralResourceUri profileUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5G-999").sliceProfiles()) DoDeleteSliceService obj = spy(DoDeleteSliceService.class) when(obj.getAAIClient()).thenReturn(client) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy index 0251eab668..3780d42efb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy @@ -20,24 +20,17 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.mockito.ArgumentMatchers.isA +import static org.mockito.Mockito.doThrow +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.when import org.camunda.bpm.engine.delegate.BpmnError import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.rules.ExpectedException -import org.onap.aai.domain.yang.VolumeGroup -import org.onap.aai.domain.yang.VolumeGroups -import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.aaiclient.client.aai.AAIObjectPlurals -import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory -import org.onap.so.constants.Defaults - -import static org.mockito.ArgumentMatchers.isA -import static org.mockito.Mockito.doThrow -import static org.mockito.Mockito.spy -import static org.mockito.Mockito.when +import org.onap.so.bpmn.common.scripts.MsoGroovyTest public class DoDeleteVFCNetworkServiceInstanceTest extends MsoGroovyTest { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy index daf005eabf..da68a213b0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy @@ -42,11 +42,12 @@ import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.core.WorkflowException -import org.onap.aaiclient.client.aai.AAIObjectPlurals import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import static com.github.tomakehurst.wiremock.client.WireMock.* @@ -106,7 +107,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest { List fqdnList = new ArrayList() fqdnList.add("test") when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", "test") NetworkPolicies networkPolicies = new NetworkPolicies(); NetworkPolicy networkPolicy = new NetworkPolicy(); @@ -114,7 +115,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest { networkPolicies.getNetworkPolicy().add(networkPolicy) when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies)) - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId()) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicy.getNetworkPolicyId())) doNothing().when(client).delete(delUri) deleteVfModuleFromVnf.deleteNetworkPoliciesFromAAI(mockExecution) @@ -128,7 +129,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest { List fqdnList = new ArrayList() fqdnList.add("test") when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", "test") when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.empty()) deleteVfModuleFromVnf.deleteNetworkPoliciesFromAAI(mockExecution) @@ -142,7 +143,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest { void testQueryAAIForVfModule() { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("vnfId")).thenReturn("12345") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "12345").depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("12345")).depth(Depth.ONE) GenericVnf genericVnf = new GenericVnf() genericVnf.setVnfId("test1") when(client.get(GenericVnf.class, uri)).thenReturn(Optional.of(genericVnf)) @@ -156,7 +157,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest { void testQueryAAIForVfModuleNotFound() { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("vnfId")).thenReturn("12345") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "12345").depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("12345")).depth(Depth.ONE) when(client.get(GenericVnf.class, uri)).thenReturn(Optional.empty()) deleteVfModuleFromVnf.queryAAIForVfModule(mockExecution) Mockito.verify(mockExecution, atLeastOnce()).setVariable("DDVMFV_getVnfResponseCode", 404) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy index 0e47958249..5882f73ce9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy @@ -20,15 +20,14 @@ package org.onap.so.bpmn.infrastructure.scripts -import com.github.tomakehurst.wiremock.junit.WireMockRule +import static com.github.tomakehurst.wiremock.client.WireMock.* +import static org.mockito.Mockito.* +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.ProcessEngineServices import org.camunda.bpm.engine.RepositoryService import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.camunda.bpm.engine.repository.ProcessDefinition -import org.junit.Assert import org.junit.Before -import org.junit.Ignore -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor @@ -40,21 +39,13 @@ import org.mockito.runners.MockitoJUnitRunner import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy import org.onap.aai.domain.yang.VfModule -import org.onap.aai.domain.yang.VfModules -import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.so.bpmn.common.scripts.utils.XmlComparator -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil -import org.onap.aaiclient.client.aai.AAIObjectPlurals -import org.onap.aaiclient.client.aai.AAIObjectType 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 javax.ws.rs.NotFoundException - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.common.scripts.utils.XmlComparator +import org.onap.so.bpmn.mock.FileUtil @RunWith(MockitoJUnitRunner.class) class DoDeleteVfModuleTest extends MsoGroovyTest{ @@ -105,7 +96,7 @@ class DoDeleteVfModuleTest extends MsoGroovyTest{ NetworkPolicy networkPolicy = new NetworkPolicy() networkPolicy.setNetworkPolicyId("NP1") networkPolicies.getNetworkPolicy().add(networkPolicy) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", "test") when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies)) doDeleteVfModule.deleteNetworkPoliciesFromAAI(mockExecution) @@ -121,10 +112,10 @@ class DoDeleteVfModuleTest extends MsoGroovyTest{ NetworkPolicy networkPolicy = new NetworkPolicy() networkPolicy.setNetworkPolicyId("NP1") networkPolicies.getNetworkPolicy().add(networkPolicy) - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()) uri.queryParam("network-policy-fqdn", "test") when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies)) - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "NP1") + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy("NP1")) doThrow(new NotFoundException(("Not Found !"))).when(client).delete(delUri) doDeleteVfModule.deleteNetworkPoliciesFromAAI(mockExecution) Mockito.verify(client).delete(delUri) @@ -135,7 +126,7 @@ class DoDeleteVfModuleTest extends MsoGroovyTest{ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("vnfId")).thenReturn("12345") when(mockExecution.getVariable("vfModuleId")).thenReturn("module-0") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE,"12345","module-0") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("12345").vfModule("module-0")) VfModule vfModule = new VfModule() vfModule.setOrchestrationStatus("Created") when(client.get(VfModule.class, uri)).thenReturn(Optional.of(vfModule)) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy index dd8601fb43..84d88ffaf9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy @@ -53,6 +53,8 @@ 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.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException import org.springframework.core.env.Environment import org.springframework.mock.env.MockEnvironment @@ -182,7 +184,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant123") when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123") when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "Region1").volumeGroup("VolumeGroup123")) Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/AAI/VolumeGroupWithTenant.json"); when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup) when(client.get(resourceUri)).thenReturn( @@ -197,7 +199,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant123") when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123") when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "Region1").volumeGroup("VolumeGroup123")) Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroup.json"); when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup) try { @@ -212,7 +214,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant12345") when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123") when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "Region1").volumeGroup("VolumeGroup123")) Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/AAI/VolumeGroupWithTenant.json"); when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup) try { @@ -227,7 +229,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant123") when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123") when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "Region1").volumeGroup("VolumeGroup123")) when(client.get(VolumeGroup.class,resourceUri)).thenReturn(Optional.empty()) try { deleteVfModuleVolumeV2.callRESTQueryAAIForVolumeGroup(mockExecution, "true") @@ -241,7 +243,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant123") when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123") when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "Region1").volumeGroup("VolumeGroup123")) Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroupWithVfModule.json"); when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup) try { @@ -256,7 +258,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroup.json"); when(mockExecution.getVariable("DDVMV_queryAAIVolGrpResponse")).thenReturn(volumeGroup.get()) when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "Region1").volumeGroup("VolumeGroup123")) doNothing().when(client).delete(resourceUri) deleteVfModuleVolumeV2.callRESTDeleteAAIVolumeGroup(mockExecution,"true") } @@ -266,7 +268,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroupWithVfModule.json"); when(mockExecution.getVariable("DDVMV_queryAAIVolGrpResponse")).thenReturn(volumeGroup.get()) when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1",volumeGroup.get().getVolumeGroupId()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "Region1").volumeGroup(volumeGroup.get()).getVolumeGroupId()) doThrow(new GraphInventoryUriComputationException("Error")).when(client).delete(resourceUri) try { deleteVfModuleVolumeV2.callRESTDeleteAAIVolumeGroup(mockExecution, "true") @@ -280,7 +282,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroup.json"); when(mockExecution.getVariable("DDVMV_queryAAIVolGrpResponse")).thenReturn(volumeGroup.get()) when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") - AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(CLOUD_OWNER, "Region1").volumeGroup("VolumeGroup123")) doThrow(new NotFoundException("VolumeGroup Not found")).when(client).delete(resourceUri) try { deleteVfModuleVolumeV2.callRESTDeleteAAIVolumeGroup(mockExecution, "true") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy index 2da6eca84e..e85b81327f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy @@ -42,6 +42,8 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException import static com.github.tomakehurst.wiremock.client.WireMock.* @@ -99,7 +101,7 @@ public class DoDeleteVnfAndModulesTest extends MsoGroovyTest{ @Test public void testQueryAAIVfModuleNullEndPoint() { when(mockExecution.getVariable("vnfId")).thenReturn("12345") - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "12345").depth(Depth.ONE) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("12345")).depth(Depth.ONE) doThrow(new GraphInventoryUriComputationException("Error in AAI")).when(client).get(GenericVnf.class,uri) try { doDeleteVnfAndModules.queryAAIVfModule(mockExecution) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy index a3c2b46fe6..bbc237f1f9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy @@ -30,6 +30,8 @@ import org.onap.aaiclient.client.aai.AAIObjectType 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types import org.onap.so.bpmn.common.scripts.MsoGroovyTest import static org.junit.Assert.assertNotNull @@ -180,7 +182,7 @@ class DoModifyCoreNSSITest extends MsoGroovyTest { currentNSSI.put("nssiId", nssiId) currentNSSI.put("sliceProfileId", sliceProfileId) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiId, sliceProfileId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileId)) SliceProfile sliceProfile = new SliceProfile() sliceProfile.setProfileId(sliceProfileId) @@ -213,8 +215,8 @@ class DoModifyCoreNSSITest extends MsoGroovyTest { String globalSubscriberId = "globalSubscriberId" String serviceType = "serviceType" - AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) - AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiId, sliceProfileId) + AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId)) + AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(nssiId).sliceProfile(sliceProfileId)) currentNSSI.put("globalSubscriberId", globalSubscriberId) currentNSSI.put("serviceType", serviceType) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssiTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssiTest.groovy index bbbec3bb46..ef106f8064 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssiTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyTnNssiTest.groovy @@ -29,12 +29,15 @@ import org.mockito.Mockito import org.onap.aaiclient.client.aai.AAIObjectType 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.common.scripts.MsoGroovyTest import static org.junit.Assert.assertNotNull import static org.mockito.ArgumentMatchers.eq import static org.mockito.Mockito.* + class DoModifyTnNssiTest extends MsoGroovyTest { @Before void init() throws IOException { @@ -80,7 +83,7 @@ class DoModifyTnNssiTest extends MsoGroovyTest { when(mockExecution.getVariable("modelUuid")).thenReturn("36a3a8ea-49a6-4ac8-b06c-89a54544b9b6") when(mockExecution.getVariable("sliceProfile")).thenReturn(mockSliceProfile()) - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("5GCustomer").serviceSubscription("5G").serviceInstance("5ad89cf9-0569-4a93-9306-d8324321e2be")) DoModifyTnNssi obj = spy(DoModifyTnNssi.class) when(obj.getAAIClient()).thenReturn(client) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy index bf877bd725..e2010ce047 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy @@ -23,6 +23,8 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.mockito.Mockito.* +import javax.ws.rs.core.UriBuilder import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Assert @@ -38,18 +40,16 @@ import org.mockito.junit.MockitoJUnitRunner import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.VfModule import org.onap.aai.domain.yang.VolumeGroup -import org.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.so.bpmn.mock.FileUtil 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.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.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.mock.FileUtil import org.onap.so.constants.Defaults -import javax.ws.rs.core.UriBuilder - -import static org.mockito.Mockito.* - @RunWith(MockitoJUnitRunner.Silent.class) class UpdateVfModuleVolumeInfraV1Test extends MsoGroovyTest{ @@ -79,7 +79,7 @@ class UpdateVfModuleVolumeInfraV1Test extends MsoGroovyTest{ UpdateVfModuleVolumeInfraV1 obj = spy(UpdateVfModuleVolumeInfraV1.class) when(obj.getAAIClient()).thenReturn(client) - AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VF_MODULE, UriBuilder.fromPath("/aai/v8/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module/12345").build()) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(Types.VF_MODULE, UriBuilder.fromPath("/aai/v8/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module/12345").build()) VfModule vfModule = new VfModule(); vfModule.setVfModuleId("12345") vfModule.setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff") @@ -98,7 +98,7 @@ class UpdateVfModuleVolumeInfraV1Test extends MsoGroovyTest{ UpdateVfModuleVolumeInfraV1 obj = spy(UpdateVfModuleVolumeInfraV1.class) when(obj.getAAIClient()).thenReturn(client) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId)) VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId(volumeGroupId) @@ -116,7 +116,7 @@ class UpdateVfModuleVolumeInfraV1Test extends MsoGroovyTest{ UpdateVfModuleVolumeInfraV1 obj = spy(UpdateVfModuleVolumeInfraV1.class) when(obj.getAAIClient()).thenReturn(client) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) GenericVnf genericVnf = new GenericVnf() genericVnf.setVnfId(vnfId) genericVnf.setVnfName("testvnfName") @@ -133,7 +133,7 @@ class UpdateVfModuleVolumeInfraV1Test extends MsoGroovyTest{ UpdateVfModuleVolumeInfraV1 obj = spy(UpdateVfModuleVolumeInfraV1.class) when(obj.getAAIClient()).thenReturn(client) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) when(client.get(GenericVnf.class,uri)).thenReturn(Optional.empty()) thrown.expect(BpmnError.class) obj.queryAAIForGenericVnf(mockExecution, "true") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy index 6a8465e2b6..a505a7c8b8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy @@ -42,6 +42,8 @@ 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.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.constants.Defaults import javax.ws.rs.core.UriBuilder @@ -75,7 +77,7 @@ class UpdateVfModuleVolumeTest extends MsoGroovyTest{ UpdateVfModuleVolume obj = spy(UpdateVfModuleVolume.class) when(obj.getAAIClient()).thenReturn(client) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId)) VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId(volumeGroupId) @@ -94,7 +96,7 @@ class UpdateVfModuleVolumeTest extends MsoGroovyTest{ UpdateVfModuleVolume obj = spy(UpdateVfModuleVolume.class) when(obj.getAAIClient()).thenReturn(client) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(Defaults.CLOUD_OWNER.toString(), aicCloudRegion).volumeGroup(volumeGroupId)) VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId(volumeGroupId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy index d7f7547459..a3851435c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy @@ -22,27 +22,26 @@ package org.onap.so.bpmn.vcpe.scripts -import com.github.tomakehurst.wiremock.junit.WireMockRule +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.put +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.* +import static org.mockito.Mockito.* +import static org.onap.so.bpmn.mock.StubResponseAAI.* +import javax.ws.rs.core.UriBuilder import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.* import org.mockito.MockitoAnnotations +import org.onap.aaiclient.client.aai.AAIResourcesClient +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.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.mock.FileUtil -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory - -import javax.ws.rs.core.UriBuilder - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.* -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.* +import com.github.tomakehurst.wiremock.junit.WireMockRule class DoCreateAllottedResourceBRGTest extends GroovyTestBase { @@ -157,7 +156,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase { public void createAaiAR() { ExecutionEntity mockExecution = setupMock() AAIResourcesClient client = mock(AAIResourcesClient.class) - when(mockExecution.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build())) + when(mockExecution.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build())) when(mockExecution.getVariable("CSI_resourceLink")).thenReturn("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST) when(mockExecution.getVariable("allottedResourceModelInfo")).thenReturn("{\n" + " \"modelInvariantUuid\":\"modelInvariantUuid\",\n" + @@ -843,7 +842,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase { when(mex.getVariable("allottedResourceId")).thenReturn(ARID) when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) - when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build())) + when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build())) when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/mycsi") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy index 2a6894785e..0e2c01a200 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy @@ -22,28 +22,25 @@ package org.onap.so.bpmn.vcpe.scripts -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.* -import org.mockito.MockitoAnnotations -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil -import org.onap.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory - -import javax.ws.rs.core.UriBuilder - import static org.junit.Assert.* import static org.mockito.Mockito.* import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500 - +import javax.ws.rs.core.UriBuilder +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.* +import org.mockito.MockitoAnnotations +import org.onap.aaiclient.client.aai.AAIResourcesClient +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.core.RollbackData - +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.mock.FileUtil import com.github.tomakehurst.wiremock.junit.WireMockRule class DoCreateAllottedResourceTXCTest extends GroovyTestBase { @@ -157,7 +154,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase { public void createAaiAR() { ExecutionEntity mex = setupMock() initCreateAaiAr(mex) - when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build())) + when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build())) when(mex.getVariable("CSI_resourceLink")).thenReturn("/aai/v9/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST) when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{\n" + " \"modelInvariantUuid\":\"modelInvariantUuid\",\n" + @@ -788,7 +785,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase { when(mex.getVariable("allottedResourceId")).thenReturn(ARID) when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) - when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build())) + when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(Types.SERVICE_INSTANCE, UriBuilder.fromPath("/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST).build())) when(mex.getVariable("allottedResourceType")).thenReturn("TXCt") when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr") when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/mycsi") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java index 978814be7f..ddc30f8262 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java @@ -35,12 +35,12 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; 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.servicedecomposition.bbobjects.GenericVnf; @RunWith(MockitoJUnitRunner.class) public class AAICreateResourcesTest { @@ -87,7 +87,8 @@ public class AAICreateResourcesTest { aaiCreateResources.createAAIProject(projectName, serviceInstanceId); - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); + AAIResourceUri projectURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().project(projectName)); verify(aaiResourcesClient, times(1)).createIfNotExists(projectURI, Optional.empty()); verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); @@ -103,7 +104,8 @@ public class AAICreateResourcesTest { HashMap<String, String> owningEntityMap = new HashMap<>(); owningEntityMap.put("owning-entity-name", owningEntityName); - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri owningEntityURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntityId)); verify(aaiResourcesClient, times(1)).createIfNotExists(owningEntityURI, Optional.of(owningEntityMap)); verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); @@ -115,7 +117,8 @@ public class AAICreateResourcesTest { boolean expectedBoolean = aaiCreateResources.existsOwningEntity(owningEntityId); - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + AAIResourceUri owningEntityURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntityId)); verify(aaiResourcesClient, times(1)).exists(owningEntityURI); assertTrue(expectedBoolean); @@ -138,7 +141,8 @@ public class AAICreateResourcesTest { aaiCreateResources.createAAIPlatform(platformName, vnfId); - AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); + AAIResourceUri platformURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().platform(platformName)); verify(aaiResourcesClient, times(1)).createIfNotExists(platformURI, Optional.empty()); verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); @@ -153,7 +157,7 @@ public class AAICreateResourcesTest { aaiCreateResources.createAAILineOfBusiness(lineOfBusiness, vnfId); AAIResourceUri lineOfBusinessURI = - AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().lineOfBusiness(lineOfBusiness)); verify(aaiResourcesClient, times(1)).createIfNotExists(lineOfBusinessURI, Optional.empty()); verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); @@ -166,8 +170,8 @@ public class AAICreateResourcesTest { aaiCreateResources.createAAIServiceInstance(globalCustomerId, serviceType, serviceInstanceId); - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalCustomerId, serviceType, serviceInstanceId); + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalCustomerId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); verify(aaiResourcesClient, times(1)).createIfNotExists(serviceInstanceURI, Optional.empty()); } @@ -180,7 +184,7 @@ public class AAICreateResourcesTest { Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId); - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); verify(aaiResourcesClient, times(1)).get(vnfURI); assertEquals(actualVnf, aaiResultWrapper.asBean(GenericVnf.class)); @@ -192,7 +196,7 @@ public class AAICreateResourcesTest { Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId); - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); verify(aaiResourcesClient, times(1)).get(vnfURI); assertEquals(actualVnf, Optional.empty()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index 55edf0bb6c..b55499473c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -32,6 +32,10 @@ import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; import org.camunda.bpm.engine.delegate.BpmnError; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; @@ -52,9 +56,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; @@ -66,7 +67,6 @@ import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; import org.onap.so.client.orchestration.AAIVpnBindingResources; -import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; @@ -691,7 +691,8 @@ public class AAICreateTasks { if (fqdnCount > 0) { for (int i = 0; i < fqdnCount; i++) { String fqdn = fqdnList[i]; - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()); uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn); Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java index 42fb719f89..d62fc6f50f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java @@ -27,6 +27,9 @@ import java.util.List; import java.util.Optional; import org.onap.aai.domain.yang.NetworkPolicies; import org.onap.aai.domain.yang.NetworkPolicy; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -38,9 +41,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAIInstanceGroupResources; @@ -279,7 +279,8 @@ public class AAIDeleteTasks { if (fqdnCount > 0) { for (int i = 0; i < fqdnCount; i++) { String fqdn = fqdnList[i]; - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies()); uri.queryParam(networkPolicyFqdnParam, fqdn); Optional<NetworkPolicies> oNetPolicies = aaiNetworkResources.getNetworkPolicies(uri); if (oNetPolicies.isPresent()) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java index 0912cba94a..9df9dd330c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java @@ -32,15 +32,15 @@ import org.onap.aai.domain.yang.RouteTableReference; import org.onap.aai.domain.yang.RouteTargets; import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.VpnBinding; +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.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -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.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAINetworkResources; import org.slf4j.Logger; @@ -76,8 +76,7 @@ public class AAIQueryTasks { if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); } - List<AAIResourceUri> netBindingsUriList = - networkRelationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING); + List<AAIResourceUri> netBindingsUriList = networkRelationships.get().getRelatedUris(Types.VPN_BINDING); List<org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding> mappedVpnBindings = new ArrayList<>(); if (netBindingsUriList != null && !netBindingsUriList.isEmpty()) { @@ -115,8 +114,7 @@ public class AAIQueryTasks { if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); } - List<AAIResourceUri> netBindingsUriList = - networkRelationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING); + List<AAIResourceUri> netBindingsUriList = networkRelationships.get().getRelatedUris(Types.VPN_BINDING); List<org.onap.so.openstack.beans.RouteTarget> routeTargets = new ArrayList<>(); for (AAIResourceUri netBindingUri : netBindingsUriList) { logger.info("Get Route Targests"); @@ -168,8 +166,7 @@ public class AAIQueryTasks { if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); } - List<AAIResourceUri> netPoliciesUriList = - networkRelationships.get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY); + List<AAIResourceUri> netPoliciesUriList = networkRelationships.get().getRelatedUris(Types.NETWORK_POLICY); if (!netPoliciesUriList.isEmpty()) { for (AAIResourceUri netPolicyUri : netPoliciesUriList) { @@ -201,7 +198,7 @@ public class AAIQueryTasks { throw (new Exception(ERROR_MSG)); } List<AAIResourceUri> routeTableUriList = - networkRelationships.get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE); + networkRelationships.get().getRelatedUris(Types.ROUTE_TABLE_REFERENCE); if (!routeTableUriList.isEmpty()) { for (AAIResourceUri routeTableUri : routeTableUriList) { @@ -241,7 +238,7 @@ public class AAIQueryTasks { if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); } - List<AAIResourceUri> subnetsUriList = networkRelationships.get().getRelatedAAIUris(AAIObjectType.SUBNET); + List<AAIResourceUri> subnetsUriList = networkRelationships.get().getRelatedUris(Types.SUBNET); if (!subnetsUriList.isEmpty()) { for (AAIResourceUri subnetUri : subnetsUriList) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java index 1f05522011..2644ae1b58 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -6,11 +6,11 @@ import java.util.List; import java.util.Map; import java.util.Optional; import org.onap.aai.domain.yang.Vserver; -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.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.appc.client.lcm.model.Action; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm; @@ -186,7 +186,7 @@ public class AppcOrchestratorPreProcessor { if (aaiRW != null && aaiRW.getRelationships().isPresent()) { Relationships relationships = aaiRW.getRelationships().get(); if (relationships != null) { - List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER); + List<AAIResourceUri> vserverUris = relationships.getRelatedUris(Types.VSERVER); ArrayList<String> vserverIds = new ArrayList<String>(); ArrayList<String> vserverSelfLinks = new ArrayList<String>(); for (AAIResourceUri j : vserverUris) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 70edc375c4..de2976fb80 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -30,11 +30,11 @@ import java.util.Map; import java.util.Optional; import org.json.JSONArray; import org.json.JSONObject; -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.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.appc.client.lcm.model.Action; import org.onap.logging.filter.base.ErrorCode; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -251,7 +251,7 @@ public class AppcRunTasks { return; } Relationships relationships = aaiRW.getRelationships().get(); - List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER); + List<AAIResourceUri> vserverUris = relationships.getRelatedUris(Types.VSERVER); JSONArray vserverIds = new JSONArray(); JSONArray vserverSelfLinks = new JSONArray(); if (vserverUris != null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java index 751e91d009..f7c42b97e9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java @@ -1,6 +1,14 @@ package org.onap.so.bpmn.infrastructure.vfmodule; import java.util.Optional; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -8,14 +16,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; -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.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.exception.ExceptionBuilder; import org.onap.so.cloud.resource.beans.CloudInformation; import org.onap.so.cloud.resource.beans.NodeType; @@ -60,15 +60,15 @@ public class CreateVFModule { } protected NodeType getNodeType(CloudRegion cloudRegion) { - AAIResourceUri cloudRegionUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, - cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()); + AAIResourceUri cloudRegionUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())); AAIResourcesClient client = getAAIClient(); Optional<Relationships> relationships = client.get(cloudRegionUri).getRelationships(); if (relationships.isPresent()) { AAIPluralResourceUri networkTechsGreenfieldUri = AAIUriFactory - .createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId()) - .relatedTo(AAIObjectPlurals.NETWORK_TECHNOLOGY) + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())) + .relatedTo(Types.NETWORK_TECHNOLOGIES.getFragment()) .queryParam("network-technology-name", NodeType.GREENFIELD.getNetworkTechnologyName()); AAIResultWrapper networkTechsGreenfield = client.get(networkTechsGreenfieldUri); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java index 905862880f..304cb9f4b4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java @@ -23,10 +23,10 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import java.util.List; import java.util.Optional; import org.onap.aai.domain.yang.L3Network; -import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; -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.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -143,7 +143,7 @@ public class VrfValidation { AAIResultWrapper networkWrapper = new AAIResultWrapper(aaiLocalNetwork); if (networkWrapper.getRelationships().isPresent()) { List<AAIResourceUri> vpnBindingUris = - networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING); + networkWrapper.getRelationships().get().getRelatedUris(Types.VPN_BINDING); if (!vpnBindingUris.isEmpty()) { Optional<org.onap.aai.domain.yang.VpnBinding> vpnBindingOp = bbInputSetupUtils.getAAIResourceDepthOne(vpnBindingUris.get(0)) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 9b9433afdb..0f955e2851 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -50,12 +50,13 @@ import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VpnBinding; import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIObjectName; 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.common.BBConstants; import org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; @@ -485,16 +486,17 @@ public class WorkflowAction { } protected <T> List<T> getRelatedResourcesInVfModule(String vnfId, String vfModuleId, Class<T> resultClass, - AAIObjectType type) { + AAIObjectName name) { List<T> vnfcs = new ArrayList<>(); - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)); AAIResultWrapper vfModuleResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri); Optional<Relationships> relationshipsOp = vfModuleResultsWrapper.getRelationships(); if (!relationshipsOp.isPresent()) { logger.debug("No relationships were found for vfModule in AAI"); } else { Relationships relationships = relationshipsOp.get(); - List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(type); + List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(name); for (AAIResultWrapper vnfcResultWrapper : vnfcResultWrappers) { Optional<T> vnfcOp = vnfcResultWrapper.asBean(resultClass); vnfcOp.ifPresent(vnfcs::add); @@ -503,9 +505,9 @@ public class WorkflowAction { return vnfcs; } - protected <T> T getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) throws Exception { + protected <T> T getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectName name) throws Exception { T configuration = null; - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfc.getVnfcName())); AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri); Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships(); if (!relationshipsOp.isPresent()) { @@ -513,7 +515,7 @@ public class WorkflowAction { } else { Relationships relationships = relationshipsOp.get(); List<AAIResultWrapper> configurationResultWrappers = - this.getResultWrappersFromRelationships(relationships, type); + this.getResultWrappersFromRelationships(relationships, name); if (configurationResultWrappers.size() > 1) { String multipleRelationshipsError = "Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations"; @@ -530,8 +532,8 @@ public class WorkflowAction { } protected List<AAIResultWrapper> getResultWrappersFromRelationships(Relationships relationships, - AAIObjectType type) { - return relationships.getByType(type); + AAIObjectName name) { + return relationships.getByType(name); } protected boolean isConfiguration(List<OrchestrationFlow> orchFlows) { @@ -565,12 +567,12 @@ public class WorkflowAction { vfModuleCustomizationUUID = aaiVfModule.getModelCustomizationId(); } - List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, - org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC); + List<org.onap.aai.domain.yang.Vnfc> vnfcs = + getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, Types.VNFC); for (org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) { WorkflowResourceIds workflowIdsCopy = SerializationUtils.clone(dataObj.getWorkflowResourceIds()); - org.onap.aai.domain.yang.Configuration configuration = getRelatedResourcesInVnfc(vnfc, - org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION); + org.onap.aai.domain.yang.Configuration configuration = + getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, Types.CONFIGURATION); if (configuration == null) { logger.warn(String.format("No configuration found for VNFC %s in AAI", vnfc.getVnfcName())); continue; @@ -813,7 +815,7 @@ public class WorkflowAction { new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiLocalNetwork)).getRelationships(); if (relationshipsOp.isPresent()) { List<AAIResultWrapper> configurationsRelatedToLocalNetwork = - relationshipsOp.get().getByType(AAIObjectType.CONFIGURATION); + relationshipsOp.get().getByType(Types.CONFIGURATION); if (configurationsRelatedToLocalNetwork.size() > 1) { throw new VrfBondingServiceException( "Network: " + aaiLocalNetwork.getNetworkId() + " has more than 1 configuration related to it"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 7420df144a..5425b2a725 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -20,12 +20,23 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; +import javax.persistence.EntityNotFoundException; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.aai.domain.yang.*; -import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.InstanceGroup; +import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.VfModule; +import org.onap.aai.domain.yang.Vnfc; +import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aaiclient.client.aai.entities.Configuration; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; @@ -48,13 +59,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import javax.persistence.EntityNotFoundException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Collectors; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; @Component public class WorkflowActionBBTasks { @@ -421,8 +427,7 @@ public class WorkflowActionBBTasks { String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(); String vfModuleCustomizationUUID = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId(); - List<Vnfc> vnfcs = - workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, AAIObjectType.VNFC); + List<Vnfc> vnfcs = workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, Types.VNFC); logger.debug("Vnfc Size: {}", vnfcs.size()); for (Vnfc vnfc : vnfcs) { String modelCustomizationId = vnfc.getModelCustomizationId(); @@ -461,7 +466,7 @@ public class WorkflowActionBBTasks { protected String getConfigurationId(Vnfc vnfc) throws Exception { Configuration configuration = - workflowAction.getRelatedResourcesInVnfc(vnfc, Configuration.class, AAIObjectType.CONFIGURATION); + workflowAction.getRelatedResourcesInVnfc(vnfc, Configuration.class, Types.CONFIGURATION); if (configuration != null) { return configuration.getConfigurationId(); } else { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java index de674daca3..4140692b44 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java @@ -23,12 +23,12 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import java.util.List; import java.util.Optional; import org.onap.aai.domain.yang.VpnBinding; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; -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.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -42,7 +42,7 @@ public class WorkflowActionExtractResourcesAAI { protected BBInputSetupUtils bbInputSetupUtils; public Optional<Configuration> extractRelationshipsConfiguration(Relationships relationships) { - List<AAIResultWrapper> configurations = relationships.getByType(AAIObjectType.CONFIGURATION); + List<AAIResultWrapper> configurations = relationships.getByType(Types.CONFIGURATION); for (AAIResultWrapper configWrapper : configurations) { Optional<Configuration> config = configWrapper.asBean(Configuration.class); if (config.isPresent()) { @@ -53,7 +53,7 @@ public class WorkflowActionExtractResourcesAAI { } public Optional<VpnBinding> extractRelationshipsVpnBinding(Relationships relationships) { - List<AAIResourceUri> configurations = relationships.getRelatedUris(AAIObjectType.VPN_BINDING); + List<AAIResourceUri> configurations = relationships.getRelatedUris(Types.VPN_BINDING); for (AAIResourceUri vpnBindingUri : configurations) { AAIResultWrapper vpnBindingWrapper = bbInputSetupUtils.getAAIResourceDepthOne(vpnBindingUri); Optional<VpnBinding> vpnBinding = vpnBindingWrapper.asBean(VpnBinding.class); @@ -65,7 +65,7 @@ public class WorkflowActionExtractResourcesAAI { } public Optional<Relationships> extractRelationshipsVnfc(Relationships relationships) { - List<AAIResultWrapper> vnfcs = relationships.getByType(AAIObjectType.VNFC); + List<AAIResultWrapper> vnfcs = relationships.getByType(Types.VNFC); for (AAIResultWrapper vnfcWrapper : vnfcs) { if (vnfcWrapper.getRelationships().isPresent()) { return vnfcWrapper.getRelationships(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java index 7386740c25..78c8cfb145 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAICollectionResources.java @@ -20,11 +20,11 @@ package org.onap.so.client.orchestration; -import org.onap.so.bpmn.common.InjectionHelper; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; -import org.onap.aaiclient.client.aai.AAIObjectType; 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.servicedecomposition.bbobjects.Collection; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +40,7 @@ public class AAICollectionResources { public void createCollection(Collection collection) { AAIResourceUri networkCollectionURI = - AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(collection.getId())); collection.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(collection); injectionHelper.getAaiClient().create(networkCollectionURI, aaiCollection); @@ -48,13 +48,14 @@ public class AAICollectionResources { public void updateCollection(Collection collection) { AAIResourceUri networkCollectionURI = - AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(collection.getId())); org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(collection); injectionHelper.getAaiClient().update(networkCollectionURI, aaiCollection); } public void deleteCollection(Collection collection) { - AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId()); + AAIResourceUri instanceGroupUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(collection.getId())); injectionHelper.getAaiClient().delete(instanceGroupUri); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java index a832930723..1373c2ca97 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java @@ -22,12 +22,13 @@ package org.onap.so.client.orchestration; import java.util.Optional; import javax.ws.rs.core.UriBuilder; -import org.onap.so.bpmn.common.InjectionHelper; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.aaiclient.client.aai.AAIObjectType; 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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.springframework.beans.factory.annotation.Autowired; @@ -47,8 +48,8 @@ public class AAIConfigurationResources { * @param configuration */ public void createConfiguration(Configuration configuration) { - AAIResourceUri configurationURI = - AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId()); + AAIResourceUri configurationURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().configuration(configuration.getConfigurationId())); configuration.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration); injectionHelper.getAaiClient().createIfNotExists(configurationURI, Optional.of(aaiConfiguration)); @@ -61,7 +62,8 @@ public class AAIConfigurationResources { * @return */ public Optional<org.onap.aai.domain.yang.Configuration> getConfiguration(String configurationId) { - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Configuration.class, aaiResourceUri); } @@ -71,8 +73,8 @@ public class AAIConfigurationResources { * @param configuration */ public void updateConfiguration(Configuration configuration) { - AAIResourceUri configurationURI = - AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId()); + AAIResourceUri configurationURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().configuration(configuration.getConfigurationId())); org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration); injectionHelper.getAaiClient().update(configurationURI, aaiConfiguration); } @@ -85,9 +87,10 @@ public class AAIConfigurationResources { */ public void disconnectConfigurationToServiceInstance(String configurationId, String serviceInstanceId) { - AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri configurationURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); injectionHelper.getAaiClient().disconnect(configurationURI, serviceInstanceURI); } @@ -99,9 +102,9 @@ public class AAIConfigurationResources { */ public void connectVrfConfigurationToVnrConfiguration(String vrfConfigurationId, String vnrConfigurationId) { AAIResourceUri vnrConfigurationUri = - AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, vnrConfigurationId); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(vnrConfigurationId)); AAIResourceUri vrfConfigurationUri = - AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, vrfConfigurationId); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(vrfConfigurationId)); injectionHelper.getAaiClient().connect(vrfConfigurationUri, vnrConfigurationUri); } @@ -112,8 +115,9 @@ public class AAIConfigurationResources { * @param configurationId */ public void connectConfigurationToPnfObject(String pnfId, String configurationId) { - AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId); - AAIResourceUri configurationUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnfId)); + AAIResourceUri configurationUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); injectionHelper.getAaiClient().connect(configurationUri, pnfUri); } @@ -124,9 +128,10 @@ public class AAIConfigurationResources { * @param serviceInstanceId */ public void connectConfigurationToServiceInstance(String configurationId, String serviceInstanceId) { - AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri configurationURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); injectionHelper.getAaiClient().connect(configurationURI, serviceInstanceURI); } @@ -139,9 +144,10 @@ public class AAIConfigurationResources { */ public void connectConfigurationToServiceInstance(String configurationId, String serviceInstanceId, AAIEdgeLabel aaiLabel) { - AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri configurationURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); injectionHelper.getAaiClient().connect(configurationURI, serviceInstanceURI, aaiLabel); } @@ -152,8 +158,10 @@ public class AAIConfigurationResources { * @param genericVnfId */ public void connectConfigurationToGenericVnf(String configurationId, String genericVnfId) { - AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); - AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnfId); + AAIResourceUri configurationURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); + AAIResourceUri genericVnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId)); injectionHelper.getAaiClient().connect(configurationURI, genericVnfURI); } @@ -165,26 +173,33 @@ public class AAIConfigurationResources { * */ public void connectConfigurationToVpnBinding(String configurationId, String vpnId) { - AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); - AAIResourceUri vpnBindingURI = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnId); + AAIResourceUri configurationURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); + AAIResourceUri vpnBindingURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vpnBinding(vpnId)); injectionHelper.getAaiClient().connect(configurationURI, vpnBindingURI); } public void connectConfigurationToVfModule(String configurationId, String vnfId, String vfModuleId) { - AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); - AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); + AAIResourceUri configurationURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); + AAIResourceUri vfModuleURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)); injectionHelper.getAaiClient().connect(configurationURI, vfModuleURI); } public void connectConfigurationToVnfc(String configurationId, String vnfcName) { - AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); - AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfcName); + AAIResourceUri configurationURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); + AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName)); injectionHelper.getAaiClient().connect(configurationURI, vnfcURI); } public void connectConfigurationToL3Network(String configurationId, String networkId) { - AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId); + AAIResourceUri configurationURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)); injectionHelper.getAaiClient().connect(configurationURI, networkURI); } @@ -194,7 +209,8 @@ public class AAIConfigurationResources { * @param configurationId */ public void deleteConfiguration(String configurationId) { - AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(configurationId)); injectionHelper.getAaiClient().delete(aaiResourceUri); } @@ -204,8 +220,8 @@ public class AAIConfigurationResources { * @param configuration */ public void deleteConfiguration(Configuration configuration) { - AAIResourceUri aaiResourceUri = - AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId()); + AAIResourceUri aaiResourceUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().configuration(configuration.getConfigurationId())); injectionHelper.getAaiClient().delete(aaiResourceUri); } @@ -217,13 +233,13 @@ public class AAIConfigurationResources { */ public Optional<org.onap.aai.domain.yang.Configuration> getConfigurationFromRelatedLink(String relatedLink) { return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Configuration.class, AAIUriFactory - .createResourceFromExistingURI(AAIObjectType.CONFIGURATION, UriBuilder.fromPath(relatedLink).build())); + .createResourceFromExistingURI(Types.CONFIGURATION, UriBuilder.fromPath(relatedLink).build())); } public void updateOrchestrationStatusConfiguration(Configuration configuration, OrchestrationStatus orchestrationStatus) { - AAIResourceUri aaiResourceUri = - AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId()); + AAIResourceUri aaiResourceUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().configuration(configuration.getConfigurationId())); configuration.setOrchestrationStatus(orchestrationStatus); org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration); injectionHelper.getAaiClient().update(aaiResourceUri, aaiConfiguration); @@ -231,8 +247,8 @@ public class AAIConfigurationResources { public void updateConfigurationOrchestrationStatus(Configuration configuration, OrchestrationStatus orchestrationStatus) { - AAIResourceUri aaiResourceUri = - AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId()); + AAIResourceUri aaiResourceUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().configuration(configuration.getConfigurationId())); org.onap.aai.domain.yang.Configuration aaiConfiguration = new org.onap.aai.domain.yang.Configuration(); aaiConfiguration.setOrchestrationStatus(orchestrationStatus.name()); injectionHelper.getAaiClient().update(aaiResourceUri, aaiConfiguration); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java index 05c8f7dd8f..27fa4304c4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java @@ -21,16 +21,16 @@ package org.onap.so.client.orchestration; import java.util.Optional; -import org.onap.so.bpmn.common.InjectionHelper; -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.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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.so.bpmn.common.InjectionHelper; +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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -45,50 +45,52 @@ public class AAIInstanceGroupResources { public void createInstanceGroup(InstanceGroup instanceGroup) { AAIResourceUri instanceGroupUri = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup); injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup)); } public void deleteInstanceGroup(InstanceGroup instanceGroup) { AAIResourceUri instanceGroupUri = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); injectionHelper.getAaiClient().delete(instanceGroupUri); } public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf) { AAIResourceUri instanceGroupUri = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI); } public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf, AAIEdgeLabel aaiLabel) { AAIResourceUri instanceGroupUri = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI, aaiLabel); } public boolean exists(InstanceGroup instanceGroup) { AAIResourceUri instanceGroupUri = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); return injectionHelper.getAaiClient().exists(instanceGroupUri); } public void createInstanceGroupandConnectServiceInstance(InstanceGroup instanceGroup, ServiceInstance serviceInstance) { AAIResourceUri instanceGroupUri = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup); - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup)) .connect(instanceGroupUri, serviceInstanceURI); } public boolean checkInstanceGroupNameInUse(String instanceGroupName) { - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP) + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroups()) .queryParam("instance-group-name", instanceGroupName); return injectionHelper.getAaiClient().exists(uri); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index 611d715331..2e8e50aebf 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -25,6 +25,15 @@ import org.onap.aai.domain.yang.NetworkPolicies; import org.onap.aai.domain.yang.NetworkPolicy; import org.onap.aai.domain.yang.RouteTableReference; import org.onap.aai.domain.yang.VpnBinding; +import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.uri.AAIBaseResourceUri; +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; @@ -34,16 +43,7 @@ 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.bpmn.servicedecomposition.bbobjects.Subnet; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.uri.AAIBaseResourceUri; -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.graphinventory.entities.uri.Depth; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -58,46 +58,51 @@ public class AAINetworkResources { private AAIObjectMapper aaiObjectMapper; public void updateNetwork(L3Network network) { - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId())); org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(network); injectionHelper.getAaiClient().update(networkURI, aaiL3Network); } public void updateSubnet(L3Network network, Subnet subnet) { - AAIResourceUri subnetURI = - AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, network.getNetworkId(), subnet.getSubnetId()); + AAIResourceUri subnetURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().l3Network(network.getNetworkId()).subnet(subnet.getSubnetId())); org.onap.aai.domain.yang.Subnet aaiSubnet = aaiObjectMapper.mapSubnet(subnet); injectionHelper.getAaiClient().update(subnetURI, aaiSubnet); } public void createNetworkConnectToServiceInstance(L3Network network, ServiceInstance serviceInstance) { - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId())); network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); org.onap.aai.domain.yang.L3Network aaiL3Network = aaiObjectMapper.mapNetwork(network); injectionHelper.getAaiClient().createIfNotExists(networkURI, Optional.of(aaiL3Network)).connect(networkURI, serviceInstanceURI); } public void createLineOfBusinessAndConnectNetwork(LineOfBusiness lineOfBusiness, L3Network network) { - AAIResourceUri lineOfBusinessURI = - AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness.getLineOfBusinessName()); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + AAIResourceUri lineOfBusinessURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().lineOfBusiness(lineOfBusiness.getLineOfBusinessName())); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId())); injectionHelper.getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.of(lineOfBusiness)) .connect(networkURI, lineOfBusinessURI); } public void createPlatformAndConnectNetwork(Platform platform, L3Network network) { AAIResourceUri platformURI = - AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platform.getPlatformName()); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().platform(platform.getPlatformName())); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId())); injectionHelper.getAaiClient().createIfNotExists(platformURI, Optional.of(platform)).connect(networkURI, platformURI); } public void deleteNetwork(L3Network network) { - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(network.getNetworkId())); injectionHelper.getAaiClient().delete(networkURI); } @@ -122,115 +127,122 @@ public class AAINetworkResources { } public Optional<org.onap.aai.domain.yang.L3Network> queryNetworkById(L3Network l3network) { - AAIResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId()).depth(Depth.ALL); + AAIResourceUri uri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3network.getNetworkId())).depth(Depth.ALL); AAIResultWrapper aaiWrapper = injectionHelper.getAaiClient().get(uri); return aaiWrapper.asBean(org.onap.aai.domain.yang.L3Network.class); } public AAIResultWrapper queryNetworkWrapperById(L3Network l3network) { - AAIResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId()).depth(Depth.ALL); + AAIResourceUri uri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3network.getNetworkId())).depth(Depth.ALL); return injectionHelper.getAaiClient().get(uri); } public void createNetworkInstanceGroup(InstanceGroup instanceGroup) { AAIResourceUri instanceGroupURI = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = aaiObjectMapper.mapInstanceGroup(instanceGroup); injectionHelper.getAaiClient().create(instanceGroupURI, aaiInstanceGroup); } public void createNetworkCollection(Collection networkCollection) { AAIResourceUri networkCollectionURI = - AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(networkCollection.getId())); networkCollection.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); org.onap.aai.domain.yang.Collection aaiCollection = aaiObjectMapper.mapCollection(networkCollection); injectionHelper.getAaiClient().create(networkCollectionURI, aaiCollection); } public void connectNetworkToTenant(L3Network l3network, CloudRegion cloudRegion) { - AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId()); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId()); + AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .tenant(cloudRegion.getTenantId())); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3network.getNetworkId())); injectionHelper.getAaiClient().connect(tenantURI, networkURI); } public void connectNetworkToCloudRegion(L3Network l3network, CloudRegion cloudRegion) { - AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, - cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId()); + AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3network.getNetworkId())); injectionHelper.getAaiClient().connect(networkURI, cloudRegionURI); } public void connectNetworkToNetworkCollectionInstanceGroup(L3Network l3network, InstanceGroup instanceGroup) { AAIResourceUri netwrokCollectionInstanceGroupURI = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3network.getNetworkId())); injectionHelper.getAaiClient().connect(netwrokCollectionInstanceGroupURI, networkURI); } public void connectNetworkToNetworkCollectionServiceInstance(L3Network l3network, ServiceInstance networkCollectionServiceInstance) { AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri( - AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId()); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3network.getNetworkId()); + Types.SERVICE_INSTANCE.getFragment(networkCollectionServiceInstance.getServiceInstanceId())); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3network.getNetworkId())); injectionHelper.getAaiClient().connect(networkCollectionServiceInstanceUri, networkURI); } public void connectNetworkCollectionInstanceGroupToNetworkCollection(InstanceGroup instanceGroup, Collection networkCollection) { AAIResourceUri networkCollectionUri = - AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(networkCollection.getId())); AAIResourceUri netwrokCollectionInstanceGroupURI = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); injectionHelper.getAaiClient().connect(networkCollectionUri, netwrokCollectionInstanceGroupURI); } public void connectInstanceGroupToCloudRegion(InstanceGroup instanceGroup, CloudRegion cloudRegion) { - AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, - cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()); + AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())); AAIResourceUri instanceGroupURI = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); injectionHelper.getAaiClient().connect(instanceGroupURI, cloudRegionURI, AAIEdgeLabel.USES); } public void connectNetworkCollectionToServiceInstance(Collection networkCollection, ServiceInstance networkCollectionServiceInstance) { AAIResourceUri networkCollectionUri = - AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(networkCollection.getId())); AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri( - AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId()); + Types.SERVICE_INSTANCE.getFragment(networkCollectionServiceInstance.getServiceInstanceId())); injectionHelper.getAaiClient().connect(networkCollectionUri, networkCollectionServiceInstanceUri); } public void deleteCollection(Collection collection) { - AAIResourceUri collectionURI = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, collection.getId()); + AAIResourceUri collectionURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().collection(collection.getId())); injectionHelper.getAaiClient().delete(collectionURI); } public void deleteNetworkInstanceGroup(InstanceGroup instanceGroup) { AAIResourceUri instanceGroupURI = - AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().instanceGroup(instanceGroup.getId())); injectionHelper.getAaiClient().delete(instanceGroupURI); } public void createNetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy networkPolicy) { NetworkPolicy aaiNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy); String networkPolicyId = networkPolicy.getNetworkPolicyId(); - AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId); + AAIResourceUri netUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)); injectionHelper.getAaiClient().create(netUri, aaiNetworkPolicy); } public void deleteNetworkPolicy(String networkPolicyId) { AAIResourceUri networkPolicyURI = - AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId)); injectionHelper.getAaiClient().delete(networkPolicyURI); } public boolean checkNetworkNameInUse(String networkName) { - AAIPluralResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Networks()) + .queryParam("network-name", networkName); return injectionHelper.getAaiClient().exists(uri); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java index 3da17194ff..a426c39646 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java @@ -20,24 +20,25 @@ package org.onap.so.client.orchestration; -import com.google.common.base.Strings; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.onap.aai.domain.yang.RelatedToProperty; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipData; +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.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.aaiclient.client.aai.AAIObjectType; -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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Strings; @Component public class AAIPnfResources { @@ -51,16 +52,16 @@ public class AAIPnfResources { private AAIObjectMapper aaiObjectMapper; public void createPnfAndConnectServiceInstance(Pnf pnf, ServiceInstance serviceInstance) { - AAIResourceUri pnfURI = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName()); + AAIResourceUri pnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnf.getPnfName())); pnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); injectionHelper.getAaiClient().createIfNotExists(pnfURI, Optional.of(aaiObjectMapper.mapPnf(pnf))) .connect(pnfURI, serviceInstanceURI); } public void updateOrchestrationStatusPnf(Pnf pnf, OrchestrationStatus orchestrationStatus) { - AAIResourceUri pnfURI = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName()); + AAIResourceUri pnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnf.getPnfName())); Pnf pnfCopy = pnf.shallowCopyId(); @@ -72,7 +73,7 @@ public class AAIPnfResources { public void checkIfPnfExistsInAaiAndCanBeUsed(Pnf pnf) throws Exception { Optional<org.onap.aai.domain.yang.Pnf> pnfFromAai = injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName())); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnf.getPnfName()))); if (pnfFromAai.isPresent()) { checkIfPnfCanBeUsed(pnfFromAai.get()); updatePnfInAAI(pnf, pnfFromAai.get()); @@ -81,8 +82,8 @@ public class AAIPnfResources { private void updatePnfInAAI(Pnf pnf, org.onap.aai.domain.yang.Pnf pnfFromAai) { updatePnfFields(pnf, pnfFromAai); - injectionHelper.getAaiClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName()), - pnfFromAai); + injectionHelper.getAaiClient().update( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnf.getPnfName())), pnfFromAai); logger.debug("updatePnfInAAI: {}", pnfFromAai); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java index 424b3ecefa..cc99f178bd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java @@ -27,17 +27,17 @@ package org.onap.so.client.orchestration; import java.util.List; import java.util.Optional; import org.onap.aai.domain.yang.OwningEntities; +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; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; 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.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.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; import org.springframework.beans.factory.annotation.Autowired; @@ -53,15 +53,16 @@ public class AAIServiceInstanceResources { private AAIObjectMapper aaiObjectMapper; public boolean existsServiceInstance(ServiceInstance serviceInstance) { - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); return injectionHelper.getAaiClient().exists(serviceInstanceURI); } public void createServiceInstance(ServiceInstance serviceInstance, Customer customer) { AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, customer.getGlobalCustomerId(), - customer.getServiceSubscription().getServiceType(), serviceInstance.getServiceInstanceId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription(customer.getServiceSubscription().getServiceType()) + .serviceInstance(serviceInstance.getServiceInstanceId())); serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance); @@ -74,58 +75,63 @@ public class AAIServiceInstanceResources { * @param customer */ public void createServiceSubscription(Customer customer) { - AAIResourceUri serviceSubscriptionURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, - customer.getGlobalCustomerId(), customer.getServiceSubscription().getServiceType()); + AAIResourceUri serviceSubscriptionURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId()) + .serviceSubscription(customer.getServiceSubscription().getServiceType())); org.onap.aai.domain.yang.ServiceSubscription serviceSubscription = aaiObjectMapper.mapServiceSubscription(customer.getServiceSubscription()); injectionHelper.getAaiClient().createIfNotExists(serviceSubscriptionURI, Optional.of(serviceSubscription)); } public void deleteServiceInstance(ServiceInstance serviceInstance) { - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); injectionHelper.getAaiClient().delete(serviceInstanceURI); } public void createProject(Project project) { - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName()); + AAIResourceUri projectURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().project(project.getProjectName())); org.onap.aai.domain.yang.Project aaiProject = aaiObjectMapper.mapProject(project); injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(aaiProject)); } public void createProjectandConnectServiceInstance(Project project, ServiceInstance serviceInstance) { - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName()); - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri projectURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().project(project.getProjectName())); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); org.onap.aai.domain.yang.Project aaiProject = aaiObjectMapper.mapProject(project); injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(aaiProject)).connect(projectURI, serviceInstanceURI); } public void createOwningEntity(OwningEntity owningEntity) { - AAIResourceUri owningEntityURI = - AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId()); + AAIResourceUri owningEntityURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntity.getOwningEntityId())); org.onap.aai.domain.yang.OwningEntity aaiOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity); injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(aaiOwningEntity)); } public boolean existsOwningEntity(OwningEntity owningEntity) { - AAIResourceUri owningEntityUri = - AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId()); + AAIResourceUri owningEntityUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntity.getOwningEntityId())); return injectionHelper.getAaiClient().exists(owningEntityUri); } public boolean existsOwningEntityName(String owningEntityName) { - AAIPluralResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY) - .queryParam("owning-entity-name", owningEntityName); + AAIPluralResourceUri owningEntityUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntities()) + .queryParam("owning-entity-name", owningEntityName); AAIResourcesClient aaiRC = injectionHelper.getAaiClient(); return aaiRC.exists(owningEntityUri); } public org.onap.aai.domain.yang.OwningEntity getOwningEntityByName(String owningEntityName) throws AAIEntityNotFoundException { - AAIPluralResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY) - .queryParam("owning-entity-name", owningEntityName); + AAIPluralResourceUri owningEntityUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().owningEntities()) + .queryParam("owning-entity-name", owningEntityName); AAIResourcesClient aaiRC = injectionHelper.getAaiClient(); Optional<OwningEntities> owningEntities = aaiRC.get(OwningEntities.class, owningEntityUri); if (owningEntities.isPresent()) { @@ -142,19 +148,19 @@ public class AAIServiceInstanceResources { } public void connectOwningEntityandServiceInstance(OwningEntity owningEntity, ServiceInstance serviceInstance) { - AAIResourceUri owningEntityURI = - AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId()); - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri owningEntityURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntity.getOwningEntityId())); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); injectionHelper.getAaiClient().connect(owningEntityURI, serviceInstanceURI); } public void createOwningEntityandConnectServiceInstance(OwningEntity owningEntity, ServiceInstance serviceInstance) { - AAIResourceUri owningEntityURI = - AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId()); - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri owningEntityURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().owningEntity(owningEntity.getOwningEntityId())); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); org.onap.aai.domain.yang.OwningEntity aaiOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity); injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(aaiOwningEntity)) .connect(owningEntityURI, serviceInstanceURI); @@ -171,15 +177,15 @@ public class AAIServiceInstanceResources { } public void updateServiceInstance(ServiceInstance serviceInstance) { - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance); injectionHelper.getAaiClient().update(serviceInstanceURI, aaiServiceInstance); } public boolean checkInstanceServiceNameInUse(ServiceInstance serviceInstance) { - AAIPluralResourceUri uriSI = AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE) + AAIPluralResourceUri uriSI = AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCES.getFragment()) .queryParam("service-instance-name", serviceInstance.getServiceInstanceName()); return injectionHelper.getAaiClient().exists(uriSI); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java index d5d0b0868a..72c9b7cc4f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java @@ -23,16 +23,16 @@ package org.onap.so.client.orchestration; import java.util.Optional; +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.common.InjectionHelper; 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.AAIObjectType; -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; import org.springframework.beans.factory.annotation.Autowired; @@ -48,23 +48,23 @@ public class AAIVfModuleResources { private AAIObjectMapper aaiObjectMapper; public void createVfModule(VfModule vfModule, GenericVnf vnf) { - AAIResourceUri vfModuleURI = - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId())); vfModule.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); injectionHelper.getAaiClient().createIfNotExists(vfModuleURI, Optional.of(aaiObjectMapper.mapVfModule(vfModule))); } public void deleteVfModule(VfModule vfModule, GenericVnf vnf) { - AAIResourceUri vfModuleURI = - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId())); injectionHelper.getAaiClient().delete(vfModuleURI); } public void updateOrchestrationStatusVfModule(VfModule vfModule, GenericVnf vnf, OrchestrationStatus orchestrationStatus) { - AAIResourceUri vfModuleURI = - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId())); VfModule copiedVfModule = vfModule.shallowCopyId(); vfModule.setOrchestrationStatus(orchestrationStatus); @@ -74,8 +74,8 @@ public class AAIVfModuleResources { } public void updateHeatStackIdVfModule(VfModule vfModule, GenericVnf vnf) { - AAIResourceUri vfModuleURI = - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId())); VfModule copiedVfModule = vfModule.shallowCopyId(); copiedVfModule.setHeatStackId(vfModule.getHeatStackId()); @@ -84,8 +84,8 @@ public class AAIVfModuleResources { } public void updateContrailServiceInstanceFqdnVfModule(VfModule vfModule, GenericVnf vnf) { - AAIResourceUri vfModuleURI = - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId())); VfModule copiedVfModule = vfModule.shallowCopyId(); copiedVfModule.setContrailServiceInstanceFqdn(vfModule.getContrailServiceInstanceFqdn()); @@ -94,24 +94,25 @@ public class AAIVfModuleResources { } public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) { - AAIResourceUri vfModuleURI = - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId())); org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(vfModule); injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule); } public void connectVfModuleToVolumeGroup(GenericVnf vnf, VfModule vfModule, VolumeGroup volumeGroup, CloudRegion cloudRegion) { - AAIResourceUri vfModuleURI = - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); - AAIResourceUri volumeGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, - cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId())); + AAIResourceUri volumeGroupURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .volumeGroup(volumeGroup.getVolumeGroupId())); injectionHelper.getAaiClient().connect(vfModuleURI, volumeGroupURI); } public boolean checkNameInUse(VfModule vfModule) { boolean nameInUse = false; - 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/main/java/org/onap/so/client/orchestration/AAIVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java index c2e84f668c..2f48b1f2f5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java @@ -25,22 +25,22 @@ package org.onap.so.client.orchestration; import java.io.IOException; import java.util.Optional; import org.onap.aai.domain.yang.Vserver; -import org.onap.so.bpmn.common.InjectionHelper; -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.AAIRestClientImpl; import org.onap.aaiclient.client.aai.AAIValidatorImpl; 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.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; +import org.onap.so.bpmn.common.InjectionHelper; +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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -57,37 +57,42 @@ public class AAIVnfResources { private AAIValidatorImpl aaiValidatorImpl = new AAIValidatorImpl(); public void createVnfandConnectServiceInstance(GenericVnf vnf, ServiceInstance serviceInstance) { - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); vnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); - AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); + AAIResourceUri serviceInstanceURI = AAIUriFactory + .createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId())); injectionHelper.getAaiClient().createIfNotExists(vnfURI, Optional.of(aaiObjectMapper.mapVnf(vnf))) .connect(vnfURI, serviceInstanceURI); } public void createPlatformandConnectVnf(Platform platform, GenericVnf vnf) { AAIResourceUri platformURI = - AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platform.getPlatformName()); - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().platform(platform.getPlatformName())); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); injectionHelper.getAaiClient().createIfNotExists(platformURI, Optional.of(platform)).connect(vnfURI, platformURI); } public void createLineOfBusinessandConnectVnf(LineOfBusiness lineOfBusiness, GenericVnf vnf) { - AAIResourceUri lineOfBusinessURI = - AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness.getLineOfBusinessName()); - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIResourceUri lineOfBusinessURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.business().lineOfBusiness(lineOfBusiness.getLineOfBusinessName())); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); injectionHelper.getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.of(lineOfBusiness)).connect(vnfURI, lineOfBusinessURI); } public void deleteVnf(GenericVnf vnf) { - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); injectionHelper.getAaiClient().delete(vnfURI); } public void updateOrchestrationStatusVnf(GenericVnf vnf, OrchestrationStatus orchestrationStatus) { - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); GenericVnf copiedVnf = vnf.shallowCopyId(); @@ -97,7 +102,8 @@ public class AAIVnfResources { } public void updateObjectVnf(GenericVnf vnf) { - AAIResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIResourceUri vnfUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); injectionHelper.getAaiClient().update(vnfUri, aaiObjectMapper.mapVnf(vnf)); } @@ -109,7 +115,7 @@ public class AAIVnfResources { */ public Optional<org.onap.aai.domain.yang.GenericVnf> getGenericVnf(String vnfId) { return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))); } /** @@ -121,29 +127,32 @@ public class AAIVnfResources { public boolean checkInMaintFlag(String vnfId) { org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient() .get(org.onap.aai.domain.yang.GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))) .orElse(new org.onap.aai.domain.yang.GenericVnf()); return vnf.isInMaint(); } public void connectVnfToCloudRegion(GenericVnf vnf, CloudRegion cloudRegion) { - AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, - cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()); - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); injectionHelper.getAaiClient().connect(vnfURI, cloudRegionURI); } public void connectVnfToTenant(GenericVnf vnf, CloudRegion cloudRegion) { - AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId()); - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .tenant(cloudRegion.getTenantId())); + AAIResourceUri vnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())); injectionHelper.getAaiClient().connect(tenantURI, vnfURI); } public boolean checkVnfClosedLoopDisabledFlag(String vnfId) { org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient() .get(org.onap.aai.domain.yang.GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))) .orElse(new org.onap.aai.domain.yang.GenericVnf()); return vnf.isIsClosedLoopDisabled(); } @@ -151,7 +160,7 @@ public class AAIVnfResources { public boolean checkVnfPserversLockedFlag(String vnfId) throws IOException { org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient() .get(org.onap.aai.domain.yang.GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))) .orElse(new org.onap.aai.domain.yang.GenericVnf()); AAIRestClientImpl client = new AAIRestClientImpl(); aaiValidatorImpl.setClient(client); @@ -160,14 +169,14 @@ public class AAIVnfResources { } public boolean checkNameInUse(String vnfName) { - AAIPluralResourceUri vnfUri = - AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName); + AAIPluralResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()) + .queryParam("vnf-name", vnfName); return injectionHelper.getAaiClient().exists(vnfUri); } public AAIResultWrapper queryVnfWrapperById(GenericVnf vnf) { - AAIResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()).depth(Depth.ALL); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId())) + .depth(Depth.ALL); return injectionHelper.getAaiClient().get(uri); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java index 886dafe626..1fbfe8cab0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java @@ -22,15 +22,15 @@ package org.onap.so.client.orchestration; +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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.bpmn.common.InjectionHelper; 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.AAIObjectType; -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; import org.springframework.beans.factory.annotation.Autowired; @@ -46,16 +46,18 @@ public class AAIVolumeGroupResources { private AAIObjectMapper aaiObjectMapper; public void createVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) { - AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, - cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .volumeGroup(volumeGroup.getVolumeGroupId())); volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); injectionHelper.getAaiClient().create(uriVolumeGroup, aaiObjectMapper.mapVolumeGroup(volumeGroup)); } public void updateOrchestrationStatusVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion, OrchestrationStatus orchestrationStatus) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .volumeGroup(volumeGroup.getVolumeGroupId())); VolumeGroup copiedVolumeGroup = volumeGroup.shallowCopyId(); volumeGroup.setOrchestrationStatus(orchestrationStatus); @@ -65,29 +67,34 @@ public class AAIVolumeGroupResources { public void connectVolumeGroupToVnf(GenericVnf genericVnf, VolumeGroup volumeGroup, CloudRegion cloudRegion) { AAIResourceUri uriGenericVnf = - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId()); - AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, - cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnf.getVnfId())); + AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .volumeGroup(volumeGroup.getVolumeGroupId())); injectionHelper.getAaiClient().connect(uriGenericVnf, uriVolumeGroup); } public void connectVolumeGroupToTenant(VolumeGroup volumeGroup, CloudRegion cloudRegion) { - AAIResourceUri uriTenant = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId()); - AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, - cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + AAIResourceUri uriTenant = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .tenant(cloudRegion.getTenantId())); + AAIResourceUri uriVolumeGroup = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .volumeGroup(volumeGroup.getVolumeGroupId())); injectionHelper.getAaiClient().connect(uriTenant, uriVolumeGroup); } public void deleteVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .volumeGroup(volumeGroup.getVolumeGroupId())); injectionHelper.getAaiClient().delete(uri); } public void updateHeatStackIdVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), - cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()) + .volumeGroup(volumeGroup.getVolumeGroupId())); VolumeGroup copiedVolumeGroup = volumeGroup.shallowCopyId(); copiedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId()); @@ -95,7 +102,7 @@ public class AAIVolumeGroupResources { } public boolean checkNameInUse(VolumeGroup volumeGroup) { - AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + AAIPluralResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(Types.VOLUME_GROUPS.getFragment()) .queryParam("volume-group-name", volumeGroup.getVolumeGroupName()); return injectionHelper.getAaiClient().exists(volumeGroupUri); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java index 5ce8268d55..5200be9d65 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java @@ -22,14 +22,13 @@ package org.onap.so.client.orchestration; import java.util.Optional; import org.onap.aai.domain.yang.VpnBindings; -import org.onap.so.bpmn.common.InjectionHelper; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIObjectType; 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.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -46,8 +45,8 @@ public class AAIVpnBindingResources { * @param customer */ public boolean existsCustomer(Customer customer) { - AAIResourceUri uriCustomer = - AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, customer.getGlobalCustomerId()); + AAIResourceUri uriCustomer = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())); return injectionHelper.getAaiClient().exists(uriCustomer); } @@ -56,8 +55,9 @@ public class AAIVpnBindingResources { * @return */ public Optional<VpnBindings> getVpnBindingByCustomerVpnId(String customerVpnId) { - AAIPluralResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VPN_BINDING) - .queryParam("customer-vpn-id", customerVpnId); + AAIPluralResourceUri aaiVpnBindingsResourceUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vpnBindings()) + .queryParam("customer-vpn-id", customerVpnId); return injectionHelper.getAaiClient().get(VpnBindings.class, aaiVpnBindingsResourceUri); } @@ -67,7 +67,7 @@ public class AAIVpnBindingResources { */ public void createVpnBinding(VpnBinding vpnBinding) { AAIResourceUri aaiVpnBindingResourceUri = - AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBinding.getVpnId()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vpnBinding(vpnBinding.getVpnId())); injectionHelper.getAaiClient().create(aaiVpnBindingResourceUri, aaiObjectMapper.mapVpnBinding(vpnBinding)); } @@ -75,8 +75,8 @@ public class AAIVpnBindingResources { * @param customer */ public void createCustomer(Customer customer) { - AAIResourceUri uriCustomer = - AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, customer.getGlobalCustomerId()); + AAIResourceUri uriCustomer = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())); injectionHelper.getAaiClient().create(uriCustomer, aaiObjectMapper.mapCustomer(customer)); } @@ -88,7 +88,7 @@ public class AAIVpnBindingResources { */ public Optional<org.onap.aai.domain.yang.VpnBinding> getVpnBinding(String vpnId) { return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.VpnBinding.class, - AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnId)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vpnBinding(vpnId))); } @@ -97,8 +97,10 @@ public class AAIVpnBindingResources { * @param vpnId */ public void connectCustomerToVpnBinding(String globalSubscriberId, String vpnId) { - AAIResourceUri customerURI = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId); - AAIResourceUri vpnBindingURI = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnId); + AAIResourceUri customerURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId)); + AAIResourceUri vpnBindingURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vpnBinding(vpnId)); injectionHelper.getAaiClient().connect(customerURI, vpnBindingURI); } } 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<AAIResourceUri> 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<ExecuteBuildingBlock> 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<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj); @@ -1763,13 +1762,13 @@ public class WorkflowActionTest extends BaseTaskTest { List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>(); 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<VpnBinding> 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<org.onap.aai.domain.yang.NetworkPolicy> 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<org.onap.aai.domain.yang.NetworkPolicies> 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<RouteTableReference> 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<org.onap.aai.domain.yang.Subnet> 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<org.onap.aai.domain.yang.Vserver> 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); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java index 998aea9065..ee06fa4be8 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java @@ -22,63 +22,12 @@ package org.onap.aaiclient.client.aai; import java.io.Serializable; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals; -import org.onap.so.constants.Defaults; import com.google.common.base.CaseFormat; public class AAIObjectPlurals implements AAIObjectBase, GraphInventoryObjectPlurals, Serializable { private static final long serialVersionUID = 5312713297525740746L; - public static final AAIObjectPlurals CUSTOMER = - new AAIObjectPlurals(AAIObjectType.CUSTOMER, AAINamespaceConstants.BUSINESS, "/customers"); - public static final AAIObjectPlurals GENERIC_VNF = - new AAIObjectPlurals(AAIObjectType.GENERIC_VNF, AAINamespaceConstants.NETWORK, "/generic-vnfs"); - public static final AAIObjectPlurals PORT_GROUP = - new AAIObjectPlurals(AAIObjectType.PORT_GROUP, AAIObjectType.VCE.uriTemplate(), "/port-groups"); - public static final AAIObjectPlurals PSERVER = - new AAIObjectPlurals(AAIObjectType.PSERVER, AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"); - public static final AAIObjectPlurals P_INTERFACE = - new AAIObjectPlurals(AAIObjectType.P_INTERFACE, AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"); - public static final AAIObjectPlurals L3_NETWORK = - new AAIObjectPlurals(AAIObjectType.L3_NETWORK, AAINamespaceConstants.NETWORK, "/l3-networks"); - public static final AAIObjectPlurals NETWORK_POLICY = - new AAIObjectPlurals(AAIObjectType.NETWORK_POLICY, AAINamespaceConstants.NETWORK, "/network-policies"); - public static final AAIObjectPlurals VPN_BINDING = - new AAIObjectPlurals(AAIObjectType.VPN_BINDING, AAINamespaceConstants.NETWORK, "/vpn-bindings"); - public static final AAIObjectPlurals SERVICE_SUBSCRIPTION = new AAIObjectPlurals(AAIObjectType.SERVICE_SUBSCRIPTION, - AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"); - public static final AAIObjectPlurals SERVICE_INSTANCE = new AAIObjectPlurals(AAIObjectType.SERVICE_INSTANCE, - AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"); - public static final AAIObjectPlurals OWNING_ENTITY = - new AAIObjectPlurals(AAIObjectType.OWNING_ENTITY, AAINamespaceConstants.BUSINESS, "/owning-entities"); - public static final AAIObjectPlurals VOLUME_GROUP = new AAIObjectPlurals(AAIObjectType.VOLUME_GROUP, - AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups"); - public static final AAIObjectPlurals AVAILIBILITY_ZONE = new AAIObjectPlurals(AAIObjectType.AVAILIBILITY_ZONE, - AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones"); - public static final AAIObjectPlurals VF_MODULE = - new AAIObjectPlurals(AAIObjectType.VF_MODULE, AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules"); - public static final AAIObjectPlurals CONFIGURATION = - new AAIObjectPlurals(AAIObjectType.CONFIGURATION, AAINamespaceConstants.NETWORK, "/configurations"); - public static final AAIObjectPlurals DEFAULT_TENANT = - new AAIObjectPlurals(AAIObjectType.DEFAULT_TENANT, AAINamespaceConstants.CLOUD_INFRASTRUCTURE - + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants"); - public static final AAIObjectPlurals NETWORK_TECHNOLOGY = new AAIObjectPlurals(AAIObjectType.NETWORK_TECHNOLOGY, - AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies"); - public static final AAIObjectPlurals LOGICAL_LINK = - new AAIObjectPlurals(AAIObjectType.LOGICAL_LINK, AAINamespaceConstants.NETWORK, "/logical-links"); - public static final AAIObjectPlurals L_INTERFACE = - new AAIObjectPlurals(AAIObjectType.L_INTERFACE, AAIObjectType.VSERVER.uriTemplate(), "/l-interfaces"); - public static final AAIObjectPlurals SUB_L_INTERFACE = - new AAIObjectPlurals(AAIObjectType.L_INTERFACE, AAIObjectType.L_INTERFACE.uriTemplate(), "/l-interfaces"); - public static final AAIObjectPlurals INSTANCE_GROUP = - new AAIObjectPlurals(AAIObjectType.INSTANCE_GROUP, AAINamespaceConstants.NETWORK, "/instance-groups"); - public static final AAIObjectPlurals PNF = - new AAIObjectPlurals(AAIObjectType.PNF, AAINamespaceConstants.NETWORK, "/pnfs"); - public static final AAIObjectPlurals PROJECT = - new AAIObjectPlurals(AAIObjectType.PROJECT, AAINamespaceConstants.BUSINESS, "/projects"); - public static final AAIObjectPlurals VSERVER = - new AAIObjectPlurals(AAIObjectType.VSERVER, AAIObjectType.TENANT.uriTemplate(), "/vservers"); - private final String uriTemplate; private final String partialUri; private final String name; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java index dae5c62dd3..55a487d675 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java @@ -27,175 +27,30 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; import org.onap.aai.annotations.Metadata; -import org.onap.aai.domain.yang.AggregateRoute; -import org.onap.aai.domain.yang.AllottedResource; -import org.onap.aai.domain.yang.AvailabilityZone; -import org.onap.aai.domain.yang.CloudRegion; -import org.onap.aai.domain.yang.Collection; -import org.onap.aai.domain.yang.CommunicationServiceProfile; -import org.onap.aai.domain.yang.Complex; -import org.onap.aai.domain.yang.Configuration; -import org.onap.aai.domain.yang.Connector; -import org.onap.aai.domain.yang.Customer; -import org.onap.aai.domain.yang.Device; -import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.aai.domain.yang.ExtAaiNetwork; -import org.onap.aai.domain.yang.Flavor; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Image; -import org.onap.aai.domain.yang.InstanceGroup; -import org.onap.aai.domain.yang.L3Network; -import org.onap.aai.domain.yang.LInterface; -import org.onap.aai.domain.yang.LagInterface; -import org.onap.aai.domain.yang.LineOfBusiness; -import org.onap.aai.domain.yang.LogicalLink; -import org.onap.aai.domain.yang.ModelVer; -import org.onap.aai.domain.yang.NetworkPolicy; -import org.onap.aai.domain.yang.NetworkTechnology; -import org.onap.aai.domain.yang.OperationalEnvironment; -import org.onap.aai.domain.yang.OwningEntity; -import org.onap.aai.domain.yang.PInterface; -import org.onap.aai.domain.yang.PhysicalLink; -import org.onap.aai.domain.yang.Platform; -import org.onap.aai.domain.yang.Pnf; -import org.onap.aai.domain.yang.PortGroup; -import org.onap.aai.domain.yang.Project; -import org.onap.aai.domain.yang.Pserver; -import org.onap.aai.domain.yang.RouteTableReference; -import org.onap.aai.domain.yang.Service; -import org.onap.aai.domain.yang.ServiceInstance; -import org.onap.aai.domain.yang.ServiceProfile; -import org.onap.aai.domain.yang.ServiceSubscription; -import org.onap.aai.domain.yang.SliceProfile; -import org.onap.aai.domain.yang.SpPartner; -import org.onap.aai.domain.yang.SriovPf; -import org.onap.aai.domain.yang.SriovVf; -import org.onap.aai.domain.yang.Subnet; -import org.onap.aai.domain.yang.Tenant; -import org.onap.aai.domain.yang.TunnelXconnect; -import org.onap.aai.domain.yang.Vce; -import org.onap.aai.domain.yang.VfModule; -import org.onap.aai.domain.yang.VlanRange; -import org.onap.aai.domain.yang.VlanTag; -import org.onap.aai.domain.yang.Vnfc; -import org.onap.aai.domain.yang.VolumeGroup; -import org.onap.aai.domain.yang.VpnBinding; -import org.onap.aai.domain.yang.Vserver; -import org.onap.aai.domain.yang.Zone; import org.onap.aaiclient.client.aai.entities.uri.AAIFluentTypeReverseLookup; +import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType; -import org.onap.so.constants.Defaults; import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; import com.google.common.base.CaseFormat; -public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, Serializable { +/** + * Types are accessed through AAIFluentTypeBuilder and should no longer be added as static members + * + */ +public class AAIObjectType implements AAIObjectBase, AAIObjectName, GraphInventoryObjectType, Serializable { private static final long serialVersionUID = -2877184776691514600L; private static Map<String, AAIObjectType> map = new HashMap<>(); - public static final AAIObjectType DEFAULT_CLOUD_REGION = new AAIObjectType( - AAINamespaceConstants.CLOUD_INFRASTRUCTURE, - "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}", "default-cloud-region"); - public static final AAIObjectType CUSTOMER = new AAIObjectType(AAINamespaceConstants.BUSINESS, Customer.class); public static final AAIObjectType GENERIC_QUERY = new AAIObjectType("/search", "/generic-query", "generic-query"); public static final AAIObjectType BULK_PROCESS = new AAIObjectType("/bulkprocess", "", "bulkprocess"); public static final AAIObjectType SINGLE_TRANSACTION = new AAIObjectType("/bulk/single-transaction", "", "single-transaction"); - public static final AAIObjectType GENERIC_VNF = new AAIObjectType(AAINamespaceConstants.NETWORK, GenericVnf.class); - public static final AAIObjectType GENERIC_VNFS = - new AAIObjectType(AAINamespaceConstants.NETWORK, "/generic-vnfs", "generic-vnfs"); - public static final AAIObjectType VF_MODULE = - new AAIObjectType(AAIObjectType.GENERIC_VNF.uriTemplate(), VfModule.class); - public static final AAIObjectType L3_NETWORK = new AAIObjectType(AAINamespaceConstants.NETWORK, L3Network.class); - public static final AAIObjectType NETWORK_POLICY = - new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkPolicy.class); public static final AAIObjectType NODES_QUERY = new AAIObjectType("/search", "/nodes-query", "nodes-query"); public static final AAIObjectType CUSTOM_QUERY = new AAIObjectType("/query", "", "query"); - public static final AAIObjectType ROUTE_TABLE_REFERENCE = - new AAIObjectType(AAINamespaceConstants.NETWORK, RouteTableReference.class); - public static final AAIObjectType DEFAULT_TENANT = - new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" - + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}", "default-tenant"); - public static final AAIObjectType VCE = new AAIObjectType(AAINamespaceConstants.NETWORK, Vce.class); - public static final AAIObjectType PORT_GROUP = new AAIObjectType(AAIObjectType.VCE.uriTemplate(), PortGroup.class); - public static final AAIObjectType VPN_BINDING = new AAIObjectType(AAINamespaceConstants.NETWORK, VpnBinding.class); - public static final AAIObjectType CONFIGURATION = - new AAIObjectType(AAINamespaceConstants.NETWORK, Configuration.class); - public static final AAIObjectType PSERVER = - new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class); - public static final AAIObjectType SERVICE_SUBSCRIPTION = - new AAIObjectType(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class); - - public static final AAIObjectType SERVICE_INSTANCE_METADATA = new AAIObjectType( - AAIObjectType.SERVICE_INSTANCE + "/metadata", org.onap.aai.domain.yang.v13.Metadata.class); - - public static final AAIObjectType SERVICE = new AAIObjectType( - AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/services/service/{service-id}", Service.class); - public static final AAIObjectType SERVICE_INSTANCE = - new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class); - public static final AAIObjectType PROJECT = new AAIObjectType(AAINamespaceConstants.BUSINESS, Project.class); - public static final AAIObjectType LINE_OF_BUSINESS = - new AAIObjectType(AAINamespaceConstants.BUSINESS, LineOfBusiness.class); - public static final AAIObjectType PLATFORM = new AAIObjectType(AAINamespaceConstants.BUSINESS, Platform.class); - public static final AAIObjectType OWNING_ENTITY = - new AAIObjectType(AAINamespaceConstants.BUSINESS, OwningEntity.class); - public static final AAIObjectType ALLOTTED_RESOURCE = - new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class); - public static final AAIObjectType ALLOTTED_RESOURCE_ALL = - new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/allotted-resources", "allottedResources"); - public static final AAIObjectType PNF = new AAIObjectType(AAINamespaceConstants.NETWORK, Pnf.class); - public static final AAIObjectType OPERATIONAL_ENVIRONMENT = - new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class); - public static final AAIObjectType CLOUD_REGION = - new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, CloudRegion.class); - public static final AAIObjectType TENANT = - new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Tenant.class); - public static final AAIObjectType VOLUME_GROUP = - new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), VolumeGroup.class); - public static final AAIObjectType VSERVER = new AAIObjectType(AAIObjectType.TENANT.uriTemplate(), Vserver.class); - public static final AAIObjectType MODEL_VER = new AAIObjectType( - AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", ModelVer.class); - public static final AAIObjectType TUNNEL_XCONNECT = - new AAIObjectType(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), TunnelXconnect.class); - public static final AAIObjectType P_INTERFACE = - new AAIObjectType(AAIObjectType.PSERVER.uriTemplate(), PInterface.class); - public static final AAIObjectType SRIOV_PF = - new AAIObjectType(AAIObjectType.P_INTERFACE.uriTemplate(), SriovPf.class); - public static final AAIObjectType LOGICAL_LINK = - new AAIObjectType(AAINamespaceConstants.NETWORK, LogicalLink.class); - public static final AAIObjectType PHYSICAL_LINK = - new AAIObjectType(AAINamespaceConstants.NETWORK, PhysicalLink.class); - public static final AAIObjectType INSTANCE_GROUP = - new AAIObjectType(AAINamespaceConstants.NETWORK, InstanceGroup.class); - public static final AAIObjectType COLLECTION = new AAIObjectType(AAINamespaceConstants.NETWORK, Collection.class); - public static final AAIObjectType VNFC = new AAIObjectType(AAINamespaceConstants.NETWORK, Vnfc.class); - public static final AAIObjectType VLAN_TAG = new AAIObjectType(AAINamespaceConstants.NETWORK, VlanTag.class); - public static final AAIObjectType COMPLEX = - new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class); - public static final AAIObjectType CONNECTOR = new AAIObjectType(AAINamespaceConstants.BUSINESS, Connector.class); - public static final AAIObjectType NETWORK_TECHNOLOGY = - new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class); - public static final AAIObjectType SUBNET = new AAIObjectType(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class); - public static final AAIObjectType SP_PARTNER = new AAIObjectType(AAINamespaceConstants.BUSINESS, SpPartner.class); - public static final AAIObjectType DEVICE = new AAIObjectType(AAINamespaceConstants.NETWORK, Device.class); - public static final AAIObjectType EXT_AAI_NETWORK = - new AAIObjectType(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class); - public static final AAIObjectType AGGREGATE_ROUTE = - new AAIObjectType(AAINamespaceConstants.NETWORK, AggregateRoute.class); - public static final AAIObjectType L_INTERFACE = - new AAIObjectType(AAIObjectType.VSERVER.uriTemplate(), LInterface.class); - public static final AAIObjectType SRIOV_VF = - new AAIObjectType(AAIObjectType.L_INTERFACE.uriTemplate(), SriovVf.class); - public static final AAIObjectType SUB_L_INTERFACE = new AAIObjectType(AAIObjectType.L_INTERFACE.uriTemplate(), - "/l-interfaces/l-interface/{sub-interface-name}", "sub-l-interface"); - public static final AAIObjectType IMAGE = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Image.class); - public static final AAIObjectType FLAVOR = - new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Flavor.class); - - public static final AAIObjectType VLAN_RANGE = new AAIObjectType(CLOUD_REGION.uriTemplate(), VlanRange.class); public static final AAIObjectType UNKNOWN = new AAIObjectType("", "", "unknown") { private static final long serialVersionUID = 9208984071038447607L; @@ -206,42 +61,9 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S } }; public static final AAIObjectType DSL = new AAIObjectType("/dsl", "", "dsl"); - public static final AAIObjectType VNFM = new AAIObjectType( - AAINamespaceConstants.EXTERNAL_SYSTEM + "/esr-vnfm-list/esr-vnfm/{vnfm-id}", EsrVnfm.class); - public static final AAIObjectType VNFM_LIST = - new AAIObjectType(AAINamespaceConstants.EXTERNAL_SYSTEM, "/esr-vnfm-list", "vnfm-list"); - public static final AAIObjectType VNFM_ESR_SYSTEM_INFO_LIST = - new AAIObjectType(AAINamespaceConstants.EXTERNAL_SYSTEM + "/esr-vnfm-list", - "/esr-vnfm/{vnfm-id}/esr-system-info-list", "vnfm-esr-system-info-list"); - public static final AAIObjectType CLOUD_ESR_SYSTEM_INFO_LIST = new AAIObjectType( - AAIObjectType.CLOUD_REGION.uriTemplate(), "/esr-system-info-list", "cloud-esr-system-info-list"); - public static final AAIObjectType ZONE = new AAIObjectType(AAINamespaceConstants.NETWORK, Zone.class); - public static final AAIObjectType AVAILIBILITY_ZONE = - new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), AvailabilityZone.class); - public static final AAIObjectType THIRDPARTY_SDNC_LIST = new AAIObjectType(AAINamespaceConstants.EXTERNAL_SYSTEM, - "/esr-thirdparty-sdnc-list", "thirdparty-sdnc-list"); - public static final AAIObjectType THIRDPARTY_SDNC_SYSTEM_INFO_LIST = - new AAIObjectType(AAINamespaceConstants.EXTERNAL_SYSTEM + "/esr-thirdparty-sdnc-list", - "/esr-thirdparty-sdnc/{sdnc-id}/esr-system-info-list", "thirdparty-sdnc-system-info-list"); - public static final AAIObjectType COMMUNICATION_SERVICE_PROFILE = - new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), CommunicationServiceProfile.class); - public static final AAIObjectType SERVICE_PROFILE = - new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceProfile.class); - public static final AAIObjectType SERVICE_PROFILE_ALL = - new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/service-profiles", "serviceProfiles"); - public static final AAIObjectType SLICE_PROFILE = - new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), SliceProfile.class); - public static final AAIObjectType SLICE_PROFILE_ALL = - new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/slice-profiles", "sliceProfiles"); - public static final AAIObjectType COMMUNICATION_PROFILE_ALL = new AAIObjectType( - AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/communication-service-profiles", "communicationProfiles"); - public static final AAIObjectType QUERY_ALLOTTED_RESOURCE = - new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "?depth=2", "service-Instance"); - - public static final AAIObjectType LAG_INTERFACE = - new AAIObjectType(AAIObjectType.PSERVER.uriTemplate(), LagInterface.class); - - + public static final AAIObjectType SUB_L_INTERFACE = new AAIObjectType( + "/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}", + "/l-interfaces/l-interface/{sub-interface-name}", "sub-l-interface"); private final String uriTemplate; private final String parentUri; @@ -346,8 +168,8 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S @Override public boolean equals(Object o) { - if (o instanceof AAIObjectBase) { - return this.typeName().equals(((AAIObjectBase) o).typeName()); + if (o instanceof GraphInventoryObjectName) { + return this.typeName().equals(((GraphInventoryObjectName) o).typeName()); } return false; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java index 0aff965ac0..c31d393b36 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java @@ -20,8 +20,6 @@ package org.onap.aaiclient.client.aai; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -36,9 +34,12 @@ import org.onap.aaiclient.client.aai.entities.CustomQuery; import org.onap.aaiclient.client.aai.entities.Results; 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.graphinventory.Format; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; public class AAIRestClientImpl implements AAIRestClientI { @@ -48,7 +49,7 @@ public class AAIRestClientImpl implements AAIRestClientI { @Override public List<Pserver> getPhysicalServerByVnfId(String vnfId) throws IOException { List<AAIResourceUri> startNodes = new ArrayList<>(); - startNodes.add(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + startNodes.add(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))); String jsonInput = new AAIQueryClient().query(Format.RESOURCE, new CustomQuery(startNodes, PSERVER_VNF_QUERY)); return this.getListOfPservers(jsonInput); @@ -70,20 +71,21 @@ public class AAIRestClientImpl implements AAIRestClientI { public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint) { GenericVnf genericVnf = new GenericVnf(); genericVnf.setInMaint(inMaint); - new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId), genericVnf); + new AAIResourcesClient() + .update(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)), genericVnf); } @Override public GenericVnf getVnfByName(String vnfId) { - return new AAIResourcesClient() - .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)).orElse(null); + return new AAIResourcesClient().get(GenericVnf.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))).orElse(null); } @Override public Optional<Pnf> getPnfByName(String pnfId) { - Response response = - new AAIResourcesClient().getFullResponse(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId)); + Response response = new AAIResourcesClient() + .getFullResponse(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnfId))); if (response.getStatus() != 200) { return Optional.empty(); } else { @@ -93,20 +95,22 @@ public class AAIRestClientImpl implements AAIRestClientI { @Override public void createPnf(String pnfId, Pnf pnf) { - new AAIResourcesClient().createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), - Optional.of(pnf)); + new AAIResourcesClient().createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnfId)), Optional.of(pnf)); } @Override public void updatePnf(String pnfId, Pnf pnf) { - new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), pnf); + new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().pnf(pnfId)), + pnf); } @Override public Optional<ServiceInstance> getServiceInstanceById(String globalSubscriberId, String serviceType, String serviceInstanceId) { - Response response = new AAIResourcesClient().getFullResponse(AAIUriFactory - .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)); + Response response = new AAIResourcesClient().getFullResponse( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId) + .serviceSubscription(serviceType).serviceInstance(serviceInstanceId))); return Optional.ofNullable(response.readEntity(ServiceInstance.class)); } @@ -114,8 +118,9 @@ public class AAIRestClientImpl implements AAIRestClientI { public void updateServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId, ServiceInstance serviceInstance) { try { - new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalSubscriberId, serviceType, serviceInstanceId), serviceInstance); + new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)), + serviceInstance); } catch (Throwable ex) { log.error("Exception happened while updating ServiceInstance, Exception: {}", ex.getLocalizedMessage()); throw new RuntimeException(ex); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookup.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookup.java index bd9f4c713f..95cb1fe7c2 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookup.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookup.java @@ -1,5 +1,6 @@ package org.onap.aaiclient.client.aai.entities.uri; +import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -20,7 +21,7 @@ public class AAIFluentTypeReverseLookup { (Class<? extends GraphInventoryFluentType.Info>) Class .forName("org.onap.aaiclient.client.generated.fluentbuilders." + className + "$Info"); - GraphInventoryFluentType.Info type = clazz.newInstance(); + GraphInventoryFluentType.Info type = clazz.getConstructor().newInstance(); Optional<String> parentTemplate = findParentPath(type, uri); if (parentTemplate.isPresent()) { @@ -29,7 +30,8 @@ public class AAIFluentTypeReverseLookup { // fallback to enum lookup return AAIObjectType.fromTypeName(name); } - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | NoSuchMethodException | SecurityException e) { } return AAIObjectType.UNKNOWN; } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java index 6bb2cbd471..be49535f3e 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java @@ -21,29 +21,43 @@ package org.onap.aaiclient.client.aai.entities.uri; import java.net.URI; +import org.onap.aaiclient.client.aai.AAIObjectName; import org.onap.aaiclient.client.aai.AAIObjectPlurals; import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; public class AAIUriFactory { + + public static final AAIFluentTypeReverseLookup reverseLookup = new AAIFluentTypeReverseLookup(); + /** * values are filled into the URI template specified in {@link AAIObjectType} in order <br> - * There are two special lookups performed on certain types when a single value is specified: <br> - * Service Instance and AllottedResources <br> - * These can be retrieved without all their required keys but an HTTP call is required to do so - * + * * @param type * @param values * @return */ public static AAIResourceUri createResourceUri(AAIObjectType type, Object... values) { - if (AAIObjectType.SERVICE_INSTANCE.equals(type)) { - return new ServiceInstanceUri(values); - } else if (AAIObjectType.ALLOTTED_RESOURCE.equals(type)) { - return new AllottedResourceLookupUri(values); + return new AAISimpleUri(type, values); + } + + /** + * These can be retrieved without all their required keys but an HTTP call is required to do so + * + * @param type + * @param values + * @return + */ + public static AAIResourceUri createResourceUri(AAISingleFragment fragment) { + + if (Types.SERVICE_INSTANCE.typeName().equals(fragment.get().build().typeName())) { + return new ServiceInstanceUri(fragment); + } else if (Types.ALLOTTED_RESOURCE.typeName().equals(fragment.get().build().typeName())) { + return new AllottedResourceLookupUri(fragment); } else { - return new AAISimpleUri(type, values); + return null; } } @@ -51,13 +65,16 @@ public class AAIUriFactory { return new AAISimpleUri(uri.build(), uri.values()); } - public static NodesSingleUri createNodesUri(AAIObjectType type, Object... values) { + protected static NodesSingleUri createNodesUri(AAIObjectType type, Object... values) { return new NodesSingleUri(type, values); + } + public static NodesSingleUri createNodesUri(AAISingleFragment fragment) { + return new NodesSingleUri(fragment.get().build(), fragment.get().values()); } - public static NodesPluralUri createNodesUri(AAIObjectPlurals type) { - return new NodesPluralUri(type); + public static NodesPluralUri createNodesUri(AAIPluralFragment fragment) { + return new NodesPluralUri(fragment.get().build()); } @@ -68,7 +85,8 @@ public class AAIUriFactory { * @param uri * @return */ - public static AAISimpleUri createResourceFromExistingURI(AAIObjectType type, URI uri) { + public static AAISimpleUri createResourceFromExistingURI(AAIObjectName name, URI uri) { + AAIObjectType type = reverseLookup.fromName(name.typeName(), uri.toString()); return new AAISimpleUri(type, uri); } @@ -81,20 +99,19 @@ public class AAIUriFactory { * @param childValues * @return */ - public static AAISimpleUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectType childType, - Object... childValues) { + public static AAISimpleUri createResourceFromParentURI(AAIResourceUri parentUri, AAISingleFragment fragment) { - return new AAISimpleUri(parentUri, childType, childValues); + return new AAISimpleUri(parentUri, fragment.get().build(), fragment.get().values()); } - public static AAISimplePluralUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectPlurals childType) { + public static AAISimplePluralUri createResourceFromParentURI(AAIResourceUri parentUri, AAIPluralFragment fragment) { - return new AAISimplePluralUri(parentUri, childType); + return new AAISimplePluralUri(parentUri, fragment.get().build()); } public static AAISimplePluralUri createResourceUri(AAIFluentPluralType uri) { - return new AAISimplePluralUri(uri.build()); + return new AAISimplePluralUri(uri.build(), uri.values()); } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java index 7f51835580..099f717238 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java @@ -25,22 +25,25 @@ import java.util.Optional; import javax.ws.rs.core.UriBuilder; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; public class AllottedResourceLookupUri extends HttpLookupUri { private static final long serialVersionUID = -9212594383876793188L; - protected AllottedResourceLookupUri(Object... values) { - super(AAIObjectType.ALLOTTED_RESOURCE, values); + protected AllottedResourceLookupUri(AAIObjectType type, UriBuilder builder, Optional<String> cachedValue, + Object... values) { + super(type, builder, cachedValue, values); } - protected AllottedResourceLookupUri(UriBuilder builder, Optional<String> cachedValue, Object... values) { - super(AAIObjectType.ALLOTTED_RESOURCE, builder, cachedValue, values); + protected AllottedResourceLookupUri(AAISingleFragment fragment) { + super(AAIFluentTypeBuilder.business().customer("").serviceSubscription("").serviceInstance("") + .allottedResource("").build(), fragment.get().values()); } @Override public AllottedResourceLookupUri clone() { - return new AllottedResourceLookupUri(this.internalURI.clone(), this.getCachedValue(), values); + return new AllottedResourceLookupUri(this.aaiType, this.internalURI.clone(), this.getCachedValue(), values); } public AAIResourcesClient getResourcesClient() { diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java index c39eb50dc2..42f52565cd 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java @@ -45,7 +45,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri { private transient Optional<String> cachedValue = Optional.empty(); - private final AAIObjectType aaiType; + protected final AAIObjectType aaiType; protected HttpLookupUri(AAIObjectType type, Object... values) { super(type, values); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java index 96eaac5815..366a011b14 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java @@ -25,22 +25,25 @@ import java.util.Optional; import javax.ws.rs.core.UriBuilder; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; public class ServiceInstanceUri extends HttpLookupUri { private static final long serialVersionUID = 2248914170527514548L; - protected ServiceInstanceUri(Object... values) { - super(AAIObjectType.SERVICE_INSTANCE, values); + protected ServiceInstanceUri(AAIObjectType type, UriBuilder builder, Optional<String> cachedValue, + Object... values) { + super(type, builder, cachedValue, values); } - protected ServiceInstanceUri(UriBuilder builder, Optional<String> cachedValue, Object... values) { - super(AAIObjectType.SERVICE_INSTANCE, builder, cachedValue, values); + protected ServiceInstanceUri(AAISingleFragment fragment) { + super(AAIFluentTypeBuilder.business().customer("").serviceSubscription("").serviceInstance("").build(), + fragment.get().values()); } @Override public ServiceInstanceUri clone() { - return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values); + return new ServiceInstanceUri(this.aaiType, this.internalURI.clone(), this.getCachedValue(), values); } public AAIResourcesClient getResourcesClient() { diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java index 000521bdf6..12051fb07d 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIObjectTypeTest.java @@ -22,16 +22,15 @@ package org.onap.aaiclient.client.aai; import static org.junit.Assert.assertEquals; import org.junit.Test; -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; public class AAIObjectTypeTest { @Test public void fromTypeNameTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException { - AAIObjectType type = AAIObjectType.fromTypeName("allotted-resource"); - assertEquals("allotted-resource", type.typeName()); + AAIObjectType type = AAIObjectType.fromTypeName("generic-query"); + assertEquals("generic-query", type.typeName()); } @@ -43,58 +42,14 @@ public class AAIObjectTypeTest { } @Test - public void verifyDefaultCase() { - assertEquals("default removed for tenant", "tenant", AAIObjectType.DEFAULT_TENANT.typeName()); - assertEquals("default removed for cloud-region", "cloud-region", AAIObjectType.DEFAULT_CLOUD_REGION.typeName()); - } - - @Test - public void verifyRegularCase() { - assertEquals("default removed for tenant", "allotted-resource", AAIObjectType.ALLOTTED_RESOURCE.typeName()); - } - - @Test - public void instanceGroupObjectTypeTest() { - final String id = "test1"; - AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, id); - assertEquals("/network/instance-groups/instance-group/test1", aaiUri.build().toString()); - } - - @Test - public void collectionObjectTypeTest() { - final String id = "test1"; - AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, id); - assertEquals("/network/collections/collection/test1", aaiUri.build().toString()); - } - - @Test - public void genericVnfTest() { - AAIObjectType type = AAIObjectType.GENERIC_VNF; - assertEquals("/network/generic-vnfs/generic-vnf/{vnf-id}", type.uriTemplate()); - assertEquals("/generic-vnfs/generic-vnf/{vnf-id}", type.partialUri()); - } - - @Test - public void pInterfaceTest() { - AAIObjectType type = AAIObjectType.P_INTERFACE; - assertEquals("/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces/p-interface/{interface-name}", - type.uriTemplate()); - assertEquals("/p-interfaces/p-interface/{interface-name}", type.partialUri()); - } - - @Test - public void networkPolicyObjectTypeTest() { - final String id = "test1"; - AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, id); - assertEquals("/network/network-policies/network-policy/test1", aaiUri.build().toString()); - } - - @Test public void equalityTest() { AAIObjectType genericVnf = AAIFluentTypeBuilder.network().genericVnf("test").build(); + AAIObjectType genericVnf2 = AAIFluentTypeBuilder.network().genericVnf("test2").build(); + + assertEquals(genericVnf2, genericVnf); - assertEquals(AAIObjectType.GENERIC_VNF, genericVnf); + assertEquals(genericVnf, Types.GENERIC_VNF); } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIQueryClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIQueryClientTest.java index 15fe03e93f..29d862478c 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIQueryClientTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIQueryClientTest.java @@ -43,17 +43,18 @@ import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.Complex; -import org.onap.so.client.RestClient; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.CustomQuery; import org.onap.aaiclient.client.aai.entities.Results; 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.aaiclient.client.graphinventory.Format; import org.onap.aaiclient.client.graphinventory.GraphInventoryClient; import org.onap.aaiclient.client.graphinventory.GraphInventorySubgraphType; import org.onap.aaiclient.client.graphinventory.entities.Pathed; import org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl; +import org.onap.so.client.RestClient; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -112,7 +113,7 @@ public class AAIQueryClientTest { doReturn(getJson("single-query-result.json")).when(aaiQueryClient).query(eq(Format.RESOURCE_AND_URL), any(CustomQuery.class)); List<Complex> result = aaiQueryClient.querySingleResource( - new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(AAIObjectType.COMPLEX, "test"))), + new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(Types.COMPLEX.getFragment("test")))), Complex.class); assertEquals(2, result.size()); assertEquals("complex-id-15100-jc689q2", result.get(1).getPhysicalLocationId()); @@ -123,11 +124,10 @@ public class AAIQueryClientTest { doReturn(getJson("single-query-result.json")).when(aaiQueryClient).query(eq(Format.RESOURCE_AND_URL), any(CustomQuery.class)); List<ResourceAndUrl<AAIResultWrapper>> result = aaiQueryClient.getResourceAndUrl( - new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(AAIObjectType.COMPLEX, "test")))); + new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(Types.COMPLEX.getFragment("test"))))); assertEquals(2, result.size()); - assertEquals(1, - result.get(1).getWrapper().getRelationships().get().getRelatedUris(AAIObjectType.PSERVER).size()); + assertEquals(1, result.get(1).getWrapper().getRelationships().get().getRelatedUris(Types.PSERVER).size()); } @Test @@ -138,7 +138,7 @@ public class AAIQueryClientTest { List<Pathed> results = aaiQueryClient.queryPathed( - new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(AAIObjectType.COMPLEX, "test")))); + new CustomQuery(Arrays.asList(AAIUriFactory.createNodesUri(Types.COMPLEX.getFragment("test"))))); assertEquals(2, results.size()); assertEquals("service-instance", results.get(1).getResourceType()); 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 ca361f46d8..36ba1f3e76 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 @@ -55,6 +55,7 @@ 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.defaultproperties.DefaultAAIPropertiesImpl; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryMultipleItemsException; import org.onap.so.client.RestClient; import com.github.tomakehurst.wiremock.admin.NotFoundException; @@ -86,7 +87,7 @@ public class AAIResourcesClientTest { @Test public void verifyNotExists() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test")); wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) .willReturn(aResponse().withHeader("Content-Type", "text/plain").withBody("hello").withStatus(404))); AAIResourcesClient client = aaiClient; @@ -96,7 +97,7 @@ public class AAIResourcesClientTest { @Test public void verifyDelete() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test2")); wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBodyFile("aai/resources/mockObject.json").withStatus(200))); @@ -108,7 +109,7 @@ public class AAIResourcesClientTest { @Test public void verifyBasicAuth() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test3")); wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString())) .withHeader("Authorization", equalTo("Basic dGVzdDp0ZXN0")) .willReturn(aResponse().withHeader("Content-Type", "application/json") @@ -119,8 +120,8 @@ public class AAIResourcesClientTest { @Test public void verifyConnect() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); - AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test2")); + AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test3")); wireMockRule.stubFor( put(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build() + "/relationship-list/relationship")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(200))); @@ -133,8 +134,8 @@ public class AAIResourcesClientTest { @Test public void verifyDisconnect() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); - AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test2")); + AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test3")); wireMockRule.stubFor( delete(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build() + "/relationship-list/relationship")) @@ -148,7 +149,7 @@ public class AAIResourcesClientTest { @Test public void verifyPatch() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test2")); wireMockRule.stubFor(post(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) .willReturn(aResponse().withStatus(200))); @@ -160,7 +161,7 @@ public class AAIResourcesClientTest { @Test public void verifyNotExistsGet() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test")); wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) .willReturn(aResponse().withHeader("Content-Type", "text/plain").withBody("hello").withStatus(404))); AAIResourcesClient client = aaiClient; @@ -170,7 +171,7 @@ public class AAIResourcesClientTest { @Test public void verifyNotExistsGetException() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test")); wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) .willReturn(aResponse().withHeader("Content-Type", "text/plain").withBody("hello").withStatus(404))); AAIResourcesClient client = aaiClient; @@ -181,7 +182,7 @@ public class AAIResourcesClientTest { @Test public void verifyFailedCallException() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test")); wireMockRule.stubFor(get(urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())).willReturn(aResponse() .withHeader("Content-Type", "text/plain").withBodyFile("aai/error-message.json").withStatus(400))); AAIResourcesClient client = aaiClient; @@ -195,7 +196,7 @@ public class AAIResourcesClientTest { @Test public void buildRelationshipTest() { AAIResourcesClient client = aaiClient; - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test")); Relationship relationship = new Relationship(); relationship.setRelatedLink(uri.build().toString()); Relationship actual = client.buildRelationship(uri); @@ -213,7 +214,7 @@ public class AAIResourcesClientTest { vnf.setVnfId("my-vnf-id"); GenericVnfs vnfs = new GenericVnfs(); vnfs.getGenericVnf().add(vnf); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()); RestClient restClientMock = mock(RestClient.class); doReturn(restClientMock).when(client).createClient(uri); when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.of(vnfs)); @@ -232,7 +233,7 @@ public class AAIResourcesClientTest { GenericVnfs vnfs = new GenericVnfs(); vnfs.getGenericVnf().add(vnf); vnfs.getGenericVnf().add(vnf2); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()); RestClient restClientMock = mock(RestClient.class); doReturn(restClientMock).when(client).createClient(uri); when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.of(vnfs)); @@ -250,7 +251,7 @@ public class AAIResourcesClientTest { GenericVnfs vnfs = new GenericVnfs(); vnfs.getGenericVnf().add(vnf); vnfs.getGenericVnf().add(vnf2); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()); RestClient restClientMock = mock(RestClient.class); doReturn(restClientMock).when(client).createClient(uri); when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.of(vnfs)); @@ -266,7 +267,7 @@ public class AAIResourcesClientTest { vnf.setVnfId("my-vnf-id"); GenericVnfs vnfs = new GenericVnfs(); vnfs.getGenericVnf().add(vnf); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()); RestClient restClientMock = mock(RestClient.class); doReturn(restClientMock).when(client).createClient(uri); when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.empty()); @@ -282,7 +283,7 @@ public class AAIResourcesClientTest { vnf.setVnfId("my-vnf-id"); GenericVnfs vnfs = new GenericVnfs(); vnfs.getGenericVnf().add(vnf); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()); RestClient restClientMock = mock(RestClient.class); doReturn(restClientMock).when(client).createClient(uri); when(restClientMock.get(GenericVnfs.class)).thenReturn(Optional.empty()); @@ -295,7 +296,7 @@ public class AAIResourcesClientTest { @Test public void testGetFirstWrongPluralClass() { GenericVnf vnf = new GenericVnf(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnfs()); RestClient restClientMock = mock(RestClient.class); doReturn(restClientMock).when(client).createClient(uri); when(restClientMock.get(GenericVnf.class)).thenReturn(Optional.of(vnf)); diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java index 9e0825bbb5..23c06a6817 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java @@ -45,6 +45,7 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.aai.entities.uri.ServiceInstanceUri; import org.onap.aaiclient.client.defaultproperties.DefaultAAIPropertiesImpl; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import com.github.tomakehurst.wiremock.junit.WireMockRule; @RunWith(MockitoJUnitRunner.class) @@ -70,7 +71,7 @@ public class AAIResourcesClientWithServiceInstanceUriTest { wireMockRule.stubFor(get(urlMatching("/aai/v[0-9]+/nodes.*")).willReturn( aResponse().withStatus(404).withHeader("Content-Type", "application/json").withHeader("Mock", "true"))); - uri = spy((ServiceInstanceUri) AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "id")); + uri = spy((ServiceInstanceUri) AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment("id"))); doReturn(aaiClient).when(uri).getResourcesClient(); } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAISingleTransactionClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAISingleTransactionClientTest.java index 0820397fd6..7035999a69 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAISingleTransactionClientTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAISingleTransactionClientTest.java @@ -49,6 +49,7 @@ import org.onap.aaiclient.client.aai.entities.singletransaction.SingleTransactio import org.onap.aaiclient.client.aai.entities.singletransaction.SingleTransactionResponse; 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.graphinventory.GraphInventoryPatchConverter; import org.skyscreamer.jsonassert.JSONAssert; import com.fasterxml.jackson.core.JsonParseException; @@ -60,9 +61,12 @@ import com.fasterxml.jackson.databind.SerializationFeature; public class AAISingleTransactionClientTest { private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/singletransaction/"; - AAIResourceUri uriA = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "pserver-hostname"); - AAIResourceUri uriB = AAIUriFactory.createResourceUri(AAIObjectType.COMPLEX, "my-complex"); - AAIResourceUri uriC = AAIUriFactory.createResourceUri(AAIObjectType.COMPLEX, "my-complex2"); + AAIResourceUri uriA = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver("pserver-hostname")); + AAIResourceUri uriB = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().complex("my-complex")); + AAIResourceUri uriC = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().complex("my-complex2")); ObjectMapper mapper; diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAITransactionalClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAITransactionalClientTest.java index bf2417141f..cda119ef13 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAITransactionalClientTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAITransactionalClientTest.java @@ -45,6 +45,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.Relationship; 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.graphinventory.GraphInventoryPatchConverter; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; @@ -56,13 +57,13 @@ import com.fasterxml.jackson.databind.SerializationFeature; public class AAITransactionalClientTest { private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/bulkprocess/"; - AAIResourceUri uriA = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); - AAIResourceUri uriB = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test2"); - AAIResourceUri uriC = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); - AAIResourceUri uriD = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test4"); - AAIResourceUri uriE = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test5"); - AAIResourceUri uriF = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test6"); - AAIResourceUri uriG = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test7"); + AAIResourceUri uriA = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test1")); + AAIResourceUri uriB = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver("test2")); + AAIResourceUri uriC = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test3")); + AAIResourceUri uriD = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver("test4")); + AAIResourceUri uriE = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test5")); + AAIResourceUri uriF = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver("test6")); + AAIResourceUri uriG = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("test7")); ObjectMapper mapper; diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIURITest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIURITest.java index f2bd188ab3..7fad6f512f 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIURITest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIURITest.java @@ -25,6 +25,7 @@ import javax.ws.rs.core.UriBuilder; import org.junit.Test; 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; public class AAIURITest { @@ -33,8 +34,9 @@ public class AAIURITest { @Test public void verifyTemplateReplacement() { final String id = "test1"; - AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, id); - String manualReplace = AAIObjectType.CONFIGURATION.toString().replaceAll("\\{configuration-id\\}", id); + AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().configuration(id)); + String manualReplace = + AAIFluentTypeBuilder.network().configuration(id).uriTemplate().replaceAll("\\{configuration-id\\}", id); assertEquals("uri template replaced", aaiUri.build(), UriBuilder.fromPath(manualReplace).build()); } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java index b0b0c6aca9..4b5085edf2 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java @@ -23,6 +23,7 @@ package org.onap.aaiclient.client.aai; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.entities.DSLNodeKey; import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder; import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode; @@ -36,12 +37,11 @@ public class DSLQueryBuilderTest { @Test public void whereTest() { - DSLQueryBuilder<Start, Start> builder = TraversalBuilder.fragment(new DSLStartNode(AAIObjectType.CLOUD_REGION, + DSLQueryBuilder<Start, Start> builder = TraversalBuilder.fragment(new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", "att-nc"), __.key("cloud-region-id", "test"))); - builder.to(__.node(AAIObjectType.VLAN_TAG)) - .where(__.node(AAIObjectType.OWNING_ENTITY, __.key("owning-entity-name", "name"))) - .to(__.node(AAIObjectType.VLAN_TAG, __.key("vlan-id-outer", "108")).output()); + builder.to(__.node(Types.VLAN_TAG)).where(__.node(Types.OWNING_ENTITY, __.key("owning-entity-name", "name"))) + .to(__.node(Types.VLAN_TAG, __.key("vlan-id-outer", "108")).output()); assertEquals("cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'test') > " + "vlan-tag (> owning-entity('owning-entity-name', 'name')) > " + "vlan-tag*('vlan-id-outer', '108')", @@ -50,12 +50,11 @@ public class DSLQueryBuilderTest { @Test public void unionTest() { - DSLQueryBuilder<Output, Output> builder = TraversalBuilder - .traversal(new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("vnf-id", "vnfId")).output()); + DSLQueryBuilder<Output, Output> builder = + TraversalBuilder.traversal(new DSLStartNode(Types.GENERIC_VNF, __.key("vnf-id", "vnfId")).output()); - builder.union(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()), - __.node(AAIObjectType.VSERVER) - .to(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()))); + builder.union(__.node(Types.PSERVER).output().to(__.node(Types.COMPLEX).output()), + __.node(Types.VSERVER).to(__.node(Types.PSERVER).output().to(__.node(Types.COMPLEX).output()))); assertEquals( "generic-vnf*('vnf-id', 'vnfId') > " + "[ pserver* > complex*, " + "vserver > pserver* > complex* ]", @@ -64,11 +63,11 @@ public class DSLQueryBuilderTest { @Test public void whereUnionTest() { - DSLQueryBuilder<Output, Output> builder = TraversalBuilder - .traversal(new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("vnf-id", "vnfId")).output()); + DSLQueryBuilder<Output, Output> builder = + TraversalBuilder.traversal(new DSLStartNode(Types.GENERIC_VNF, __.key("vnf-id", "vnfId")).output()); - builder.where(__.union(__.node(AAIObjectType.PSERVER, __.key("hostname", "hostname1")), - __.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.PSERVER, __.key("hostname", "hostname1"))))); + builder.where(__.union(__.node(Types.PSERVER, __.key("hostname", "hostname1")), + __.node(Types.VSERVER).to(__.node(Types.PSERVER, __.key("hostname", "hostname1"))))); assertEquals("generic-vnf*('vnf-id', 'vnfId') (> [ pserver('hostname', 'hostname1'), " + "vserver > pserver('hostname', 'hostname1') ])", builder.build().get()); @@ -76,38 +75,38 @@ public class DSLQueryBuilderTest { @Test public void notNullTest() { - DSLQueryBuilder<Output, Output> builder = TraversalBuilder.traversal( - new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "", "null").not()).output()); + DSLQueryBuilder<Output, Output> builder = TraversalBuilder + .traversal(new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", "", "null").not()).output()); assertEquals("cloud-region* !('cloud-owner', ' ', ' null ')", builder.build().get()); } @Test public void shortCutToTest() { - DSLQueryBuilder<Output, Output> builder = TraversalBuilder - .traversal(new DSLStartNode(AAIObjectType.PSERVER, __.key("hostname", "my-hostname")).output()); + DSLQueryBuilder<Output, Output> builder = + TraversalBuilder.traversal(new DSLStartNode(Types.PSERVER, __.key("hostname", "my-hostname")).output()); - builder.to(AAIObjectType.P_INTERFACE).to(AAIObjectType.SRIOV_PF, __.key("pf-pci-id", "my-id")); + builder.to(Types.P_INTERFACE).to(Types.SRIOV_PF, __.key("pf-pci-id", "my-id")); assertEquals("pserver*('hostname', 'my-hostname') > p-interface > sriov-pf('pf-pci-id', 'my-id')", builder.build().get()); } @Test public void limitTest() { - DSLQueryBuilder<Output, Output> builder = TraversalBuilder - .traversal(new DSLStartNode(AAIObjectType.PSERVER, __.key("hostname", "my-hostname")).output()); + DSLQueryBuilder<Output, Output> builder = + TraversalBuilder.traversal(new DSLStartNode(Types.PSERVER, __.key("hostname", "my-hostname")).output()); - builder.to(AAIObjectType.P_INTERFACE).limit(2).to(AAIObjectType.SRIOV_PF, __.key("pf-pci-id", "my-id")); + builder.to(Types.P_INTERFACE).limit(2).to(Types.SRIOV_PF, __.key("pf-pci-id", "my-id")); assertEquals("pserver*('hostname', 'my-hostname') > p-interface > sriov-pf('pf-pci-id', 'my-id') LIMIT 2", builder.build().get()); } @Test public void equalsTest() { - DSLQueryBuilder<Output, Output> builder = TraversalBuilder - .traversal(new DSLStartNode(AAIObjectType.PSERVER, __.key("hostname", "my-hostname")).output()); + DSLQueryBuilder<Output, Output> builder = + TraversalBuilder.traversal(new DSLStartNode(Types.PSERVER, __.key("hostname", "my-hostname")).output()); - builder.to(AAIObjectType.P_INTERFACE).to(AAIObjectType.SRIOV_PF, __.key("pf-pci-id", "my-id")); + builder.to(Types.P_INTERFACE).to(Types.SRIOV_PF, __.key("pf-pci-id", "my-id")); assertTrue( builder.equals("pserver*('hostname', 'my-hostname') > p-interface > sriov-pf('pf-pci-id', 'my-id')")); assertTrue(builder.equals(builder)); @@ -115,32 +114,30 @@ public class DSLQueryBuilderTest { @Test public void mixedTypeTest() { - DSLQueryBuilder<Start, Start> builder = TraversalBuilder.fragment(new DSLStartNode(AAIObjectType.CLOUD_REGION, - __.key("cloud-owner", "owner"), __.key("cloud-region-id", "id"))); - builder.to(__.node(AAIObjectType.VLAN_TAG, __.key("vlan-id-outer", 167), __.key("my-boolean", true)).output()); + DSLQueryBuilder<Start, Start> builder = TraversalBuilder.fragment( + new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", "owner"), __.key("cloud-region-id", "id"))); + builder.to(__.node(Types.VLAN_TAG, __.key("vlan-id-outer", 167), __.key("my-boolean", true)).output()); assertTrue(builder.equals( "cloud-region('cloud-owner', 'owner')('cloud-region-id', 'id') > vlan-tag*('vlan-id-outer', 167)('my-boolean', true)")); } @Test public void outputOnNodeLambdasTest() { - DSLQueryBuilder<Start, Start> builder = TraversalBuilder - .fragment(new DSLStartNode(AAIObjectType.L_INTERFACE, new DSLNodeKey("interface-id", "myId"))); + DSLQueryBuilder<Start, Start> builder = + TraversalBuilder.fragment(new DSLStartNode(Types.L_INTERFACE, new DSLNodeKey("interface-id", "myId"))); - builder.to(AAIObjectType.VSERVER, __.key("vserver-name", "myName")).output().to(AAIObjectType.P_INTERFACE) - .output(); + builder.to(Types.VSERVER, __.key("vserver-name", "myName")).output().to(Types.P_INTERFACE).output(); assertEquals("l-interface('interface-id', 'myId') > vserver*('vserver-name', 'myName') > p-interface*", builder.build().get()); } @Test public void skipOutputOnUnionTest() { - DSLQueryBuilder<Output, Output> builder = TraversalBuilder - .traversal(new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("vnf-id", "vnfId")).output()); + DSLQueryBuilder<Output, Output> builder = + TraversalBuilder.traversal(new DSLStartNode(Types.GENERIC_VNF, __.key("vnf-id", "vnfId")).output()); - builder.union(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()), - __.node(AAIObjectType.VSERVER) - .to(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()))) + builder.union(__.node(Types.PSERVER).output().to(__.node(Types.COMPLEX).output()), + __.node(Types.VSERVER).to(__.node(Types.PSERVER).output().to(__.node(Types.COMPLEX).output()))) .output(); assertEquals( @@ -150,10 +147,10 @@ public class DSLQueryBuilderTest { @Test public void selectOutputFilterTest() { - DSLQueryBuilder<Output, Output> builder = TraversalBuilder - .traversal(new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")) + DSLQueryBuilder<Output, Output> builder = + TraversalBuilder.traversal(new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")) .output("cloud-region-id", "a", "b")); - builder.to(__.node(AAIObjectType.PSERVER)).output("x", "y", "z"); + builder.to(__.node(Types.PSERVER)).output("x", "y", "z"); assertEquals("cloud-region{'cloud-region-id', 'a', 'b'}('cloud-owner', 'CloudOwner') > pserver{'x', 'y', 'z'}", builder.build().toString()); @@ -161,7 +158,7 @@ public class DSLQueryBuilderTest { @Test public void selectOutputFilterOnNodeTest() { - DSLStartNode node = new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")); + DSLStartNode node = new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")); DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(node).output("cloud-region-id"); assertEquals("cloud-region{'cloud-region-id'}('cloud-owner', 'CloudOwner')", builder.build().toString()); diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/RelationshipsTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/RelationshipsTest.java index 9e106fab85..75dbd4aea2 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/RelationshipsTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/RelationshipsTest.java @@ -30,9 +30,10 @@ import java.util.List; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; -import org.onap.aaiclient.client.aai.AAIObjectType; 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; public class RelationshipsTest { @@ -45,12 +46,16 @@ public class RelationshipsTest { AAIResultWrapper wrapper = new AAIResultWrapper(content); Relationships relationships = wrapper.getRelationships().get(); - List<AAIResourceUri> test = relationships.getRelatedUris(AAIObjectType.VCE); + List<AAIResourceUri> test = relationships.getRelatedUris(Types.VCE); List<AAIResourceUri> uris = Arrays.asList( - AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a9fec18e-1ea3-40e4-a6c0-a89b3de07053"), - AAIUriFactory.createResourceUri(AAIObjectType.VCE, "8ae1e5f8-61f1-4c71-913a-b40cc4593cb9"), - AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a2935fa9-b743-49f4-9813-a127f13c4e93"), - AAIUriFactory.createResourceUri(AAIObjectType.VCE, "c7fe7698-8063-4e26-8bd3-ca3edde0b0d4")); + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().vce("a9fec18e-1ea3-40e4-a6c0-a89b3de07053")), + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().vce("8ae1e5f8-61f1-4c71-913a-b40cc4593cb9")), + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().vce("a2935fa9-b743-49f4-9813-a127f13c4e93")), + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().vce("c7fe7698-8063-4e26-8bd3-ca3edde0b0d4"))); assertTrue(uris.containsAll(test) && test.containsAll(uris)); @@ -67,14 +72,14 @@ public class RelationshipsTest { ArgumentCaptor<AAIResourceUri> argument = ArgumentCaptor.forClass(AAIResourceUri.class); doReturn(new AAIResultWrapper("{}")).when(spy).get(argument.capture()); - spy.getByType(AAIObjectType.VCE, uri -> uri.nodesOnly(true)); + spy.getByType(Types.VCE, uri -> uri.nodesOnly(true)); assertTrue(argument.getAllValues().stream().allMatch(item -> item.build().toString().contains("nodes-only"))); argument = ArgumentCaptor.forClass(AAIResourceUri.class); doReturn(new AAIResultWrapper("{}")).when(spy).get(argument.capture()); - spy.getByType(AAIObjectType.VCE); + spy.getByType(Types.VCE); assertTrue(argument.getAllValues().stream().allMatch(item -> !item.build().toString().contains("?"))); 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); } diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImplTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImplTest.java index 270aca072c..7b3e80fa46 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImplTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImplTest.java @@ -23,9 +23,7 @@ package org.onap.aaiclient.client.graphinventory.entities.uri.parsers; import static org.junit.Assert.assertEquals; import java.util.Map; import org.junit.Test; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.graphinventory.entities.uri.parsers.UriParser; -import org.onap.aaiclient.client.graphinventory.entities.uri.parsers.UriParserSpringImpl; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; public class UriParserSpringImplTest { @@ -33,7 +31,8 @@ public class UriParserSpringImplTest { @Test public void reverseTemplate() { - final UriParser parser = new UriParserSpringImpl(AAIObjectType.SERVICE_INSTANCE.toString()); + final UriParser parser = new UriParserSpringImpl( + AAIFluentTypeBuilder.business().customer("").serviceSubscription("").serviceInstance("").uriTemplate()); final String uri = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"; diff --git a/graph-inventory/fluent-builder-maven-plugin/pom.xml b/graph-inventory/fluent-builder-maven-plugin/pom.xml index f0884758b8..87f5138b4b 100644 --- a/graph-inventory/fluent-builder-maven-plugin/pom.xml +++ b/graph-inventory/fluent-builder-maven-plugin/pom.xml @@ -8,10 +8,6 @@ </parent> <artifactId>fluent-builder-maven-plugin</artifactId> <packaging>maven-plugin</packaging> - <properties> - <maven.compiler.source>1.8</maven.compiler.source> - <maven.compiler.target>1.8</maven.compiler.target> - </properties> <build> <plugins> <plugin> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index c7692cb2cc..b09d676b57 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -23,7 +23,12 @@ package org.onap.so.apihandlerinfra; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -34,14 +39,13 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.*; +import org.apache.http.HttpStatus; +import org.json.JSONObject; import org.onap.aai.domain.yang.v16.ServiceInstance; -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.apache.http.HttpStatus; -import org.json.JSONObject; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.logging.filter.base.ErrorCode; import org.onap.so.apihandler.camundabeans.CamundaResponse; import org.onap.so.apihandler.common.CamundaClient; @@ -53,6 +57,7 @@ import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.CompareModelsRequest; import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceDeleteRequest; import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest; import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceScaleRequest; +import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2ESliceServiceActivateRequest; import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; @@ -380,8 +385,9 @@ public class E2EServiceInstances { // TODO Get the service template model version uuid from AAI. String modelVersionId = null; AAIResourcesClient client = new AAIResourcesClient(); - AAIResourceUri url = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - e2eActReq.getGlobalSubscriberId(), e2eActReq.getServiceType(), instanceIdMap.get(SERVICE_ID)); + AAIResourceUri url = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(e2eActReq.getGlobalSubscriberId()).serviceSubscription(e2eActReq.getServiceType()) + .serviceInstance(instanceIdMap.get(SERVICE_ID))); Optional<ServiceInstance> serviceInstanceOpt = client.get(ServiceInstance.class, url); if (serviceInstanceOpt.isPresent()) { modelVersionId = serviceInstanceOpt.get().getModelVersionId(); @@ -469,8 +475,9 @@ public class E2EServiceInstances { // TODO Get the service template model version uuid from AAI. String modelVersionId = null; AAIResourcesClient client = new AAIResourcesClient(); - AAIResourceUri url = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - e2eDelReq.getGlobalSubscriberId(), e2eDelReq.getServiceType(), instanceIdMap.get(SERVICE_ID)); + AAIResourceUri url = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(e2eDelReq.getGlobalSubscriberId()).serviceSubscription(e2eDelReq.getServiceType()) + .serviceInstance(instanceIdMap.get(SERVICE_ID))); Optional<ServiceInstance> serviceInstanceOpt = client.get(ServiceInstance.class, url); if (serviceInstanceOpt.isPresent()) { modelVersionId = serviceInstanceOpt.get().getModelVersionId(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java index 70de94a3ef..d8ad82c17d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java @@ -1,7 +1,6 @@ package org.onap.so.apihandlerinfra.infra.rest; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -15,14 +14,13 @@ import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; -import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound; import org.onap.aaiclient.client.aai.AAIDSLQueryClient; -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.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; 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.aaiclient.client.graphinventory.entities.DSLQuery; import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder; import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode; @@ -30,6 +28,8 @@ import org.onap.aaiclient.client.graphinventory.entities.Node; import org.onap.aaiclient.client.graphinventory.entities.Start; import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder; import org.onap.aaiclient.client.graphinventory.entities.__; +import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound; +import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -48,7 +48,7 @@ public class AAIDataRetrieval { public ServiceInstance getServiceInstance(String serviceInstanceId) { return this.getAaiResourcesClient() .get(ServiceInstance.class, - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)) + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId))) .orElseGet(() -> { logger.debug("No Service Instance found in A&AI ServiceInstanceId: {}", serviceInstanceId); return null; @@ -57,7 +57,9 @@ public class AAIDataRetrieval { public VfModule getAAIVfModule(String vnfId, String vfModuleId) { return this.getAaiResourcesClient() - .get(VfModule.class, AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)) + .get(VfModule.class, + AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId))) .orElseGet(() -> { logger.debug("No Vf Module found in A&AI VnfId: {}" + ", VfModuleId: {}", vnfId, vfModuleId); return null; @@ -66,7 +68,8 @@ public class AAIDataRetrieval { public GenericVnf getGenericVnf(String vnfId) { return this.getAaiResourcesClient() - .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + .get(GenericVnf.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))) .orElseGet(() -> { logger.debug("No Generic VNF found in A&AI VnfId: {}", vnfId); return null; @@ -74,9 +77,9 @@ public class AAIDataRetrieval { } public VolumeGroup getVolumeGroup(String vnfId, String volumeGroupId) throws AAIEntityNotFound { - AAIResultWrapper wrapper = - this.getAaiResourcesClient().get(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - .relatedTo(AAIObjectType.VOLUME_GROUP, volumeGroupId)); + AAIResultWrapper wrapper = this.getAaiResourcesClient() + .get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) + .relatedTo(Types.VOLUME_GROUP.getFragment(volumeGroupId))); Optional<VolumeGroup> volume = wrapper.asBean(VolumeGroup.class); if (volume.isPresent()) { return volume.get(); @@ -88,7 +91,8 @@ public class AAIDataRetrieval { public L3Network getNetwork(String networkId) { return this.getAaiResourcesClient() - .get(L3Network.class, AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)) + .get(L3Network.class, + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId))) .orElseGet(() -> { logger.debug("No Network found in A&AI NetworkId: {}", networkId); return null; @@ -96,51 +100,57 @@ public class AAIDataRetrieval { } - public boolean isVolumeGroupRelatedToVFModule(String volumeGroupId) { - return this.getAaiResourcesClient().exists(AAIUriFactory - .createResourceUri(AAIObjectType.VOLUME_GROUP, volumeGroupId).relatedTo(AAIObjectPlurals.VF_MODULE)); + public boolean isVolumeGroupRelatedToVFModule(CloudConfiguration cloudConfig, String volumeGroupId) { + return this.getAaiResourcesClient() + .exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId()) + .volumeGroup(volumeGroupId)).relatedTo(Types.VF_MODULES.getFragment())); } public boolean isVnfRelatedToVolumes(String vnfId) { - return this.getAaiResourcesClient().exists(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - .relatedTo(AAIObjectPlurals.VOLUME_GROUP)); + return this.getAaiResourcesClient() + .exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) + .relatedTo(Types.VOLUME_GROUPS.getFragment())); } public boolean isNetworkRelatedToModules(String networkId) { - return this.getAaiResourcesClient().exists(AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) - .relatedTo(AAIObjectPlurals.VF_MODULE)); + return this.getAaiResourcesClient() + .exists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)) + .relatedTo(Types.VF_MODULES.getFragment())); } public boolean isServiceRelatedToNetworks(String serviceInstanceId) { return this.getAaiResourcesClient() - .exists(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - .relatedTo(AAIObjectPlurals.L3_NETWORK)); + .exists(AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + .relatedTo(Types.L3_NETWORKS.getFragment())); } public boolean isServiceRelatedToGenericVnf(String serviceInstanceId) { return this.getAaiResourcesClient() - .exists(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - .relatedTo(AAIObjectPlurals.GENERIC_VNF)); + .exists(AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + .relatedTo(Types.GENERIC_VNFS.getFragment())); } public boolean isServiceRelatedToConfiguration(String serviceInstanceId) { return this.getAaiResourcesClient() - .exists(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - .relatedTo(AAIObjectPlurals.CONFIGURATION)); + .exists(AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) + .relatedTo(Types.CONFIGURATIONS.getFragment())); } public Service getService(String serviceId) { return this.getAaiResourcesClient() - .get(Service.class, AAIUriFactory.createResourceUri(AAIObjectType.SERVICE, serviceId)).orElseGet(() -> { + .get(Service.class, + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().service(serviceId))) + .orElseGet(() -> { logger.debug("No Service found in A&AI ServiceId: {}", serviceId); return null; }); } public Tenant getTenant(String cloudOwner, String cloudRegion, String tenantId) { - return this.getAaiResourcesClient() - .get(Tenant.class, - AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId)) + return this.getAaiResourcesClient().get(Tenant.class, AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId))) .orElseGet(() -> { logger.debug("No Tenant found in A&AI TenantId: {}", tenantId); return null; @@ -148,9 +158,9 @@ public class AAIDataRetrieval { } public List<LInterface> getLinterfacesOfVnf(String vnfId) { - DSLStartNode startNode = new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("vnf-id", vnfId)); - DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(startNode) - .to(__.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.L_INTERFACE).output())); + DSLStartNode startNode = new DSLStartNode(Types.GENERIC_VNF, __.key("vnf-id", vnfId)); + DSLQueryBuilder<Start, Node> builder = + TraversalBuilder.fragment(startNode).to(__.node(Types.VSERVER).to(__.node(Types.L_INTERFACE).output())); List<LInterface> linterfaces = getAAIDSLQueryClient().querySingleResource(new DSLQuery(builder.build()), LInterface.class); return linterfaces; @@ -176,7 +186,8 @@ public class AAIDataRetrieval { public List<VfModule> getVfModulesOfVnf(String vnfId) { List<VfModule> vfModuleList = new ArrayList<VfModule>(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, vnfId); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModules()); Optional<VfModules> vfModules = getAaiResourcesClient().get(VfModules.class, uri); if (!vfModules.isPresent() || vfModules.get().getVfModule().isEmpty()) { logger.debug("No VfModules attached to Vnf in AAI : {}", vnfId); @@ -198,8 +209,8 @@ public class AAIDataRetrieval { public List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId) { List<VolumeGroup> volumeGroupList = new ArrayList<VolumeGroup>(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - .relatedTo(AAIObjectPlurals.VOLUME_GROUP); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)) + .relatedTo(Types.VOLUME_GROUPS.getFragment()); Optional<VolumeGroups> volumeGroups = getAaiResourcesClient().get(VolumeGroups.class, uri); if (!volumeGroups.isPresent() || volumeGroups.get().getVolumeGroup().isEmpty()) { logger.debug("No VolumeGroups attached to Vnf in AAI : {}", vnfId); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java index 6e7947bb58..edf17f363b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java @@ -29,9 +29,9 @@ import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VfModule; 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.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound; import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException; @@ -278,13 +278,13 @@ public class BpmnRequestBuilder { String cloudOwner = null; String lcpRegionId = null; if (relationshipsOpt.isPresent()) { - tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() + tenantId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst() .map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)) .orElse(null); - cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + cloudOwner = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map( item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)) .orElse(null); - lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + lcpRegionId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map( item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)) .orElse(null); } @@ -323,13 +323,13 @@ public class BpmnRequestBuilder { String cloudOwner = null; String lcpRegionId = null; if (relationshipsOpt.isPresent()) { - tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst() + tenantId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst() .map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId)) .orElse(null); - cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + cloudOwner = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map( item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner)) .orElse(null); - lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map( + lcpRegionId = relationshipsOpt.get().getRelatedUris(Types.TENANT).stream().findFirst().map( item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId)) .orElse(null); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java index 550db19af4..3640baa942 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java @@ -25,7 +25,8 @@ public class VolumeGroupDeleteValidator implements RequestValidator { @Override public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request, Map<String, String> queryParams, Actions action) { - if (aaiDataRetrieval.isVolumeGroupRelatedToVFModule(instanceIdMap.get("volumeGroupInstanceId"))) { + if (aaiDataRetrieval.isVolumeGroupRelatedToVFModule(request.getRequestDetails().getCloudConfiguration(), + instanceIdMap.get("volumeGroupInstanceId"))) { return Optional.of("Cannot delete volume group it is related to existing vf-modules"); } else { return Optional.empty(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java index a28298f859..33fe9d8ae9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java @@ -27,13 +27,13 @@ import java.io.StringWriter; import java.util.Map; import javax.ws.rs.NotFoundException; import org.onap.aai.domain.yang.OperationalEnvironment; -import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; 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.graphinventory.entities.uri.Depth; +import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed; import org.springframework.stereotype.Component; @@ -50,7 +50,8 @@ public class AAIClientHelper { */ public AAIResultWrapper getAaiOperationalEnvironment(String id) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(id)); uri.depth(Depth.ZERO); AAIResourcesClient client = this.getClient(); return client.get(uri, NotFoundException.class); @@ -65,7 +66,8 @@ public class AAIClientHelper { */ public void updateAaiOperationalEnvironment(String id, OperationalEnvironment aaiRequest) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(id)); AAIResourcesClient client = this.getClient(); client.update(uri, aaiRequest); @@ -75,8 +77,8 @@ public class AAIClientHelper { public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload) throws AAIClientCallFailed { try { - AAIResourceUri uri = - AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironmentId); + AAIResourceUri uri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(operationalEnvironmentId)); AAIResourcesClient aaiClient = this.getClient(); aaiClient.update(uri, payload); } catch (Exception ex) { @@ -92,8 +94,8 @@ public class AAIClientHelper { */ public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, - operationalEnvironment.getOperationalEnvironmentId()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .operationalEnvironment(operationalEnvironment.getOperationalEnvironmentId())); AAIResourcesClient client = this.getClient(); client.create(uri, operationalEnvironment); } @@ -107,10 +109,10 @@ public class AAIClientHelper { */ public void createRelationship(String managingEcompOperationalEnvironmentId, String vnfOperationalEnvironmentId) { - AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, - managingEcompOperationalEnvironmentId); - AAIResourceUri vnfEnvUri = - AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, vnfOperationalEnvironmentId); + AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .operationalEnvironment(managingEcompOperationalEnvironmentId)); + AAIResourceUri vnfEnvUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().operationalEnvironment(vnfOperationalEnvironmentId)); AAIResourcesClient client = this.getClient(); client.connect(vnfEnvUri, ecompEnvUri); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index d4c66f62e4..42d5af7feb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -26,11 +26,11 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.aai.domain.yang.OperationalEnvironment; -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.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.logging.filter.base.ErrorCode; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.ApiException; @@ -94,8 +94,7 @@ public class ActivateVnfOperationalEnvironment { Optional<Relationships> optRelationships = wrapper.getRelationships(); if (optRelationships.isPresent()) { Relationships relationships = optRelationships.get(); - List<AAIResourceUri> operationalEnvironments = - relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT); + List<AAIResourceUri> operationalEnvironments = relationships.getRelatedUris(Types.OPERATIONAL_ENVIRONMENT); if (!operationalEnvironments.isEmpty()) { ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get( AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java index 9d5d80592d..61ac542810 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrievalTest.java @@ -24,22 +24,20 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doReturn; import java.util.List; import java.util.Optional; -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.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; -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.uri.AAIPluralResourceUri; 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; @RunWith(MockitoJUnitRunner.class) public class AAIDataRetrievalTest { @@ -52,7 +50,8 @@ public class AAIDataRetrievalTest { @Test public void getVfModulesOfVnfTest() { VfModules vfModules = getVfModules(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "vnfId"); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModules()); doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri); List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId"); assertEquals("vfm1", vfModulesList.get(0).getVfModuleId()); @@ -64,7 +63,8 @@ public class AAIDataRetrievalTest { @Test public void getVfModulesOfVnfWhenNoneTest() { VfModules vfModules = new VfModules(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, "vnfId"); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModules()); doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri); List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId"); assertEquals(true, vfModulesList.isEmpty()); @@ -76,8 +76,8 @@ public class AAIDataRetrievalTest { @Test public void getVolumeGroupsOfVnfTest() throws Exception { VolumeGroups volumeGroups = getVolumeGroups(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId") - .relatedTo(AAIObjectPlurals.VOLUME_GROUP); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")) + .relatedTo(Types.VOLUME_GROUPS.getFragment()); doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri); List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId"); assertEquals("vg1", volumeGroupList.get(0).getVolumeGroupId()); @@ -88,8 +88,8 @@ public class AAIDataRetrievalTest { @Test public void getVolumeGroupsOfVnfWhenNoneTest() throws Exception { VolumeGroups volumeGroups = new VolumeGroups(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId") - .relatedTo(AAIObjectPlurals.VOLUME_GROUP); + AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")) + .relatedTo(Types.VOLUME_GROUPS.getFragment()); doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri); List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId"); assertEquals(true, volumeGroupList.isEmpty()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java index 389ff28dbd..912c026203 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilderTest.java @@ -41,10 +41,11 @@ import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VolumeGroup; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; 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.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.constants.Status; import org.onap.so.db.request.client.RequestsDbClient; @@ -104,7 +105,7 @@ public class BpmnRequestBuilderTest { GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class); doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId"))); ServiceInstancesRequest expectedRequest = mapper.readValue(new File(RESOURCE_PATH + "ExpectedVnfRequest.json"), ServiceInstancesRequest.class); @@ -117,11 +118,11 @@ public class BpmnRequestBuilderTest { GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class); doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId"))); VfModule vfModule = provider.getMapper().readValue(new File(RESOURCE_PATH + "VfModule.json"), VfModule.class); - doReturn(Optional.of(vfModule)).when(aaiResourcesClient).get(VfModule.class, - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, "vnfId", "vfModuleId")); + doReturn(Optional.of(vfModule)).when(aaiResourcesClient).get(VfModule.class, AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModule("vfModuleId"))); ServiceInstancesRequest expectedRequest = mapper .readValue(new File(RESOURCE_PATH + "ExpectedVfModuleRequest.json"), ServiceInstancesRequest.class); @@ -135,13 +136,13 @@ public class BpmnRequestBuilderTest { GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class); doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId")); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId"))); VolumeGroup volumeGroup = provider.getMapper().readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class); AAIResultWrapper wrapper = new AAIResultWrapper(volumeGroup); doReturn(wrapper).when(aaiResourcesClient) - .get(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId") - .relatedTo(AAIObjectType.VOLUME_GROUP, "volumeGroupId")); + .get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")) + .relatedTo(Types.VOLUME_GROUP.getFragment("volumeGroupId"))); ServiceInstancesRequest expectedRequest = mapper .readValue(new File(RESOURCE_PATH + "ExpectedVolumeGroupRequest.json"), ServiceInstancesRequest.class); @@ -157,7 +158,7 @@ public class BpmnRequestBuilderTest { GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class); doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))); CloudConfiguration result = reqBuilder.getCloudConfigurationVfModuleReplace(vnfId, vfModuleId); assertEquals("0422ffb57ba042c0800a29dc85ca70f8", result.getTenantId()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java index 7aa12a61a6..1023408088 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/VolumeGroupDeleteValidatorTest.java @@ -1,6 +1,8 @@ package org.onap.so.apihandlerinfra.infra.rest.validator; import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import java.util.HashMap; import java.util.Map; @@ -14,6 +16,8 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval; import org.onap.so.apihandlerinfra.infra.rest.validators.VolumeGroupDeleteValidator; +import org.onap.so.serviceinstancebeans.CloudConfiguration; +import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @@ -53,16 +57,24 @@ public class VolumeGroupDeleteValidatorTest { @Test public void validateSuccessTest() { instanceIdMap.put("volumeGroupInstanceId", "1"); - when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule("1")).thenReturn(false); - Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, null, null, null); + ServiceInstancesRequest request = new ServiceInstancesRequest(); + RequestDetails details = new RequestDetails(); + details.setCloudConfiguration(new CloudConfiguration()); + request.setRequestDetails(details); + when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule(any(CloudConfiguration.class), eq("1"))).thenReturn(false); + Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, request, null, null); assertEquals(false, result.isPresent()); } @Test public void validateFailureVnfTest() { instanceIdMap.put("volumeGroupInstanceId", "1"); - when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule("1")).thenReturn(true); - Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, null, null, null); + ServiceInstancesRequest request = new ServiceInstancesRequest(); + RequestDetails details = new RequestDetails(); + details.setCloudConfiguration(new CloudConfiguration()); + request.setRequestDetails(details); + when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule(any(CloudConfiguration.class), eq("1"))).thenReturn(true); + Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, request, null, null); assertEquals(true, result.isPresent()); } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java index 049746c6ab..c48d10bb69 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiServiceProviderImpl.java @@ -22,9 +22,10 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai; import java.util.Optional; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.ServiceInstance; -import org.onap.aaiclient.client.aai.AAIObjectType; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -47,8 +48,9 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { public void createServiceInstance(final String globalCustomerId, final String serviceType, final ServiceInstance aaiServiceInstance) { logger.info("Creating service instance in AAI: {}", aaiServiceInstance); - final AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - globalCustomerId, serviceType, aaiServiceInstance.getServiceInstanceId()); + final AAIResourceUri serviceInstanceURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustomerId) + .serviceSubscription(serviceType).serviceInstance(aaiServiceInstance.getServiceInstanceId())); aaiClientProvider.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(aaiServiceInstance)); } @@ -57,9 +59,10 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { public void createGenericVnfAndConnectServiceInstance(final String serviceInstanceId, final String vnfId, final GenericVnf genericVnf) { logger.info("Creating GenericVnf in AAI: {}", genericVnf); - final AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + final AAIResourceUri genericVnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); final AAIResourceUri serviceInstanceURI = - AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)); aaiClientProvider.getAaiClient().createIfNotExists(genericVnfURI, Optional.of(genericVnf)) .connect(genericVnfURI, serviceInstanceURI); @@ -69,15 +72,16 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { public void connectGenericVnfToTenant(final String vnfId, final String cloudOwner, final String cloudRegion, final String tenantId) { logger.info("Connecting GenericVnf {} to {}/{}/{} in AAI", vnfId, cloudOwner, cloudRegion, tenantId); - final AAIResourceUri tenantURI = - AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId); - final AAIResourceUri genericVnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + final AAIResourceUri tenantURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion).tenant(tenantId)); + final AAIResourceUri genericVnfURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); aaiClientProvider.getAaiClient().connect(tenantURI, genericVnfURI); } @Override public Optional<GenericVnf> getGenericVnf(final String vnfId) { return aaiClientProvider.getAaiClient().get(GenericVnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))); } } diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java index d2a87db70a..efc8c45ba4 100644 --- a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java @@ -26,10 +26,10 @@ import java.util.Optional; import java.util.UUID; import javax.ws.rs.NotFoundException; import org.onap.aai.domain.yang.GenericVnf; -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.client.dmaap.DmaapConsumer; import org.onap.so.client.dmaap.DmaapPublisher; import org.onap.so.client.sdno.beans.Body; @@ -48,7 +48,7 @@ public class SDNOValidatorImpl implements SDNOValidator { @Override public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); AAIResourcesClient client = new AAIResourcesClient(); GenericVnf vnf = client.get(GenericVnf.class, uri) .orElseThrow(() -> new NotFoundException(vnfId + " not found in A&AI")); diff --git a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/DeleteVServers.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/DeleteVServers.java index 27d4ce78fd..56b27a1aea 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/DeleteVServers.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/DeleteVServers.java @@ -1,9 +1,9 @@ package org.onap.so.simulator.actions.aai; -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.slf4j.Logger; import org.slf4j.LoggerFactory; import com.consol.citrus.actions.AbstractTestAction; @@ -23,8 +23,8 @@ public class DeleteVServers extends AbstractTestAction { String cloudRegion = context.getVariable("cloudRegion"); String cloudOwner = context.getVariable("cloudOwner"); String tenantId = context.getVariable("tenantId"); - AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, - tenantId, vserverId); + AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vserverId)); aaiResourceClient.delete(vserverURI); logger.error("Delete Vservers in AAI: {}", vserverURI); } catch (Exception e) { diff --git a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java index 21f9528f0f..b42441bcae 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessNetwork.java @@ -1,10 +1,10 @@ package org.onap.so.simulator.actions.aai; import org.onap.aai.domain.yang.L3Network; -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.slf4j.Logger; import org.slf4j.LoggerFactory; import com.consol.citrus.actions.AbstractTestAction; @@ -23,7 +23,8 @@ public class ProcessNetwork extends AbstractTestAction { if (context.getVariable("action").equals("assign")) { String networkId = context.getVariable("generatedNetworkId"); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)); L3Network network = new L3Network(); network.setNetworkId(networkId); network.setNetworkName(context.getVariable("networkName")); @@ -33,7 +34,8 @@ public class ProcessNetwork extends AbstractTestAction { aaiResourceClient.create(networkURI, network); } else if (context.getVariable("action").equals("delete")) { String networkId = context.getVariable("networkId"); - AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId); + AAIResourceUri networkURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network(networkId)); aaiResourceClient.delete(networkURI); } } catch (Exception e) { diff --git a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java index d53de914a3..edf212429c 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java @@ -1,18 +1,12 @@ package org.onap.so.simulator.actions.aai; -import java.io.InputStream; -import java.util.List; import org.onap.aai.domain.yang.Vnfc; -import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; -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.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.core.io.ClassPathResource; import com.consol.citrus.actions.AbstractTestAction; import com.consol.citrus.context.TestContext; @@ -38,7 +32,8 @@ public class ProcessVnfc extends AbstractTestAction { && context.getVariable("serviceAction").equals("assign") && context.getVariable("vfModuleName").equals("nc_dummy_id")) { - AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, "ssc_server_1"); + AAIResourceUri vnfcURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc("ssc_server_1")); Vnfc vnfc = new Vnfc(); vnfc.setVnfcName("ssc_server_1"); vnfc.setNfcNamingCode("oamfw"); @@ -60,8 +55,8 @@ public class ProcessVnfc extends AbstractTestAction { } else { aaiResourceClient.get(vnfcURI); } - AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, - context.getVariable("vnfId"), context.getVariable("vfModuleId")); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network() + .genericVnf(context.getVariable("vnfId")).vfModule(context.getVariable("vfModuleId"))); logger.debug("creating VNFC edge to vf module"); aaiResourceClient.connect(vfModuleURI, vnfcURI); } diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/CreateAAInventory.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/CreateAAInventory.java index 371c72dca9..aa54a7a996 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/CreateAAInventory.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/CreateAAInventory.java @@ -3,10 +3,10 @@ package org.onap.so.simulator.scenarios.openstack; import java.io.InputStream; import org.onap.aai.domain.yang.Vserver; import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; -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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.ClassPathResource; @@ -29,8 +29,9 @@ public class CreateAAInventory extends AbstractTestAction { InputStream vserverFile = new ClassPathResource("openstack/gr_api/CreateAAIInventory.json").getInputStream(); Vserver vserver = aaiMapper.getMapper().readValue(vserverFile, Vserver.class); - AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, "cloudOwner", - "regionOne", "0422ffb57ba042c0800a29dc85ca70f8", vServerId); + AAIResourceUri vserverURI = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("cloudOwner", "regionOne") + .tenant("0422ffb57ba042c0800a29dc85ca70f8").vserver(vServerId)); aaiResourceClient.create(vserverURI, vserver); } } catch (Exception e) { |