use of org.onap.so.asdc.installer.ToscaResourceStructure in project so by onap.
the class ToscaResourceInstaller method processServiceProxyAndConfiguration.
protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
List<IEntityDetails> spEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
List<IEntityDetails> configEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CONFIGURATION), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<>();
List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<>();
ServiceProxyResourceCustomization serviceProxy = null;
if (spEntityList != null) {
for (IEntityDetails spEntity : spEntityList) {
serviceProxy = createServiceProxy(spEntity, service, toscaResourceStruct);
serviceProxyList.add(serviceProxy);
for (IEntityDetails configEntity : configEntityList) {
List<RequirementAssignment> requirements = configEntity.getRequirements();
for (RequirementAssignment requirement : requirements) {
if (requirement.getNodeTemplateName().equals(spEntity.getName())) {
ConfigurationResourceCustomization configurationResource = createConfiguration(configEntity, toscaResourceStruct, serviceProxy, service, configurationResourceList);
Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream().filter(configurationResourceCustomization -> configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID())).filter(configurationResourceCustomization -> configurationResourceCustomization.getModelInstanceName().equals(configurationResource.getModelInstanceName())).findFirst();
if (!matchingObject.isPresent()) {
configurationResourceList.add(configurationResource);
}
break;
}
}
}
}
}
service.setConfigurationCustomizations(configurationResourceList);
service.setServiceProxyCustomizations(serviceProxyList);
}
use of org.onap.so.asdc.installer.ToscaResourceStructure in project so by onap.
the class ToscaResourceInputTest method processResourceSequenceTest.
@Test
public void processResourceSequenceTest() {
ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
ArrayList<Input> inputs = new ArrayList<>();
Service service = new Service();
HashMap<String, Object> hashMap = new HashMap();
hashMap.put("name", "node1");
Metadata metadata = new Metadata(hashMap);
when(entityDetails.getMetadata()).thenReturn(metadata);
when(sdcCsarHelper.getServiceInputs()).thenReturn(inputs);
when(toscaResourceInstaller.getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false)).thenReturn(Arrays.asList(entityDetails));
when(entityDetails.getRequirements()).thenReturn(null);
toscaResourceInstaller.processResourceSequence(toscaResourceStructure, service);
assertEquals(service.getResourceOrder(), "");
}
use of org.onap.so.asdc.installer.ToscaResourceStructure in project so by onap.
the class ToscaResourceInputTest method resouceInputGetInputTest.
@Test
public void resouceInputGetInputTest() throws ArtifactInstallerException {
ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
HashMap hashMap = new HashMap();
hashMap.put("customizationUUID", "id1");
Metadata metadata = new Metadata(hashMap);
Map<String, Property> propertyMap = new HashMap<String, Property>();
propertyMap.put("prop1", property);
when(toscaResourceInstaller.getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false)).thenReturn(Arrays.asList(entityDetails));
when(sdcCsarHelper.getServiceInputs()).thenReturn(Arrays.asList(input));
when(entityDetails.getMetadata()).thenReturn(metadata);
when(entityDetails.getProperties()).thenReturn(propertyMap);
when(property.getValue()).thenReturn(getInput);
when(getInput.getInputName()).thenReturn("res_key");
when(input.getName()).thenReturn("res_key");
when(input.getDefault()).thenReturn("default_value");
String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
assertEquals("{}", resourceInput);
}
use of org.onap.so.asdc.installer.ToscaResourceStructure in project so by onap.
the class ToscaResourceInputTest method resouceInputTest.
@Test
public void resouceInputTest() throws ArtifactInstallerException {
ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
Map hashMap = new HashMap();
hashMap.put("customizationUUID", "id1");
Metadata metadata = new Metadata(hashMap);
Map<String, Property> propertyMap = new HashMap<String, Property>();
propertyMap.put("prop1", property);
when(toscaResourceInstaller.getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(EntityTemplateType.NODE_TEMPLATE), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false)).thenReturn(Arrays.asList(entityDetails));
when(entityDetails.getMetadata()).thenReturn(metadata);
when(entityDetails.getProperties()).thenReturn(propertyMap);
when(property.getValue()).thenReturn("value1");
String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
assertEquals("{}", resourceInput);
}
use of org.onap.so.asdc.installer.ToscaResourceStructure in project so by onap.
the class ToscaResourceInstallerTest method installTheResourceWithGroupAndVFModulesTest.
@Test
public void installTheResourceWithGroupAndVFModulesTest() throws Exception {
ToscaResourceInstaller toscaInstaller = new ToscaResourceInstaller();
ToscaResourceStructure toscaResourceStructObj = prepareToscaResourceStructure(true, toscaInstaller);
toscaInstaller.installTheResource(toscaResourceStructObj, vfResourceStruct);
assertEquals(true, toscaResourceStructObj.isDeployedSuccessfully());
}
Aggregations