use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class NetworkAdapterResourcesTest method updateNetworkTest.
@Test
public void updateNetworkTest() throws UnsupportedEncodingException, NetworkAdapterClientException {
doReturn(new UpdateNetworkRequest()).when(MOCK_networkAdapterObjectMapper).createNetworkUpdateRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(Customer.class));
doReturn(new UpdateNetworkResponse()).when(MOCK_networkAdapterClient).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
Optional<UpdateNetworkResponse> actualUpdateNetworkResponse = networkAdapterResources.updateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
verify(MOCK_networkAdapterClient, times(1)).updateNetwork(isA(String.class), isA(UpdateNetworkRequest.class));
assertNotNull(actualUpdateNetworkResponse);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class NetworkAdapterResourcesTest method rollbackCreateNetworkTest.
@Test
public void rollbackCreateNetworkTest() throws Exception {
String cloudRegionPo = "cloudRegionPo";
RollbackNetworkResponse expectedRollbackNetworkResponse = new RollbackNetworkResponse();
expectedRollbackNetworkResponse.setMessageId("messageId");
expectedRollbackNetworkResponse.setNetworkRolledBack(true);
RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
rollbackNetworkRequest.setMessageId("messageId");
RollbackNetworkResponse rollbackNetworkResponse = new RollbackNetworkResponse();
rollbackNetworkResponse.setMessageId("messageId");
rollbackNetworkResponse.setNetworkRolledBack(true);
CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
createNetworkResponse.setMessageId("messageId");
doReturn(rollbackNetworkResponse).when(MOCK_networkAdapterClient).rollbackNetwork(isA(String.class), isA(RollbackNetworkRequest.class));
doReturn(rollbackNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRollbackRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(CreateNetworkResponse.class));
RollbackNetworkResponse actualRollbackCreateNetwrokResponse = (networkAdapterResources.rollbackCreateNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse)).get();
verify(MOCK_networkAdapterClient, times(1)).rollbackNetwork(l3Network.getNetworkId(), rollbackNetworkRequest);
verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
assertThat(expectedRollbackNetworkResponse, Matchers.sameBeanAs(actualRollbackCreateNetwrokResponse));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class AAINetworkResourcesTest method queryNetworkWrapperByIdTest.
@Test
public void queryNetworkWrapperByIdTest() throws Exception {
final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiQueryAAIResponse-Wrapper.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
L3Network network = new L3Network();
network.setNetworkId("0384d743-f69b-4cc8-9aa8-c3ae66662c44");
network.setNetworkName("Dev_Bindings_1802_020118");
network.setOrchestrationStatus(OrchestrationStatus.CREATED);
doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
AAIResultWrapper result = aaiNetworkResources.queryNetworkWrapperById(network);
verify(MOCK_aaiResourcesClient, times(1)).get(isA(AAIResourceUri.class));
assertEquals(aaiResultWrapper.getJson(), result.getJson());
assertNotNull(result);
Optional<Relationships> resultNetworkRelationships = result.getRelationships();
assertTrue(resultNetworkRelationships.isPresent());
Optional<org.onap.aai.domain.yang.L3Network> aaiL3Network = result.asBean(org.onap.aai.domain.yang.L3Network.class);
assertEquals(network.getNetworkId(), aaiL3Network.get().getNetworkId());
assertEquals(network.getNetworkName(), aaiL3Network.get().getNetworkName());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forUnassignVfModuleBB.
@Test
public void test_getGBBMacroNoUserParamsExistingService_forUnassignVfModuleBB() throws Exception {
// given
String requestAction = "unassignInstance";
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
L3Network network = new L3Network();
network.setNetworkId("networkId");
gBB.getServiceInstance().getNetworks().add(network);
ServiceInstance serviceInstance = gBB.getServiceInstance();
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
requestDetails.getRequestParameters().setUserParams(null);
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
Service service = Mockito.mock(Service.class);
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
aaiNetwork.setModelCustomizationId("modelCustId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
gBB.getServiceInstance().getVnfs().add(vnf);
org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
aaiVfModule.setModelCustomizationId("modelCustId");
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName("UnassignVfModuleBB").setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
aaiServiceInstance.setModelVersionId("modelVersionId");
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
doReturn(aaiServiceInstance).when(SPY_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(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
doReturn(aaiVfModule).when(SPY_bbInputSetupUtils).getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId());
// when
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
// then
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(any(VfModule.class), any(ModelInfo.class), any(Service.class), any(String.class));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class BBInputSetupTest method testPopulateL3Network.
@Test
public void testPopulateL3Network() throws JsonParseException, JsonMappingException, IOException {
String instanceName = "networkName";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelType(ModelType.network);
ServiceInstance serviceInstance = new ServiceInstance();
L3Network network = new L3Network();
network.setNetworkId("networkId");
network.setNetworkName("networkName");
serviceInstance.getNetworks().add(network);
String resourceId = "123";
// Mock service
Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
String bbName = AssignFlows.NETWORK_A_LA_CARTE.toString();
doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(network, modelInfo, service);
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setInstanceName(instanceName).setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).build();
SPY_bbInputSetup.populateL3Network(parameter);
lookupKeyMap.put(ResourceKey.NETWORK_ID, null);
SPY_bbInputSetup.populateL3Network(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network, modelInfo, service);
instanceName = "networkName2";
L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null, parameter);
SPY_bbInputSetup.populateL3Network(parameter);
verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service);
}
Aggregations