use of org.onap.aai.domain.yang.CloudRegion in project so by onap.
the class BBInputSetupUtilsTest method getCloudRegionTest.
@Test
public void getCloudRegionTest() {
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
Optional<CloudRegion> expected = Optional.of(new CloudRegion());
doReturn(expected).when(MOCK_aaiResourcesClient).get(CloudRegion.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId())).depth(Depth.ONE).nodesOnly(true));
assertThat(bbInputSetupUtils.getCloudRegion(cloudConfig), sameBeanAs(expected.get()));
}
use of org.onap.aai.domain.yang.CloudRegion in project so by onap.
the class BBInputSetupExistingServiceTest method test_getGBBMacro_getGBBMacroExistingService_shouldBeCalled.
@Test
public void test_getGBBMacro_getGBBMacroExistingService_shouldBeCalled() throws Exception {
// given
String resourceId = "123";
String vnfType = "vnfType";
String requestAction = this.requestAction;
Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
ServiceInstance serviceInstance = gBB.getServiceInstance();
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
aaiServiceInstance.setModelVersionId("modelVersionId");
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
CloudRegion aaiCloudRegion = Mockito.mock(CloudRegion.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
requestDetails.getRequestParameters().setUserParams(null);
requestDetails.setCloudConfiguration(cloudConfig);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
executeBB.setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName(this.bpmnFlowName).setKey(this.key);
doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
doReturn(aaiCloudRegion).when(bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
// when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
// then
verify(SPY_bbInputSetup, times(1)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(), any(String.class), isA(String.class), isA(CloudConfiguration.class));
}
use of org.onap.aai.domain.yang.CloudRegion in project so by onap.
the class CloudRestImpl method mapCloudRegion.
protected CloudRegion mapCloudRegion(CloudSite cloudSite) {
CloudRegion region = new CloudRegion();
region.setCloudOwner(cloudSite.getCloudOwner());
region.setCloudRegionId(cloudSite.getRegionId());
region.setCloudRegionVersion(cloudSite.getCloudVersion());
region.setOwnerDefinedType("cLCP");
region.setCloudType("openstack");
MavenLikeVersioning cloudVersion = new MavenLikeVersioning();
cloudVersion.setVersion(cloudSite.getCloudVersion());
if (cloudVersion.isMoreRecentThan("3.0")) {
region.setCloudZone(cloudSite.getRegionId().substring(0, cloudSite.getRegionId().length() - 1));
} else {
region.setCloudZone(cloudSite.getRegionId());
}
region.setOrchestrationDisabled(false);
region.setInMaint(false);
return region;
}
use of org.onap.aai.domain.yang.CloudRegion in project so by onap.
the class CloudRestImpl method createCloudRegionInAAI.
protected void createCloudRegionInAAI(CloudSite cloudSite) {
try {
CloudRegion cloudRegion = mapCloudRegion(cloudSite);
Optional<Complex> complex = retrieveComplex(cloudSite);
if (complex.isPresent()) {
cloudRegion.setComplexName(complex.get().getComplexName());
}
AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getCloudRegionId()));
getAaiClient().createIfNotExists(cloudRegionURI, Optional.of(cloudRegion));
if (complex.isPresent()) {
AAIResourceUri complexURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().complex(cloudSite.getClli()));
getAaiClient().connect(cloudRegionURI, complexURI);
}
createCloudRegionNetworkTechnologyRelationship(cloudSite, cloudRegionURI);
} catch (Exception e) {
logger.error("Error creating cloud region in AAI", e);
throw new CloudException("Error creating cloud region in AAI: " + e.getMessage(), e);
}
}
use of org.onap.aai.domain.yang.CloudRegion in project so by onap.
the class CloudRegionRestImplTest method mapCloudRegionVersionGreaterThan3Test.
@Test
public void mapCloudRegionVersionGreaterThan3Test() {
CloudSite cloudSite2 = new CloudSite();
cloudSite2.setCloudVersion("3.0.1");
cloudSite2.setRegionId("region1");
cloudSite2.setCloudOwner("bob");
CloudRegion mappedRegion = cloudRestImpl.mapCloudRegion(cloudSite2);
CloudRegion testRegion2 = new CloudRegion();
testRegion2.setCloudOwner("bob");
testRegion2.setCloudRegionId("region1");
testRegion2.setCloudRegionVersion("3.0.1");
testRegion2.setInMaint(false);
testRegion2.setOrchestrationDisabled(false);
testRegion2.setOwnerDefinedType("cLCP");
testRegion2.setCloudType("openstack");
testRegion2.setCloudZone("region");
assertThat(mappedRegion, sameBeanAs(testRegion2));
}
Aggregations