import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.UUID;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Assert;
import org.junit.Rule;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.serviceinstancebeans.VfModules;
+import org.onap.so.serviceinstancebeans.Vnfs;
@RunWith(MockitoJUnitRunner.class)
public class BBInputSetupTest {
assertEquals(modelInfoGenericVnf, genericVnf.getModelInfoGenericVnf());
}
+ @Test
+ public void testMapCatalogPnf() {
+ ModelInfoPnf modelInfoPnf = new ModelInfoPnf();
+ Pnf pnf = new Pnf();
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
+ requestDetails.setModelInfo(modelInfo);
+ Service service = new Service();
+
+ PnfResourceCustomization resourceCust = new PnfResourceCustomization();
+ resourceCust.setModelCustomizationUUID("pnfModelCustomizationUUID");
+ service.getPnfCustomizations().add(resourceCust);
+ resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
+
+ doReturn(modelInfoPnf).when(bbInputSetupMapperLayer).mapCatalogPnfToPnf(resourceCust);
+
+ SPY_bbInputSetup.mapCatalogPnf(pnf, modelInfo, service);
+
+ assertEquals(modelInfoPnf, pnf.getModelInfoPnf());
+ }
+
@Test
public void testMapCatalogCollectionAndInstanceGroup() {
ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
String volumeGroupId = "volumeGroupId";
String configurationId = "configurationId";
String instanceGroupId = "instancegroupId";
+ String vnfInstanceName = "vnfInstanceName";
+ String vfModuleInstanceName = "vfModuleInstanceName";
+ String childServiceInstanceId = "childServiceInstanceId";
+ String childServiceInstanceName = "childServiceInstanceName";
+ String pnfInstanceName = "pnfInstanceName";
expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
expected.put(ResourceKey.NETWORK_ID, networkId);
expected.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupId);
expected.put(ResourceKey.CONFIGURATION_ID, configurationId);
expected.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
+ expected.put(ResourceKey.VNF_INSTANCE_NAME, vnfInstanceName);
+ expected.put(ResourceKey.VF_MODULE_INSTANCE_NAME, vfModuleInstanceName);
+ expected.put(ResourceKey.CHILD_SERVICE_INSTANCE_ID, childServiceInstanceId);
+ expected.put(ResourceKey.CHILD_SERVICE_INSTANCE_NAME, childServiceInstanceName);
+ expected.put(ResourceKey.PNF_INSTANCE_NAME, pnfInstanceName);
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId(serviceInstanceId);
workflowResourceIds.setVolumeGroupId(volumeGroupId);
workflowResourceIds.setConfigurationId(configurationId);
workflowResourceIds.setInstanceGroupId(instanceGroupId);
+ workflowResourceIds.setVnfInstanceName(vnfInstanceName);
+ workflowResourceIds.setVfModuleInstanceName(vfModuleInstanceName);
+ workflowResourceIds.setChildServiceInstanceId(childServiceInstanceId);
+ workflowResourceIds.setChildServiceInstanceName(childServiceInstanceName);
+ workflowResourceIds.setPnfInstanceName(pnfInstanceName);
SPY_bbInputSetup.populateLookupKeyMapWithIds(workflowResourceIds, actual);
assertThat(actual, sameBeanAs(expected));
}
+ @Test
+ public void testGetVfModulesByInstanceName() throws IOException {
+ org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class);
+ Resources resources = serviceMacro.getResources();
+ VfModules expectedVfModule = resources.getVnfs().get(0).getVfModules().get(2);
+ assertEquals(expectedVfModule,
+ SPY_bbInputSetup.getVfModulesByInstanceName("vmxnjr001_AVPN_base_vRE_BV_expansion_002", resources));
+ }
+
+ @Test
+ public void testGetVfModulesByKey() throws IOException {
+ org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class);
+ Resources resources = serviceMacro.getResources();
+ VfModules expectedVfModule = resources.getVnfs().get(0).getVfModules().get(0);
+ assertEquals(expectedVfModule,
+ SPY_bbInputSetup.getVfModulesByKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", resources));
+ }
+
+ @Test
+ public void testFindVnfsByInstanceName() throws IOException {
+ org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class);
+ Resources resources = serviceMacro.getResources();
+ Vnfs expectedVnf = resources.getVnfs().get(0);
+ assertEquals(expectedVnf, SPY_bbInputSetup.findVnfsByInstanceName("vmxnjr001", resources));
+ }
+
+ @Test
+ public void testVnfsByKey() throws IOException {
+ org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class);
+ Resources resources = serviceMacro.getResources();
+ Vnfs expectedVnf = resources.getVnfs().get(0);
+ assertEquals(expectedVnf, SPY_bbInputSetup.findVnfsByKey("ab153b6e-c364-44c0-bef6-1f2982117f04", resources));
+ }
+
@Test
public void testGBBMacroNoUserParamsVrfConfiguration() throws Exception {
String resourceId = "123";
assertThat(actual, sameBeanAs(expected));
}
- @Test
- public void testgetGBBMacroCloudConfiguration() throws Exception {
- org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class);
- CloudConfiguration cloudConfig = null;
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = new org.onap.aai.domain.yang.CloudRegion();
- aaiCloudRegion.setCloudOwner("test-owner-name");
- Resources resources = serviceMacro.getResources();
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class));
- CloudRegion expected = new CloudRegion();
- expected.setLcpCloudRegionId("mdt1");
- expected.setCloudOwner("test-owner-name");
- expected.setTenantId("88a6ca3ee0394ade9403f075db23167e");
-
- CloudRegion actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroVnfs.json"),
- org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroNetworks.json"),
- org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroNoCloudConfig.json"),
- org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertNull(actual);
- }
-
@Test
public void testgetGBBMacroWithEmptyUserParams() throws Exception {
String resourceId = "123";
any(Service.class), isA(ConfigurationResourceKeys.class));
}
+ @Test
+ public void testGetGBBMacroExistingServiceUpgrade() throws Exception {
+ String requestAction = "upgradeInstance";
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceUpgrade.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
+ executeBB.setRequestDetails(requestDetails);
+
+ doReturn(new Service()).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
+ doReturn(new org.onap.aai.domain.yang.ServiceInstance()).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
+
+ SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
+
+ verify(SPY_bbInputSetupUtils, times(1))
+ .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
+ }
+
@Test
public void testGetGBBMacroExistingServiceServiceinstancenotFoundInAai() throws Exception {
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),