diff options
author | 2018-02-05 19:48:23 +0530 | |
---|---|---|
committer | 2018-02-19 16:08:37 +0000 | |
commit | d299e8af2e9dfa79e53f7cf9e79977bab3474919 (patch) | |
tree | 6faf3d4cda78eb48767bfa727df0e6189a81ca30 /openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp | |
parent | bd76c092d9929aa69682767855ba47b1ccc627d8 (diff) |
VLAN tagging - Added Consolidation Rules
1. Added rules for subinterface consolidation
2. Added new data types for supporting
subinterface consolidation
3. Added unit tests
4. Updated license text
5. Updated code based on review comments
Change-Id: I7c0d7a4747029c15212c3474280dd8fc6d623ccc
Issue-ID: SDC-998
Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp')
4 files changed, 969 insertions, 375 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/SubInterfaceConsolidationDataTestInfo.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/SubInterfaceConsolidationDataTestInfo.java new file mode 100644 index 0000000000..2092eb7cc7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/SubInterfaceConsolidationDataTestInfo.java @@ -0,0 +1,86 @@ +package org.openecomp.sdc.translator; + +import org.apache.commons.lang3.tuple.Pair; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.GetAttrFuncData; + +import java.util.List; + +public class SubInterfaceConsolidationDataTestInfo { + private final String serviceTemplateFileName; + private final String portNodeTemplateId; + private final String subInterfaceType; + private final int resourceGroupCount; + private final String networkRole; + private final String subInterfaceId; + private final List<String> nodesConnectedIn; + private final List<String> nodesConnectedOut; + private final List<String> nodesGetAttrIn; + private final List<Pair<String, GetAttrFuncData>> nodesGetAttrOut; + private final ConsolidationData consolidationData; + + public SubInterfaceConsolidationDataTestInfo(String serviceTemplateFileName, + String portNodeTemplateId, String subInterfaceType, + int resourceGroupCount, String networkRole, + String subInterfaceId, List<String> nodesConnectedIn, + List<String> nodesConnectedOut, + List<String> nodesGetAttrIn, + List<Pair<String, GetAttrFuncData>> nodesGetAttrOut, + ConsolidationData consolidationData) { + this.serviceTemplateFileName = serviceTemplateFileName; + this.portNodeTemplateId = portNodeTemplateId; + this.subInterfaceType = subInterfaceType; + this.resourceGroupCount = resourceGroupCount; + this.networkRole = networkRole; + this.subInterfaceId = subInterfaceId; + this.nodesConnectedIn = nodesConnectedIn; + this.nodesConnectedOut = nodesConnectedOut; + this.nodesGetAttrIn = nodesGetAttrIn; + this.nodesGetAttrOut = nodesGetAttrOut; + this.consolidationData = consolidationData; + } + + public String getServiceTemplateFileName() { + return serviceTemplateFileName; + } + + public String getPortNodeTemplateId() { + return portNodeTemplateId; + } + + public String getSubInterfaceType() { + return subInterfaceType; + } + + public int getResourceGroupCount() { + return resourceGroupCount; + } + + public String getNetworkRole() { + return networkRole; + } + + public String getSubInterfaceId() { + return subInterfaceId; + } + + public List<String> getNodesConnectedIn() { + return nodesConnectedIn; + } + + public List<String> getNodesConnectedOut() { + return nodesConnectedOut; + } + + public List<String> getNodesGetAttrIn() { + return nodesGetAttrIn; + } + + public List<Pair<String, GetAttrFuncData>> getNodesGetAttrOut() { + return nodesGetAttrOut; + } + + public ConsolidationData getConsolidationData() { + return consolidationData; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java index c7d3931961..1f7167c522 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java @@ -1,21 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2017 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= */ package org.openecomp.sdc.translator; @@ -48,6 +44,7 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.NestedTemplateConsolidationData; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.RequirementAssignmentData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.SubInterfaceTemplateConsolidationData; import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData; import java.io.File; @@ -103,13 +100,14 @@ public class TestUtils { /** * Get tosca service template models for the files in a directory + * * @param baseDirPath base directory for the tosca file * @return Map of <ServiceTemplateFilename, ServiceTemplate> for the files in this directory */ - public static Map<String, ServiceTemplate> getServiceTemplates(String baseDirPath){ + private static Map<String, ServiceTemplate> getServiceTemplates(String baseDirPath) { Map<String, ServiceTemplate> serviceTemplateMap = new HashMap<>(); ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); - baseDirPath = "."+baseDirPath+"/"; + baseDirPath = "." + baseDirPath + "/"; try { String[] fileList = {}; URL filesDirUrl = TestUtils.class.getClassLoader().getResource(baseDirPath); @@ -118,16 +116,16 @@ public class TestUtils { } else { Assert.fail("Invalid expected output files directory"); } - for (int i = 0; i < fileList.length; i++) { + for (String fileName : fileList) { - URL resource = TestUtils.class.getClassLoader().getResource(baseDirPath + fileList[i]); + URL resource = TestUtils.class.getClassLoader().getResource(baseDirPath + fileName); ServiceTemplate serviceTemplate = FileUtils.readViaInputStream(resource, - stream -> toscaExtensionYamlUtil.yamlToObject(stream, ServiceTemplate.class)); + stream -> toscaExtensionYamlUtil.yamlToObject(stream, ServiceTemplate.class)); - serviceTemplateMap.put(fileList[i], serviceTemplate); + serviceTemplateMap.put(fileName, serviceTemplate); } } catch (Exception e) { - logger.debug("",e); + logger.debug("", e); Assert.fail(e.getMessage()); } return serviceTemplateMap; @@ -135,14 +133,15 @@ public class TestUtils { /** * Get tosca service template models + * * @param expectedResultMap Map of filename and payload of the expected result files * @return Map of <ServiceTemplateFilename, ServiceTemplate> for the files in this directory */ public static Map<String, ServiceTemplate> getServiceTemplates(Map<String, byte[]> - expectedResultMap){ + expectedResultMap) { Map<String, ServiceTemplate> serviceTemplateMap = new HashMap<>(); ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); - for(String fileName : expectedResultMap.keySet()){ + for (String fileName : expectedResultMap.keySet()) { ServiceTemplate serviceTemplate = toscaExtensionYamlUtil.yamlToObject (new String(expectedResultMap.get(fileName)), ServiceTemplate.class); serviceTemplateMap.put(fileName, serviceTemplate); @@ -181,11 +180,12 @@ public class TestUtils { try (InputStream yamlFile = new FileInputStream(file)) { serviceTemplateFromYaml = toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class); - createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml, toscaExtensionYamlUtil); + createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml, + toscaExtensionYamlUtil); try { yamlFile.close(); } catch (IOException ignore) { - logger.debug("",ignore); + logger.debug("", ignore); } } catch (FileNotFoundException e) { throw e; @@ -226,12 +226,13 @@ public class TestUtils { try (InputStream yamlFile = new FileInputStream(file)) { ServiceTemplate serviceTemplateFromYaml = toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class); - createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml, toscaExtensionYamlUtil); + createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml, + toscaExtensionYamlUtil); serviceTemplates.put(file.getName(), serviceTemplateFromYaml); try { yamlFile.close(); } catch (IOException ignore) { - logger.debug("",ignore); + logger.debug("", ignore); } } catch (FileNotFoundException e) { throw e; @@ -242,9 +243,9 @@ public class TestUtils { } private static void createConcreteRequirementObjectsInServiceTemplate(ServiceTemplate - serviceTemplateFromYaml, - ToscaExtensionYamlUtil - toscaExtensionYamlUtil) { + serviceTemplateFromYaml, + ToscaExtensionYamlUtil + toscaExtensionYamlUtil) { if (serviceTemplateFromYaml == null || serviceTemplateFromYaml.getTopology_template() == null @@ -262,7 +263,7 @@ public class TestUtils { if (requirements != null) { ListIterator<Map<String, RequirementAssignment>> reqListIterator = requirements .listIterator(); - while (reqListIterator.hasNext()){ + while (reqListIterator.hasNext()) { Map<String, RequirementAssignment> requirement = reqListIterator.next(); Map<String, RequirementAssignment> concreteRequirement = new HashMap<>(); for (Map.Entry<String, RequirementAssignment> reqEntry : requirement.entrySet()) { @@ -290,14 +291,39 @@ public class TestUtils { List<List<String>> groupIds, List<List<String>> getAttrInIds, List<List<Pair<String, GetAttrFuncData>>> getAttrOutFuncDataList, - ConsolidationData consolidationData){ - for(int i = 0; i < portNodeTemplateIds.size(); i++){ + ConsolidationData consolidationData) { + for (int i = 0; i < portNodeTemplateIds.size(); i++) { updatePortConsolidationData(serviceTemplateName, portNodeTemplateIds.get(i), nodesConnectedInIds.get(i), nodesConnectedOutIds.get(i), - groupIds.get(i), getAttrInIds.get(i),getAttrOutFuncDataList.get(i), consolidationData); + groupIds.get(i), getAttrInIds.get(i), getAttrOutFuncDataList.get(i), consolidationData); } } + public static void addPortSubInterface( + SubInterfaceConsolidationDataTestInfo subInterfaceConsolidationDataTestInfo) { + PortTemplateConsolidationData portTemplateConsolidationData = + subInterfaceConsolidationDataTestInfo.getConsolidationData().getPortConsolidationData().getFilePortConsolidationData + (subInterfaceConsolidationDataTestInfo.getServiceTemplateFileName()).getPortTemplateConsolidationData( + subInterfaceConsolidationDataTestInfo.getPortNodeTemplateId()); + + SubInterfaceTemplateConsolidationData subInterface = + new SubInterfaceTemplateConsolidationData(); + subInterface.setNodeTemplateId(subInterfaceConsolidationDataTestInfo.getSubInterfaceId()); + subInterface.setNetworkRole(subInterfaceConsolidationDataTestInfo.getNetworkRole()); + subInterface.setResourceGroupCount( + subInterfaceConsolidationDataTestInfo.getResourceGroupCount()); + + updateRelationsForEntityConsolidationData( + subInterfaceConsolidationDataTestInfo.getNodesConnectedIn(), + subInterfaceConsolidationDataTestInfo.getNodesConnectedOut(), null, + subInterfaceConsolidationDataTestInfo.getNodesGetAttrIn(), + subInterfaceConsolidationDataTestInfo.getNodesGetAttrOut(), subInterface); + + portTemplateConsolidationData.addSubInterfaceConsolidationData( + subInterfaceConsolidationDataTestInfo.getSubInterfaceType(), subInterface); + + } + public static void updatePortConsolidationData(String serviceTemplateFileName, String portNodeTemplateId, List<String> nodesConnectedInIds, @@ -309,8 +335,9 @@ public class TestUtils { PortTemplateConsolidationData portTemplateConsolidationData = createPortTemplateConsolidationData(portNodeTemplateId); - updateRelationsForEntityConsolidationData(portNodeTemplateId, nodesConnectedInIds, - nodesConnectedOutIds, groupIds, getAttrInIds, getAttrOutFuncDataList, portTemplateConsolidationData); + updateRelationsForEntityConsolidationData(nodesConnectedInIds, + nodesConnectedOutIds, groupIds, getAttrInIds, getAttrOutFuncDataList, + portTemplateConsolidationData); consolidationData.getPortConsolidationData() .getFilePortConsolidationData(serviceTemplateFileName) @@ -355,8 +382,9 @@ public class TestUtils { ComputeTemplateConsolidationData computeTemplateConsolidationData = createComputeTemplateConsolidationData(computeNodeTemplateId, portTypeToIdList, volumes); - updateRelationsForEntityConsolidationData(computeNodeTemplateId, nodeIdsConnectedIn, - nodeIdsConnectedOut, groupIds, getAttrInIds, getAttrOutIds, computeTemplateConsolidationData); + updateRelationsForEntityConsolidationData(nodeIdsConnectedIn, + nodeIdsConnectedOut, groupIds, getAttrInIds, getAttrOutIds, + computeTemplateConsolidationData); updateVolumes(computeTemplateConsolidationData, volumeIds); @@ -367,27 +395,27 @@ public class TestUtils { computeTemplateConsolidationData); } - private static void updateRelationsForEntityConsolidationData(String entityNodeTemplateId, - List<String> nodeIdsConnectedIn, + private static void updateRelationsForEntityConsolidationData(List<String> nodeIdsConnectedIn, List<String> nodeIdsConnectedOut, List<String> groupIds, List<String> getAttrInIds, List<Pair<String, GetAttrFuncData>> getAttrOutFuncDataList, EntityConsolidationData entity) { updateRelationsIn(entity, nodeIdsConnectedIn); - updateRelationsOut(entity, entityNodeTemplateId, nodeIdsConnectedOut); + updateRelationsOut(entity, nodeIdsConnectedOut); updateGetAttrIn(entity, getAttrInIds); updateGetAttrOut(entity, getAttrOutFuncDataList); entity.setGroupIds(groupIds); } public static void initComputeNodeTemplateIdInConsolidationData(String serviceTemplateFileName, - String computeNodeTypeName, - String computeNodeTemplateId, - ConsolidationData consolidationData) { + String computeNodeTypeName, + String computeNodeTemplateId, + ConsolidationData consolidationData) { - if(Objects.isNull(consolidationData.getComputeConsolidationData().getFileComputeConsolidationData - (serviceTemplateFileName))) { + if (Objects + .isNull(consolidationData.getComputeConsolidationData().getFileComputeConsolidationData + (serviceTemplateFileName))) { consolidationData.getComputeConsolidationData().setFileComputeConsolidationData (serviceTemplateFileName, new FileComputeConsolidationData()); } @@ -395,36 +423,42 @@ public class TestUtils { consolidationData.getComputeConsolidationData().getFileComputeConsolidationData (serviceTemplateFileName).getTypeComputeConsolidationData(computeNodeTypeName); - if( - typeComputeConsolidationData.getComputeTemplateConsolidationData(computeNodeTemplateId) == null) { + if ( + typeComputeConsolidationData.getComputeTemplateConsolidationData(computeNodeTemplateId) == + null) { consolidationData.getComputeConsolidationData() .getFileComputeConsolidationData(serviceTemplateFileName) .getTypeComputeConsolidationData(computeNodeTypeName) - .setComputeTemplateConsolidationData(computeNodeTemplateId, new ComputeTemplateConsolidationData()); + .setComputeTemplateConsolidationData(computeNodeTemplateId, + new ComputeTemplateConsolidationData()); } } public static void updateNestedConsolidationData(String serviceTemplateName, List<String> substitutionNodeTemplateIds, - ConsolidationData consolidationData){ - if(Objects.isNull(consolidationData.getNestedConsolidationData())){ + ConsolidationData consolidationData) { + if (Objects.isNull(consolidationData.getNestedConsolidationData())) { consolidationData.setNestedConsolidationData(new NestedConsolidationData()); } FileNestedConsolidationData fileNestedConsolidationData = new FileNestedConsolidationData(); - for(String substitutionNodeTemplateId : substitutionNodeTemplateIds) { - NestedTemplateConsolidationData nestedTemplateConsolidationData = new NestedTemplateConsolidationData(); + for (String substitutionNodeTemplateId : substitutionNodeTemplateIds) { + NestedTemplateConsolidationData nestedTemplateConsolidationData = + new NestedTemplateConsolidationData(); nestedTemplateConsolidationData.setNodeTemplateId(substitutionNodeTemplateId); - fileNestedConsolidationData.setNestedTemplateConsolidationData(substitutionNodeTemplateId, nestedTemplateConsolidationData); + fileNestedConsolidationData.setNestedTemplateConsolidationData(substitutionNodeTemplateId, + nestedTemplateConsolidationData); } - consolidationData.getNestedConsolidationData().setFileNestedConsolidationData(serviceTemplateName, fileNestedConsolidationData); + consolidationData.getNestedConsolidationData() + .setFileNestedConsolidationData(serviceTemplateName, fileNestedConsolidationData); } - public static ComputeTemplateConsolidationData createComputeTemplateConsolidationData(String computeNodeTemplateId, - List<Pair<String, String>> portTypeToIdList, - Map<String,List<RequirementAssignmentData>> volumes) { + public static ComputeTemplateConsolidationData createComputeTemplateConsolidationData( + String computeNodeTemplateId, + List<Pair<String, String>> portTypeToIdList, + Map<String, List<RequirementAssignmentData>> volumes) { ComputeTemplateConsolidationData compute = new ComputeTemplateConsolidationData(); compute.setNodeTemplateId(computeNodeTemplateId); if (portTypeToIdList != null) { @@ -436,58 +470,58 @@ public class TestUtils { return compute; } - public static void updateRelationsIn(EntityConsolidationData entity, - List<String> idsPontingTome){ - if(CollectionUtils.isEmpty(idsPontingTome)){ + private static void updateRelationsIn(EntityConsolidationData entity, + List<String> idsPontingTome) { + if (CollectionUtils.isEmpty(idsPontingTome)) { return; } - for(String pointingId : idsPontingTome){ - entity.addNodesConnectedIn(pointingId, entity.getNodeTemplateId(), new RequirementAssignment()); + for (String pointingId : idsPontingTome) { + entity + .addNodesConnectedIn(pointingId, entity.getNodeTemplateId(), new RequirementAssignment()); } } - public static void updateRelationsOut(EntityConsolidationData entity, - String nodeTemplateId, - List<String> idsToUpdate){ - if(CollectionUtils.isEmpty(idsToUpdate)){ + private static void updateRelationsOut(EntityConsolidationData entity, + List<String> idsToUpdate) { + if (CollectionUtils.isEmpty(idsToUpdate)) { return; } - for(String id : idsToUpdate){ + for (String id : idsToUpdate) { entity.addNodesConnectedOut(id, id, new RequirementAssignment()); } } - public static void updateGetAttrIn(EntityConsolidationData entity, - List<String> idsToUpdate){ - if(CollectionUtils.isEmpty(idsToUpdate)){ + private static void updateGetAttrIn(EntityConsolidationData entity, + List<String> idsToUpdate) { + if (CollectionUtils.isEmpty(idsToUpdate)) { return; } - for(String id : idsToUpdate){ + for (String id : idsToUpdate) { entity.addNodesGetAttrIn(id, new GetAttrFuncData()); } } - public static void updateGetAttrOut(EntityConsolidationData entity, - List<Pair<String, GetAttrFuncData>> getAttrOutIds){ - if(CollectionUtils.isEmpty(getAttrOutIds)){ + private static void updateGetAttrOut(EntityConsolidationData entity, + List<Pair<String, GetAttrFuncData>> getAttrOutIds) { + if (CollectionUtils.isEmpty(getAttrOutIds)) { return; } - for(Pair<String, GetAttrFuncData> getAttrOutFunc : getAttrOutIds){ + for (Pair<String, GetAttrFuncData> getAttrOutFunc : getAttrOutIds) { entity.addNodesGetAttrOut(getAttrOutFunc.getLeft(), getAttrOutFunc.getRight()); } } - public static void updateVolumes(ComputeTemplateConsolidationData compute, - List<String> volumeIds){ - if(CollectionUtils.isEmpty(volumeIds)){ + private static void updateVolumes(ComputeTemplateConsolidationData compute, + List<String> volumeIds) { + if (CollectionUtils.isEmpty(volumeIds)) { return; } - for(String id : volumeIds){ + for (String id : volumeIds) { RequirementAssignment requirementAssignment = new RequirementAssignment(); requirementAssignment.setNode(id); compute.addVolume(id, requirementAssignment); @@ -552,9 +586,9 @@ public class TestUtils { public static void updatePortsInComputeTemplateConsolidationData( List<Pair<String, String>> portIdToTypeList, ComputeTemplateConsolidationData - compute){ + compute) { compute.setPorts(new HashMap<>()); - for(Pair<String, String> portIdToType : portIdToTypeList){ + for (Pair<String, String> portIdToType : portIdToTypeList) { compute.getPorts().putIfAbsent(portIdToType.getLeft(), new ArrayList<>()); compute.getPorts().get(portIdToType.getLeft()).add(portIdToType.getRight()); } @@ -607,12 +641,14 @@ public class TestUtils { for (Map.Entry<String, GroupDefinition> entry : groups.entrySet()) { String groupId = entry.getKey(); GroupDefinition groupDefinition = entry.getValue(); - if (groupDefinition.getType().contains("HeatStack")) + if (groupDefinition.getType().contains("HeatStack")) { continue; + } List<String> groupMembers = groupDefinition.getMembers(); for (String member : groupMembers) { - if (groups.containsKey(member)) + if (groups.containsKey(member)) { continue; + } if (member.equals(nodeTemplateId)) { entityGroups.add(groupId); } @@ -656,5 +692,4 @@ public class TestUtils { } - } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationServiceTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationServiceTest.java index 4af2415381..63ce6b5682 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationServiceTest.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationServiceTest.java @@ -1,11 +1,44 @@ package org.openecomp.sdc.translator.services.heattotosca; -/** - * Created by TALIO on 3/7/2017. - */ +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import org.openecomp.sdc.tosca.services.ToscaConstants; +import org.openecomp.sdc.translator.SubInterfaceConsolidationDataTestInfo; +import org.openecomp.sdc.translator.TestUtils; +import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionMode; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData; +import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.GetAttrFuncData; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class ConsolidationServiceTest { - /* + @Spy private TranslationContext translationContext = new TranslationContext(); private static String mainST = "MainServiceTemplate.yaml"; @@ -65,7 +98,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -101,7 +134,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.SingleSubstitution); + Collections.singletonList(UnifiedCompositionMode.SingleSubstitution); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -137,7 +170,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.SingleSubstitution); + Collections.singletonList(UnifiedCompositionMode.SingleSubstitution); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -181,7 +214,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.SingleSubstitution); + Collections.singletonList(UnifiedCompositionMode.SingleSubstitution); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -230,7 +263,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -279,7 +312,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.SingleSubstitution); + Collections.singletonList(UnifiedCompositionMode.SingleSubstitution); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -376,8 +409,8 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList( - UnifiedCompositionMode.ScalingInstances, UnifiedCompositionMode.SingleSubstitution); + Arrays.asList(UnifiedCompositionMode.ScalingInstances, + UnifiedCompositionMode.SingleSubstitution); verifyMainServiceTemplateConsolidation(2, expectedUnifiedModes, toscaServiceModel); } @@ -424,7 +457,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -540,7 +573,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -584,7 +617,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -596,7 +629,8 @@ public class ConsolidationServiceTest { ("/mock/services/heattotosca/consolidation/translatedfiles/computeportconsolidation/one_exCP_naming_diff", null, null); - TestUtils.initComputeNodeTypeInConsolidationData(mainST, computeNodeTypeName, consolidationData); + TestUtils + .initComputeNodeTypeInConsolidationData(mainST, computeNodeTypeName, consolidationData); List<Pair<String, String>> portTypeToIdList = new ArrayList<>(); portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); @@ -626,12 +660,12 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @Test - public void testFalsePortConsolidationForOneDiffExpcNaming(){ + public void testFalsePortConsolidationForOneDiffExpcNaming() { } @@ -674,7 +708,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -717,7 +751,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -760,7 +794,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -799,21 +833,24 @@ public class ConsolidationServiceTest { TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -832,8 +869,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -842,8 +880,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -852,30 +891,34 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), - Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), null, null, + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("group_id1"), null, + null, portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -894,8 +937,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), null, null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -903,8 +948,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -913,8 +959,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_2"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), null, null, + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_2"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -925,7 +973,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -944,8 +992,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), null, null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -953,8 +1003,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -963,8 +1014,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume_1"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume_1"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -976,7 +1028,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -995,8 +1047,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), null, null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -1004,8 +1058,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -1014,8 +1069,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume_1"), Arrays.asList("group_id1"), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume_1"), + Collections.singletonList("group_id1"), null, null, portTypeToIdList, consolidationData); @@ -1027,7 +1083,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1046,8 +1102,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1056,8 +1114,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1066,8 +1125,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_2"), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_2"), null, null, portTypeToIdList, consolidationData); @@ -1079,7 +1139,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1098,8 +1158,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1108,8 +1170,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1118,29 +1181,33 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1159,8 +1226,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1169,8 +1238,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1179,29 +1249,33 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_2"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_2"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1220,8 +1294,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1230,8 +1306,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1240,29 +1317,33 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Collections.singletonList("group_id_1"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_1"), Arrays.asList("net_id_2"), Arrays.asList("group_id_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_2"), + Collections.singletonList("group_id_1"), null, null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1281,8 +1362,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1291,8 +1374,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1301,29 +1385,30 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_2"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_2"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_3"), null, null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1343,9 +1428,11 @@ public class ConsolidationServiceTest { TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("node_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("node_1"), null, portTypeToIdList, consolidationData); @@ -1353,9 +1440,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("node_2"), null, + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("node_2"), null, portTypeToIdList, consolidationData); @@ -1363,29 +1451,30 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("node_3"), null, + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("node_3"), null, portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_2"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_2"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_2"), null, null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1405,9 +1494,11 @@ public class ConsolidationServiceTest { TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("server_ps02"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("server_ps02"), null, portTypeToIdList, consolidationData); @@ -1415,9 +1506,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("node_1"), null, + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("node_1"), null, portTypeToIdList, consolidationData); @@ -1425,29 +1517,30 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("node_2"), null, + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("node_2"), null, portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_2"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_2"), null, null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), Arrays.asList("group_id_1", "group_id_2"), null, null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1467,8 +1560,10 @@ public class ConsolidationServiceTest { TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1477,8 +1572,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1487,8 +1583,9 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), null, null, portTypeToIdList, consolidationData); @@ -1497,18 +1594,22 @@ public class ConsolidationServiceTest { List<String> portNodeTemplateIds = Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3"); List<List<String>> nodesConnectedInIds = - Arrays.asList(Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), - Arrays.asList("node_in_1")); + Arrays.asList(Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1")); List<List<String>> nodesConnectedOutIds = - Arrays.asList(Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), - Arrays.asList("node_out_1")); + Arrays.asList(Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1")); List<List<String>> getAttrInIds = - Arrays.asList(Arrays.asList("get_attr_1"), Arrays.asList("get_attr_2"), - Arrays.asList("get_attr_3")); + Arrays.asList(Collections.singletonList("get_attr_1"), + Collections.singletonList("get_attr_2"), + Collections.singletonList("get_attr_3")); List<List<String>> groupIds = - Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", - "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); - List<List<Pair<String, GetAttrFuncData>>> getAttrOut = Arrays.asList(null, null, null); + Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); + List<List<Pair<String, GetAttrFuncData>>> getAttrOut = + Arrays.asList(null, null, null); TestUtils.updateMultiplePortConsolidationDatas( mainST, portNodeTemplateIds, nodesConnectedInIds, nodesConnectedOutIds, groupIds, @@ -1516,7 +1617,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1537,9 +1638,11 @@ public class ConsolidationServiceTest { TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("node_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("node_1"), null, portTypeToIdList, consolidationData); @@ -1547,9 +1650,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("node_2"), null, + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("node_2"), null, portTypeToIdList, consolidationData); @@ -1557,9 +1661,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("node_3"), null, + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("node_3"), null, portTypeToIdList, consolidationData); @@ -1567,18 +1672,22 @@ public class ConsolidationServiceTest { List<String> portNodeTemplateIds = Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3"); List<List<String>> nodesConnectedInIds = - Arrays.asList(Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), - Arrays.asList("node_in_1")); + Arrays.asList(Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1")); List<List<String>> nodesConnectedOutIds = - Arrays.asList(Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), - Arrays.asList("node_out_1")); + Arrays.asList(Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1")); List<List<String>> getAttrInIds = - Arrays.asList(Arrays.asList("get_attr_1"), Arrays.asList("get_attr_2"), - Arrays.asList("cm01_port_1")); + Arrays.asList(Collections.singletonList("get_attr_1"), + Collections.singletonList("get_attr_2"), + Collections.singletonList("cm01_port_1")); List<List<String>> groupIds = - Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", - "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); - List<List<Pair<String, GetAttrFuncData>>> getAttrOut = Arrays.asList(null, null, null); + Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); + List<List<Pair<String, GetAttrFuncData>>> getAttrOut = + Arrays.asList(null, null, null); TestUtils.updateMultiplePortConsolidationDatas( mainST, portNodeTemplateIds, nodesConnectedInIds, nodesConnectedOutIds, groupIds, @@ -1586,7 +1695,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.CatalogInstance); + Collections.singletonList(UnifiedCompositionMode.CatalogInstance); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1607,9 +1716,11 @@ public class ConsolidationServiceTest { TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), null, portTypeToIdList, consolidationData); @@ -1617,9 +1728,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_2"), null, + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_2"), null, portTypeToIdList, consolidationData); @@ -1627,9 +1739,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_3"), null, + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_3"), null, portTypeToIdList, consolidationData); @@ -1637,18 +1750,22 @@ public class ConsolidationServiceTest { List<String> portNodeTemplateIds = Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3"); List<List<String>> nodesConnectedInIds = - Arrays.asList(Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), - Arrays.asList("node_in_1")); + Arrays.asList(Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1")); List<List<String>> nodesConnectedOutIds = - Arrays.asList(Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), - Arrays.asList("node_out_1")); + Arrays.asList(Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1")); List<List<String>> getAttrInIds = - Arrays.asList(Arrays.asList("get_attr_1"), Arrays.asList("get_attr_2"), - Arrays.asList("get_attr_3")); + Arrays.asList(Collections.singletonList("get_attr_1"), + Collections.singletonList("get_attr_2"), + Collections.singletonList("get_attr_3")); List<List<String>> groupIds = - Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", - "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); - List<List<Pair<String, GetAttrFuncData>>> getAttrOut = Arrays.asList(null, null, null); + Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); + List<List<Pair<String, GetAttrFuncData>>> getAttrOut = + Arrays.asList(null, null, null); TestUtils.updateMultiplePortConsolidationDatas( mainST, portNodeTemplateIds, nodesConnectedInIds, nodesConnectedOutIds, groupIds, @@ -1656,7 +1773,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1676,10 +1793,13 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_1", getAttrFuncData)), + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), + Collections.singletonList( + new ImmutablePair<>("cm01_port_1", getAttrFuncData)), portTypeToIdList, consolidationData); @@ -1687,10 +1807,12 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_1", getAttrFuncData)), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), + Collections.singletonList( + new ImmutablePair<>("cm01_port_1", getAttrFuncData)), portTypeToIdList, consolidationData); @@ -1698,30 +1820,35 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("cm01_port", "cm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_1", getAttrFuncData)), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), + Collections.singletonList( + new ImmutablePair<>("cm01_port_1", getAttrFuncData)), portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), - Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("sm01_port_2"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Arrays.asList("group_id_1", "group_id_2"), + Collections.singletonList("sm01_port_2"), null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), - Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("sm01_port_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Arrays.asList("group_id_1", "group_id_2"), + Collections.singletonList("sm01_port_1"), null, consolidationData); TestUtils.updatePortConsolidationData(mainST, "cm01_port_3", - Arrays.asList("node_in_1"), Arrays.asList("net_id_1"), - Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("rm01_port_1"), null, + Collections.singletonList("node_in_1"), Collections.singletonList("net_id_1"), + Arrays.asList("group_id_1", "group_id_2"), + Collections.singletonList("rm01_port_1"), null, consolidationData); translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1742,10 +1869,13 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_1", getAttrFuncData)), + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), + Collections.singletonList( + new ImmutablePair<>("cm01_port_1", getAttrFuncData)), portTypeToIdList, consolidationData); @@ -1754,10 +1884,12 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_1", getAttrFuncData)), + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), + Collections.singletonList( + new ImmutablePair<>("cm01_port_1", getAttrFuncData)), portTypeToIdList, consolidationData); @@ -1766,37 +1898,49 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("sm01_port_1", getAttrFuncData)), + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), + Collections.singletonList( + new ImmutablePair<>("sm01_port_1", getAttrFuncData)), portTypeToIdList, consolidationData); TestUtils.initPortConsolidationData(mainST, consolidationData); List<String> portNodeTemplateIds = - Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3", "sm01_port_1", "sm01_port_2", + Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3", "sm01_port_1", + "sm01_port_2", "sm01_port_3"); List<List<String>> nodesConnectedInIds = - Arrays.asList(Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), Arrays.asList - ("node_in_1"), Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), - Arrays.asList("node_in_1")); + Arrays.asList(Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), Collections.singletonList + ("node_in_1"), Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1")); List<List<String>> nodesConnectedOutIds = - Arrays.asList(Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), Arrays.asList - ("node_out_1"), Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), - Arrays.asList("node_out_1")); + Arrays.asList(Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), Collections.singletonList + ("node_out_1"), Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1")); List<List<String>> getAttrInIds = - Arrays.asList(Arrays.asList("get_attr_1"), Arrays.asList("get_attr_2"), Arrays.asList - ("get_attr_3"), Arrays.asList("get_attr_1"), Arrays.asList("get_attr_2"), - Arrays.asList("get_attr_3")); + Arrays.asList(Collections.singletonList("get_attr_1"), + Collections.singletonList("get_attr_2"), Collections.singletonList + ("get_attr_3"), Collections.singletonList("get_attr_1"), + Collections.singletonList("get_attr_2"), + Collections.singletonList("get_attr_3")); List<List<String>> groupIds = - Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", - "group_id_2"), Arrays.asList("group_id_1", "group_id_2"), - Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", + Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", + "group_id_2"), Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); - List<List<Pair<String, GetAttrFuncData>>> getAttrOut = Arrays.asList(null, null, null, null, - null, null); + List<List<Pair<String, GetAttrFuncData>>> getAttrOut = + Arrays.asList(null, null, null, null, + null, null); TestUtils.updateMultiplePortConsolidationDatas(mainST, portNodeTemplateIds, nodesConnectedInIds, nodesConnectedOutIds, groupIds, getAttrInIds, getAttrOut, @@ -1804,7 +1948,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.SingleSubstitution); + Collections.singletonList(UnifiedCompositionMode.SingleSubstitution); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1824,9 +1968,11 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), null, portTypeToIdList, consolidationData); @@ -1835,9 +1981,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), null, + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), null, portTypeToIdList, consolidationData); @@ -1846,9 +1993,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), null, + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), null, portTypeToIdList, consolidationData); @@ -1856,30 +2004,43 @@ public class ConsolidationServiceTest { GetAttrFuncData getAttrFuncData = new GetAttrFuncData("name", "s1_name"); List<String> portNodeTemplateIds = - Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3", "sm01_port_1", "sm01_port_2", + Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3", "sm01_port_1", + "sm01_port_2", "sm01_port_3"); List<List<String>> nodesConnectedInIds = - Arrays.asList(Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), Arrays.asList - ("node_in_1"), Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), - Arrays.asList("node_in_1")); + Arrays.asList(Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), Collections.singletonList + ("node_in_1"), Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1")); List<List<String>> nodesConnectedOutIds = - Arrays.asList(Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), Arrays.asList - ("node_out_1"), Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), - Arrays.asList("node_out_1")); + Arrays.asList(Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), Collections.singletonList + ("node_out_1"), Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1")); List<List<String>> getAttrInIds = Arrays.asList(null, null, null, null, null, null); List<List<String>> groupIds = - Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", - "group_id_2"), Arrays.asList("group_id_1", "group_id_2"), - Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", + Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", + "group_id_2"), Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); List<List<Pair<String, GetAttrFuncData>>> getAttrOut = Arrays.asList( - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("sm01_port_1", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("sm01_port_2", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("sm01_port_3", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_1", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_2", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_3", getAttrFuncData))); + Collections.singletonList( + new ImmutablePair<>("sm01_port_1", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("sm01_port_2", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("sm01_port_3", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("cm01_port_1", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("cm01_port_2", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("cm01_port_3", getAttrFuncData))); TestUtils.updateMultiplePortConsolidationDatas(mainST, portNodeTemplateIds, nodesConnectedInIds, nodesConnectedOutIds, groupIds, getAttrInIds, getAttrOut, @@ -1887,7 +2048,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.ScalingInstances); + Collections.singletonList(UnifiedCompositionMode.ScalingInstances); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1907,9 +2068,11 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_1")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps01", Arrays.asList("cm01_port_1"), Arrays.asList - ("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), null, + computeNodeTypeName, "server_ps01", Collections.singletonList("cm01_port_1"), + Collections.singletonList + ("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), null, portTypeToIdList, consolidationData); @@ -1918,9 +2081,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_2")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps02", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), null, + computeNodeTypeName, "server_ps02", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), null, portTypeToIdList, consolidationData); @@ -1929,9 +2093,10 @@ public class ConsolidationServiceTest { portTypeToIdList.add(new ImmutablePair<>("sm01_port", "sm01_port_3")); TestUtils.updateComputeTemplateConsolidationData( mainST, - computeNodeTypeName, "server_ps03", Arrays.asList("cm01_port_1"), - Arrays.asList("cmaui_volume"), Arrays.asList("cmaui_volume"), Arrays.asList("group_id_1"), - Arrays.asList("cm01_port_1"), null, + computeNodeTypeName, "server_ps03", Collections.singletonList("cm01_port_1"), + Collections.singletonList("cmaui_volume"), Collections.singletonList("cmaui_volume"), + Collections.singletonList("group_id_1"), + Collections.singletonList("cm01_port_1"), null, portTypeToIdList, consolidationData); @@ -1939,30 +2104,42 @@ public class ConsolidationServiceTest { GetAttrFuncData getAttrFuncData = new GetAttrFuncData("name", "s1_name"); List<String> portNodeTemplateIds = - Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3", "sm01_port_1", "sm01_port_2", + Arrays.asList("cm01_port_1", "cm01_port_2", "cm01_port_3", "sm01_port_1", + "sm01_port_2", "sm01_port_3"); List<List<String>> nodesConnectedInIds = - Arrays.asList(Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), Arrays.asList - ("node_in_1"), Arrays.asList("node_in_1"), Arrays.asList("node_in_1"), - Arrays.asList("node_in_1")); + Arrays.asList(Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), Collections.singletonList + ("node_in_1"), Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1"), + Collections.singletonList("node_in_1")); List<List<String>> nodesConnectedOutIds = - Arrays.asList(Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), Arrays.asList - ("node_out_1"), Arrays.asList("node_out_1"), Arrays.asList("node_out_1"), - Arrays.asList("node_out_1")); + Arrays.asList(Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), Collections.singletonList + ("node_out_1"), Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1"), + Collections.singletonList("node_out_1")); List<List<String>> getAttrInIds = Arrays.asList(null, null, null, null, null, null); List<List<String>> groupIds = - Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", - "group_id_2"), Arrays.asList("group_id_1", "group_id_2"), - Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", + Arrays.asList(Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), + Arrays.asList("group_id_1", "group_id_2"), Arrays.asList("group_id_1", "group_id_2")); List<List<Pair<String, GetAttrFuncData>>> getAttrOut = Arrays.asList( - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("server_ps01", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("server_ps01", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("sm01_port_3", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_1", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_2", getAttrFuncData)), - Arrays.asList(new ImmutablePair<String, GetAttrFuncData>("cm01_port_3", getAttrFuncData))); + Collections.singletonList( + new ImmutablePair<>("server_ps01", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("server_ps01", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("sm01_port_3", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("cm01_port_1", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("cm01_port_2", getAttrFuncData)), + Collections.singletonList( + new ImmutablePair<>("cm01_port_3", getAttrFuncData))); TestUtils.updateMultiplePortConsolidationDatas(mainST, portNodeTemplateIds, nodesConnectedInIds, nodesConnectedOutIds, groupIds, getAttrInIds, getAttrOut, @@ -1970,7 +2147,7 @@ public class ConsolidationServiceTest { translationContext.setConsolidationData(consolidationData); List<UnifiedCompositionMode> expectedUnifiedModes = - Arrays.asList(UnifiedCompositionMode.SingleSubstitution); + Collections.singletonList(UnifiedCompositionMode.SingleSubstitution); verifyMainServiceTemplateConsolidation(1, expectedUnifiedModes, toscaServiceModel); } @@ -1981,7 +2158,7 @@ public class ConsolidationServiceTest { String nestedServiceTemplateName = "nested-pcm_v0.1ServiceTemplate.yaml"; ConsolidationData consolidationData = new ConsolidationData(); - TestUtils.updateNestedConsolidationData(mainSTName, Arrays.asList("server_pcm_001"), + TestUtils.updateNestedConsolidationData(mainSTName, Collections.singletonList("server_pcm_001"), consolidationData); TestUtils.initComputeNodeTypeInConsolidationData(mainSTName, "org.openecomp.resource.vfc.nodes.heat" + @@ -2014,7 +2191,7 @@ public class ConsolidationServiceTest { String nestedServiceTemplateName = "nested-pcm_v0.1ServiceTemplate.yaml"; ConsolidationData consolidationData = new ConsolidationData(); - TestUtils.updateNestedConsolidationData(mainSTName, Arrays.asList("server_pcm_001"), + TestUtils.updateNestedConsolidationData(mainSTName, Collections.singletonList("server_pcm_001"), consolidationData); TestUtils.initComputeNodeTypeInConsolidationData(mainSTName, "org.openecomp.resource.vfc.nodes.heat" + @@ -2026,7 +2203,7 @@ public class ConsolidationServiceTest { "org.openecomp.resource.vfc.nodes.heat" + ".pcm_server", consolidationData); - TestUtils.updateNestedConsolidationData(mainSTName, Arrays.asList("server_oam_001"), + TestUtils.updateNestedConsolidationData(mainSTName, Collections.singletonList("server_oam_001"), consolidationData); TestUtils.initComputeNodeTypeInConsolidationData(mainSTName, "org.openecomp.resource.vfc.nodes.heat" + @@ -2056,7 +2233,7 @@ public class ConsolidationServiceTest { String nestedServiceTemplateName = "nested-pcm_v0.1ServiceTemplate.yaml"; ConsolidationData consolidationData = new ConsolidationData(); - TestUtils.updateNestedConsolidationData(mainSTName, Arrays.asList("server_pcm_001"), + TestUtils.updateNestedConsolidationData(mainSTName, Collections.singletonList("server_pcm_001"), consolidationData); TestUtils.initComputeNodeTypeInConsolidationData(nestedServiceTemplateName, "org.openecomp.resource.vfc.nodes.heat" + @@ -2069,7 +2246,8 @@ public class ConsolidationServiceTest { ".heat.pcm_server", "pcm_server_1", consolidationData); TestUtils - .updateNestedConsolidationData(nestedServiceTemplateName, Arrays.asList("server_pcm_002"), + .updateNestedConsolidationData(nestedServiceTemplateName, + Collections.singletonList("server_pcm_002"), consolidationData); TestUtils.initComputeNodeTemplateIdInConsolidationData(nestedServiceTemplateName, "org.openecomp.resource.vfc.nodes" + @@ -2081,7 +2259,8 @@ public class ConsolidationServiceTest { addMockServiceTemplateToContext(nestedServiceTemplateName, "nested-pcm_v0.1"); Mockito.doNothing().when(consolidationService).serviceTemplateConsolidation - (translationContext.getTranslatedServiceTemplates().get(nestedServiceTemplateName), translationContext); + (translationContext.getTranslatedServiceTemplates().get(nestedServiceTemplateName), + translationContext); verifySubstitutionServiceTemplateConsolidation (1, translationContext.getTranslatedServiceTemplates().get(mainSTName), translationContext.getTranslatedServiceTemplates().get(nestedServiceTemplateName), @@ -2095,7 +2274,7 @@ public class ConsolidationServiceTest { String nestedServiceTemplateName = "nested-pcm_v0.1ServiceTemplate.yaml"; ConsolidationData consolidationData = new ConsolidationData(); - TestUtils.updateNestedConsolidationData(mainSTName, Arrays.asList("server_pcm_001"), + TestUtils.updateNestedConsolidationData(mainSTName, Collections.singletonList("server_pcm_001"), consolidationData); TestUtils.initComputeNodeTypeInConsolidationData(mainSTName, "org.openecomp.resource.vfc.nodes.heat" + @@ -2110,7 +2289,8 @@ public class ConsolidationServiceTest { ".heat.pcm_server", "pcm_server", consolidationData); TestUtils - .updateNestedConsolidationData(nestedServiceTemplateName, Arrays.asList("nested_resource"), + .updateNestedConsolidationData(nestedServiceTemplateName, + Collections.singletonList("nested_resource"), consolidationData); translationContext.setConsolidationData(consolidationData); @@ -2124,6 +2304,300 @@ public class ConsolidationServiceTest { UnifiedCompositionMode.SingleSubstitution); } + @Test + public void testConsolidationPreConditionFalseDiffSubportTypes() throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + generateComputeAndPortConsolidationData(computeNodeTypeName, consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", null, null, null, null, consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested2.yaml", 2, + "role_2", "interface_2", null, null, null, null, consolidationData)); + testConsolidation(1, toscaServiceModel, consolidationData, Collections.singletonList(UnifiedCompositionMode.SingleSubstitution)); + } + + private void generateComputeAndPortConsolidationData(String computeNodeTypeName, + ConsolidationData consolidationData) { + TestUtils + .initComputeNodeTypeInConsolidationData(mainST, computeNodeTypeName, consolidationData); + + updateComputeConsolidationData("server_ps01", computeNodeTypeName, "cm01_port", + "cm01_port_1", consolidationData); + + updateComputeConsolidationData("server_ps02", computeNodeTypeName, "cm01_port", + "cm01_port_2", consolidationData); + + TestUtils.initPortConsolidationData(mainST, consolidationData); + TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", + null, null, null, null, null, + consolidationData); + TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", + null, null, null, null, null, + consolidationData); + } + + @Test + public void testConsolidationPreConditionFalseDiffSubportNumber() throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + generateComputeAndPortConsolidationData(computeNodeTypeName, consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", null, null, null, null, consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 2, + "role_2", "interface_2", null, null, null, null, consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 2, + "role_3", "interface_3", null, null, null, null, consolidationData)); + + testConsolidation(1, toscaServiceModel, + consolidationData, Collections.singletonList(UnifiedCompositionMode.SingleSubstitution)); + } + + @Test + public void testConsolidationRuleFalseDifferentCountInResourceGroup() throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + generateComputeAndPortConsolidationData(computeNodeTypeName, consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", null, null, null, null, consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 3, + "role_1", "interface_2", null, null, null, null, consolidationData)); + + testConsolidation(1, toscaServiceModel, + consolidationData, Collections.singletonList(UnifiedCompositionMode.CatalogInstance)); + } + + @Test + public void testConsolidationRuleFalseDifferentNodesConnectedInToResourceGroup() + throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + generateComputeAndPortConsolidationData(computeNodeTypeName, consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", Collections.singletonList("node_1"), null, null, null, + consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 2, + "role_1", "interface_2", Collections.singletonList("node_2"), null, null, null, + consolidationData)); + + testConsolidation(1, toscaServiceModel, consolidationData, Collections.singletonList(UnifiedCompositionMode.CatalogInstance)); + } + + @Test + public void testConsolidationRuleFalseDifferentNodesConnectedOutFromResourceGroup() + throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + generateComputeAndPortConsolidationData(computeNodeTypeName, consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", null, Collections.singletonList("node_1"), null, null, + consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 2, + "role_1", "interface_2", null, Collections.singletonList("node_2"), null, null, + consolidationData)); + + testConsolidation(1, toscaServiceModel, consolidationData, Collections.singletonList(UnifiedCompositionMode.CatalogInstance)); + } + + @Test + public void testConsolidationRuleFalseGetAttrInBetweenSubInterfacesOfSameType() + throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + generateComputeAndPortConsolidationData(computeNodeTypeName, consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", null, null, Collections.singletonList("in_node_1"), null, + consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 2, + "role_1", "interface_2", null, null, Collections.singletonList("interface_1"), null, + consolidationData)); + + testConsolidation(1, toscaServiceModel, consolidationData, Collections.singletonList(UnifiedCompositionMode.CatalogInstance)); + } + + @Test + public void testConsolidationRuleFalseGetAttrOutBetweenSubInterfacesOfSameType() + throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + TestUtils + .initComputeNodeTypeInConsolidationData(mainST, computeNodeTypeName, consolidationData); + + updateComputeConsolidationData("server_ps01", computeNodeTypeName, "cm01_port", + "cm01_port_1", consolidationData); + updateComputeConsolidationData("server_ps02", computeNodeTypeName, "cm01_port", + "cm01_port_2", consolidationData); + + GetAttrFuncData getAttrFuncData = new GetAttrFuncData("name", "c1_name"); + Pair<String, GetAttrFuncData> getAttrOutInvalid1 = + new ImmutablePair<>("interface_1", getAttrFuncData); + Pair<String, GetAttrFuncData> getAttrOutInvalid2 = + new ImmutablePair<>("interface_2", getAttrFuncData); + + TestUtils.initPortConsolidationData(mainST, consolidationData); + TestUtils.updatePortConsolidationData(mainST, "cm01_port_1", + null, null, null, null, null, + consolidationData); + TestUtils.updatePortConsolidationData(mainST, "cm01_port_2", + null, null, null, null, null, + consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", null, null, null, + Collections.singletonList(getAttrOutInvalid1), consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 2, + "role_1", "interface_2", null, null, null, + Collections.singletonList(getAttrOutInvalid2), consolidationData)); + + testConsolidation(1, toscaServiceModel, consolidationData, Collections.singletonList(UnifiedCompositionMode.CatalogInstance)); + } + + @Test + public void testConsolidationRuleFalseDifferentRoleInResourceGroup() throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + generateComputeAndPortConsolidationData(computeNodeTypeName, consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", null, null, null, null, consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 2, + "role_2", "interface_2", null, null, null, null, consolidationData)); + + testConsolidation(1, toscaServiceModel, consolidationData, Collections.singletonList(UnifiedCompositionMode.CatalogInstance)); + } + + @Test + public void testConsolidationRuleTrueForSubInterfaces() throws IOException { + translationContext = new TranslationContext(); + String computeNodeTypeName = "org.openecomp.resource.vfc.nodes.heat.ps_server"; + ToscaServiceModel toscaServiceModel = TestUtils.loadToscaServiceModel + ("/mock/services/heattotosca/consolidation/translatedfiles/pre_condition/different_subinterface_types", + null, null); + + ConsolidationData consolidationData = new ConsolidationData(); + generateComputeAndPortConsolidationData(computeNodeTypeName, consolidationData); + + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_1", "nested1.yaml", 2, + "role_1", "interface_1", Collections.singletonList("node_1"), + Collections.singletonList("node_1"), null, null, consolidationData)); + TestUtils + .addPortSubInterface( + new SubInterfaceConsolidationDataTestInfo(mainST, "cm01_port_2", "nested1.yaml", 2, + "role_1", "interface_2", Collections.singletonList("node_1"), + Collections.singletonList("node_1"), null, null, consolidationData)); + + testConsolidation(1, toscaServiceModel, consolidationData, Collections.singletonList(UnifiedCompositionMode.ScalingInstances)); + } + + private void testConsolidation(int times, ToscaServiceModel toscaServiceModel, + ConsolidationData consolidationData, + List<UnifiedCompositionMode> expectedUnifiedModes) { + Mockito.doNothing().when(unifiedCompositionServiceMock).createUnifiedComposition( + any(), + any(), + any(), + any(), + any()); + translationContext.setConsolidationData(consolidationData); + verifyMainServiceTemplateConsolidation(times, expectedUnifiedModes, toscaServiceModel); + } + + private void updateComputeConsolidationData(String computeNodeTemplateId, + String computeNodeTypeName, + String portType, + String portNodeTemplateId, + ConsolidationData consolidationData) { + List<Pair<String, String>> portTypeToIdList = new ArrayList<>(); + portTypeToIdList.add(new ImmutablePair<>(portType, portNodeTemplateId)); + + TestUtils.updateComputeTemplateConsolidationData( + mainST, + computeNodeTypeName, computeNodeTemplateId, + null, null, null, null, null, null, + portTypeToIdList, consolidationData); + } + private void verifyMainServiceTemplateConsolidation(int times, List<UnifiedCompositionMode> expectedUnifiedCompositionModes, @@ -2176,5 +2650,4 @@ public class ConsolidationServiceTest { .put(serviceTemplateFileName, serviceTemplate); } - */ } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java index 19f4d59514..17383a9a10 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation; +import static org.junit.Assert.assertEquals; + import org.apache.commons.collections4.MapUtils; import org.junit.AfterClass; import org.junit.Assert; @@ -51,8 +53,6 @@ import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import static org.junit.Assert.assertEquals; - public class BaseFullTranslationTest { |