From 821b76c6b81ebf96e8fd8340ac5f6ed79f8ed22a Mon Sep 17 00:00:00 2001 From: eleonorali Date: Sun, 15 Apr 2018 15:34:53 +0300 Subject: SIROV - add parent heat name for volume Refactoring to solve static analysis found issues + fix spelling issue for Requirments String (all issues suggested by Vitaly E.) Change-Id: I2f09d4ab088db7973ba3ff3a71a21bd1c830fad4 Issue-ID: SDC-996 Signed-off-by: eleonorali --- .../ResourceTranslationNeutronPortHelper.java | 71 +++++++++++----------- 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'openecomp-be') diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/ResourceTranslationNeutronPortHelper.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/ResourceTranslationNeutronPortHelper.java index 7af9bed23a..386ee7b94e 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/ResourceTranslationNeutronPortHelper.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/ResourceTranslationNeutronPortHelper.java @@ -35,40 +35,40 @@ public class ResourceTranslationNeutronPortHelper { public static final int DEFAULT_IP_VERSION = 4; public void setAdditionalProperties(Map properties) { - setRequirments(properties); + setRequirements(properties); setNetworkRoleTag(properties); } - private void setRequirments(Map properties) { - properties.putAll(addRequirments()); - setIpRequirments(properties); - setMacRequirments(properties); + private void setRequirements(Map properties) { + properties.putAll(addRequirements()); + setIpRequirements(properties); + setMacRequirements(properties); } - private void setIpRequirments(Map properties) { + private void setIpRequirements(Map properties) { setFixedIpCount(properties); setFloatingIpCount(properties); - addDefaultIpRequirment(properties); + addDefaultIpRequirement(properties); } - private Map addRequirments() { - Map properties = new HashMap(); + private Map addRequirements() { + Map properties = new HashMap<>(); List> ipRequirementsList = new ArrayList<>(); properties.put(IP_REQUIREMENTS, ipRequirementsList); - properties.put(MAC_REQUIREMENTS, createMacRequirment()); + properties.put(MAC_REQUIREMENTS, createMacRequirement()); return properties; } - private Map createMacRequirment() { - Map macRequirements = new HashMap(); - Map macIsRequired = new HashMap(); + private Map createMacRequirement() { + Map macRequirements = new HashMap<>(); + Map macIsRequired = new HashMap<>(); macIsRequired.put(IS_REQUIRED, Boolean.FALSE); macRequirements.put(MAC_COUNT_REQUIRED, macIsRequired); return macRequirements; } - private void setMacRequirments(Map properties) { + private void setMacRequirements(Map properties) { updateMacCountRequired(properties); } @@ -89,18 +89,17 @@ public class ResourceTranslationNeutronPortHelper { } - private void addDefaultIpRequirment(Map properties) { - List> ipRequirmentsList = ((List>) properties.get(IP_REQUIREMENTS)); - - if(CollectionUtils.isEmpty(ipRequirmentsList)) { - ipRequirmentsList.add(createIPRequirment(DEFAULT_IP_VERSION)); + private void addDefaultIpRequirement(Map properties) { + List> ipRequirementsList = ((List>) properties.get(IP_REQUIREMENTS)); + if(ipRequirementsList.isEmpty()) { + ipRequirementsList.add(createIPRequirement(DEFAULT_IP_VERSION)); } } - private Map createIPRequirment(Object version) { - Map ipRequirements = new HashMap(); - Map isRequired = new HashMap(); - Map floatingIsRequired = new HashMap(); + private Map createIPRequirement(Object version) { + Map ipRequirements = new HashMap<>(); + Map isRequired = new HashMap<>(); + Map floatingIsRequired = new HashMap<>(); isRequired.put(IS_REQUIRED, Boolean.FALSE); floatingIsRequired.put(IS_REQUIRED, Boolean.FALSE); ipRequirements.put(IP_COUNT_REQUIRED, isRequired); @@ -152,20 +151,20 @@ public class ResourceTranslationNeutronPortHelper { private void updateIpCountRequiredForVersion(String ipCountRequired, Map properties, Object ipVersion) { if (ipVersion != null) { - HashMap> ipRequirmentsMap = getIPRequirments(properties); - Map ipRequirement = ipRequirmentsMap.get(ipVersion); + HashMap> ipRequirementsMap = getIPRequirements(properties); + Map ipRequirement = ipRequirementsMap.get(ipVersion); if (ipRequirement == null){ - ipRequirement = addIPRequirment(properties, ipVersion); + ipRequirement = addIPRequirement(properties, ipVersion); } updateIpCountRequired(ipCountRequired, ipRequirement); } } - private Map addIPRequirment(Map properties, Object ipVersion) { - List> ipRequirmentsList = ((List>) properties.get(IP_REQUIREMENTS)); - Map newIpRequirment = createIPRequirment(ipVersion); - ipRequirmentsList.add(newIpRequirment); - return newIpRequirment; + private Map addIPRequirement(Map properties, Object ipVersion) { + List> ipRequirementsList = ((List>) properties.get(IP_REQUIREMENTS)); + Map newIpRequirement = createIPRequirement(ipVersion); + ipRequirementsList.add(newIpRequirement); + return newIpRequirement; } private void updateIpCountRequired(String ipCountRequired, Map ipRequirement) { @@ -173,11 +172,11 @@ public class ResourceTranslationNeutronPortHelper { isIPCountRequired.put(IS_REQUIRED, Boolean.TRUE); } - private HashMap > getIPRequirments (Map properties) { - HashMap> ipRequirmentsMap = new HashMap(); - List> ipRequirmentsList = ((List>) properties.get(IP_REQUIREMENTS)); - ipRequirmentsList.stream().forEach(e->ipRequirmentsMap.put(e.get(IP_VERSION),e)); - return ipRequirmentsMap; + private HashMap > getIPRequirements (Map properties) { + HashMap> ipRequirementsMap = new HashMap<>(); + List> ipRequirementsList = ((List>) properties.get(IP_REQUIREMENTS)); + ipRequirementsList.stream().forEach(e->ipRequirementsMap.put(e.get(IP_VERSION),e)); + return ipRequirementsMap; } private void setNetworkRoleTag(Map properties) { -- cgit 1.2.3-korg