use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.
the class AaiResourceIdValidatorTest method setupRequestDetails.
private RequestDetails setupRequestDetails() {
RequestDetails reqDetails = new RequestDetails();
SubscriberInfo subInfo = new SubscriberInfo();
subInfo.setGlobalSubscriberId("id123");
reqDetails.setSubscriberInfo(subInfo);
RequestParameters reqParams = new RequestParameters();
reqParams.setSubscriptionServiceType("subServiceType123");
reqDetails.setRequestParameters(reqParams);
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationId("1234567");
reqDetails.setModelInfo(modelInfo);
return reqDetails;
}
use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.
the class BBInputSetupTest method testPopulateInstanceGroup.
@Test
public void testPopulateInstanceGroup() throws Exception {
ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
Service service = Mockito.mock(Service.class);
List<InstanceGroup> instanceGroups = Mockito.spy(new ArrayList<>());
ServiceInstance serviceInstance = Mockito.spy(new ServiceInstance());
serviceInstance.setServiceInstanceId("si-001");
serviceInstance.setServiceInstanceName("test service instance");
serviceInstance.setInstanceGroups(instanceGroups);
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setModelInfo(modelInfo).setService(service).setServiceInstance(serviceInstance).setResourceId("instance-group-001").setInstanceName("test instance group").build();
SPY_bbInputSetup.populateInstanceGroup(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogInstanceGroup(isA(InstanceGroup.class), isA(ModelInfo.class), isA(Service.class));
verify(instanceGroups, times(1)).add(isA(InstanceGroup.class));
}
use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.
the class BBInputSetupTest method testPopulateGenericVnf.
@Test
public void testPopulateGenericVnf() throws JsonParseException, JsonMappingException, IOException {
org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = new org.onap.so.serviceinstancebeans.LineOfBusiness();
String instanceName = "vnfName";
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelType(ModelType.vnf);
ServiceInstance serviceInstance = new ServiceInstance();
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("genericVnfId");
vnf.setVnfName("vnfName");
serviceInstance.getVnfs().add(vnf);
String vnfType = "vnfType";
String applicationId = "applicationId";
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetails_CreateVnf.json"), RequestDetails.class);
Service service = mapper.readValue(new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
String bbName = AssignFlows.VNF.toString();
ServiceModel serviceModel = new ServiceModel();
serviceModel.setCurrentService(service);
Platform expectedPlatform = new Platform();
LineOfBusiness expectedLineOfBusiness = new LineOfBusiness();
String resourceId = "123";
doReturn(expectedPlatform).when(bbInputSetupMapperLayer).mapRequestPlatform(platform);
doReturn(expectedLineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(lineOfBusiness);
org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
vnfAAI.setModelCustomizationId("modelCustId");
doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service);
org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup();
doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any());
org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID).setModelInfo(modelInfo).setInstanceName(instanceName).setPlatform(platform).setLineOfBusiness(lineOfBusiness).setService(service).setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).setRelatedInstanceList(requestDetails.getRelatedInstanceList()).setResourceId(resourceId).setVnfType(vnfType).setProductFamilyId(requestDetails.getRequestInfo().getProductFamilyId()).setServiceModel(serviceModel).build();
SPY_bbInputSetup.populateGenericVnf(parameter);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
SPY_bbInputSetup.populateGenericVnf(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
instanceName = "vnfName2";
GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId);
doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
doNothing().when(SPY_bbInputSetup).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId2");
SPY_bbInputSetup.populateGenericVnf(parameter);
verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
assertEquals("modelCustId", modelInfo.getModelCustomizationUuid());
}
use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.
the class BBInputSetupTest method testMapCatalogNetwork.
@Test
public void testMapCatalogNetwork() {
ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
L3Network network = new L3Network();
RequestDetails requestDetails = new RequestDetails();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
requestDetails.setModelInfo(modelInfo);
Service service = new Service();
NetworkResourceCustomization resourceCust = new NetworkResourceCustomization();
resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
service.setNetworkCustomizations(Arrays.asList(new NetworkResourceCustomization[] { resourceCust }));
doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(resourceCust);
SPY_bbInputSetup.mapCatalogNetwork(network, modelInfo, service);
assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
}
use of org.onap.so.serviceinstancebeans.ModelInfo in project so by onap.
the class BBInputSetupTest method testMapCatalogConfiguration.
@Test
public void testMapCatalogConfiguration() {
ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
L3Network network = new L3Network();
RequestDetails requestDetails = new RequestDetails();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
requestDetails.setModelInfo(modelInfo);
Service service = new Service();
NetworkResourceCustomization resourceCust = new NetworkResourceCustomization();
resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
service.setNetworkCustomizations(Arrays.asList(new NetworkResourceCustomization[] { resourceCust }));
doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(resourceCust);
SPY_bbInputSetup.mapCatalogNetwork(network, modelInfo, service);
assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
}
Aggregations