datatypes.Constants: 73/109273/2
authorJulienBe <julien.bertozzi@intl.att.com>
Wed, 17 Jun 2020 20:27:45 +0000 (22:27 +0200)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Fri, 19 Jun 2020 10:55:13 +0000 (10:55 +0000)
  - adhere to naming conventions
  - remove unused

Issue-ID: SDC-3126
Change-Id: I4ea23a8c69aaaf8fcc404868d3c59c47d09ba442
Signed-off-by: JulienBe <julien.bertozzi@intl.att.com>
openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/Constants.java
openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaSolConverter.java
openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/VnfTopologyTemplateConverter.java
openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaConverterImplTest.java

index 7c766e2..2dbc19f 100644 (file)
 
 package org.openecomp.core.converter.datatypes;
 
-import java.io.File;
-
 public final class Constants {
-    public static final String mainStName = "MainServiceTemplate.yaml";
-    public static final String globalStName = "GlobalSubstitutionTypesServiceTemplate.yaml";
-    public static final String manifestFileName = "MainServiceTemplate.mf";
-    public static final String definitionsDir = "Definitions/";
-    public static final String metadataFile = "TOSCA-Metadata/TOSCA.meta";
-
-
-    private static final String DEFAULT_NAMESPACE = "tosca_default_namespace";
-    private static final String TEMPLATE_NAME = "template_name";
-    public static final String topologyTemplate = "topology_template";
-    private static final String TEMPLATE_AUTHOR = "template_author";
-    private static final String TEMPLATE_VERSION = "template_version";
-    private static final String DESCRIPTION = "description";
-    private static final String IMPORTS = "imports";
-    private static final String DSL_DEFINITIONS = "dsl_definitions";
-    public static final String nodeType = "node_type";
-    public static final String nodeTypes = "node_types";
-    private static final String RELATIONSHIP_TYPES = "relationship_types";
-    private static final String RELATIONSHIP_TEMPLATES = "relationship_templates";
-    private static final String CAPABILITY_TYPES = "capability_types";
-    private static final String ARTIFACT_TYPES = "artifact_types";
-    private static final String DATA_TYPES = "data_types";
-    private static final String INTERFACE_TYPES = "interface_types";
-    private static final String POLICY_TYPES = "policy_types";
-    private static final String GROUP_TYPES = "group_types";
-    private static final String REPOSITORIES = "repositories";
-    public static final String metadata = "metadata";
-    public static final String nodeTemplates = "node_templates";
-    public static final String inputs = "inputs";
-    public static final String outputs = "outputs";
-    public static final String substitutionMappings = "substitution_mappings";
-    public static final String capabilities = "capabilities";
-    public static final String requirements = "requirements";
+    public static final String MAIN_ST_NAME = "MainServiceTemplate.yaml";
+    public static final String GLOBAL_ST_NAME = "GlobalSubstitutionTypesServiceTemplate.yaml";
+    public static final String DEFINITIONS_DIR = "Definitions/";
+    public static final String TOPOLOGY_TEMPLATE = "topology_template";
+    public static final String NODE_TYPE = "node_type";
+    public static final String NODE_TYPES = "node_types";
+    public static final String METADATA = "metadata";
+    public static final String NODE_TEMPLATES = "node_templates";
+    public static final String INPUTS = "inputs";
+    public static final String OUTPUTS = "outputs";
+    public static final String SUBSTITUTION_MAPPINGS = "substitution_mappings";
+    public static final String CAPABILITIES = "capabilities";
+    public static final String REQUIREMENTS = "requirements";
     public static final String POLICIES = "policies";
 
-    public static final String openecompHeatIndex = "openecomp_heat_index";
+    public static final String OPENECOMP_HEAT_INDEX = "openecomp_heat_index";
     public static final String ONAP_INDEX = "onap_index";
-    public static final String globalSubstitution = "GlobalSubstitutionTypes";
-
-    public static final String externalFilesFolder = "External" + File.separator;
+    public static final String GLOBAL_SUBSTITUTION = "GlobalSubstitutionTypes";
 
     // prevent utility class instantiation
     private Constants () {
index 43ae3c9..7168192 100644 (file)
 package org.openecomp.core.impl;
 
 import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX;
-import static org.openecomp.core.converter.datatypes.Constants.definitionsDir;
-import static org.openecomp.core.converter.datatypes.Constants.globalStName;
-import static org.openecomp.core.converter.datatypes.Constants.globalSubstitution;
-import static org.openecomp.core.converter.datatypes.Constants.mainStName;
-import static org.openecomp.core.converter.datatypes.Constants.openecompHeatIndex;
+import static org.openecomp.core.converter.datatypes.Constants.DEFINITIONS_DIR;
+import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
+import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_SUBSTITUTION;
+import static org.openecomp.core.converter.datatypes.Constants.MAIN_ST_NAME;
+import static org.openecomp.core.converter.datatypes.Constants.OPENECOMP_HEAT_INDEX;
 import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME;
 import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX_IMPORT_FILE;
 import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.ONAP_INDEX_IMPORT_FILE;
@@ -183,9 +183,9 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
 
     private void convertImports(ServiceTemplate serviceTemplate) {
         List<Map<String, Import>> imports = new ArrayList<>();
-        imports.add(createImportMap(openecompHeatIndex, HEAT_INDEX_IMPORT_FILE));
+        imports.add(createImportMap(OPENECOMP_HEAT_INDEX, HEAT_INDEX_IMPORT_FILE));
         imports.add(createImportMap(ONAP_INDEX, ONAP_INDEX_IMPORT_FILE));
-        imports.add(createImportMap(globalSubstitution, globalStName));
+        imports.add(createImportMap(GLOBAL_SUBSTITUTION, GLOBAL_ST_NAME));
         serviceTemplate.setImports(imports);
     }
 
@@ -264,7 +264,7 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
     }
 
     protected boolean isMainServiceTemplate(String fileName) {
-        return fileName.endsWith(mainStName);
+        return fileName.endsWith(MAIN_ST_NAME);
     }
 
     protected boolean isMetadataFile(String fileName) {
@@ -272,11 +272,11 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
     }
 
     protected boolean isGlobalServiceTemplate(String fileName) {
-        return fileName.endsWith(globalStName);
+        return fileName.endsWith(GLOBAL_ST_NAME);
     }
 
     protected boolean isDefinitions(String fileName) {
-        return fileName.startsWith(definitionsDir);
+        return fileName.startsWith(DEFINITIONS_DIR);
     }
 
     private String getTemplateNameFromStName(String serviceTemplateName) {
index f94d2bf..ee66924 100644 (file)
@@ -22,7 +22,7 @@
 
 package org.openecomp.core.impl;
 
-import static org.openecomp.core.converter.datatypes.Constants.globalStName;
+import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS;
 import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
 
@@ -73,7 +73,7 @@ public abstract class AbstractToscaSolConverter extends AbstractToscaConverter {
         for (Map.Entry<String, byte[]> fileEntry : csarFiles.entrySet()) {
             if (!handledDefinitionFilesList.contains(fileEntry.getKey()) && !isMetadataFile(fileEntry.getKey())) {
                 if (isGlobalServiceTemplate(fileEntry.getKey())) {
-                    handleServiceTemplate(globalStName, fileEntry.getKey(), csarFiles, serviceTemplates);
+                    handleServiceTemplate(GLOBAL_ST_NAME, fileEntry.getKey(), csarFiles, serviceTemplates);
                 } else {
                     artifacts.addFile(
                             getConcreteArtifactFileName(fileEntry.getKey()), fileEntry.getValue());
index fcc6f0a..6f50205 100644 (file)
@@ -25,8 +25,8 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.openecomp.core.converter.datatypes.Constants.globalStName;
-import static org.openecomp.core.converter.datatypes.Constants.mainStName;
+import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
+import static org.openecomp.core.converter.datatypes.Constants.MAIN_ST_NAME;
 
 public class ToscaConverterImpl extends AbstractToscaConverter {
 
@@ -42,11 +42,11 @@ public class ToscaConverterImpl extends AbstractToscaConverter {
           CsarFileTypes fileType = getFileType(fileEntry.getKey());
           switch (fileType) {
               case mainServiceTemplate:
-                  handleServiceTemplate(mainStName, fileEntry.getKey(), csarFiles, serviceTemplates);
+                  handleServiceTemplate(MAIN_ST_NAME, fileEntry.getKey(), csarFiles, serviceTemplates);
                   break;
 
               case globalServiceTemplate:
-                  handleServiceTemplate(globalStName, fileEntry.getKey(), csarFiles, serviceTemplates);
+                  handleServiceTemplate(GLOBAL_ST_NAME, fileEntry.getKey(), csarFiles, serviceTemplates);
                   break;
 
               case externalFile:
@@ -63,7 +63,7 @@ public class ToscaConverterImpl extends AbstractToscaConverter {
           }
       }
       handleMetadataFile(csarFiles);
-      updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, mainStName);
+      updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, MAIN_ST_NAME);
       return toscaServiceModel;
     }
 
index b676fb2..f902309 100644 (file)
@@ -45,11 +45,11 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 
-import static org.openecomp.core.converter.datatypes.Constants.capabilities;
-import static org.openecomp.core.converter.datatypes.Constants.inputs;
-import static org.openecomp.core.converter.datatypes.Constants.nodeType;
-import static org.openecomp.core.converter.datatypes.Constants.outputs;
-import static org.openecomp.core.converter.datatypes.Constants.requirements;
+import static org.openecomp.core.converter.datatypes.Constants.CAPABILITIES;
+import static org.openecomp.core.converter.datatypes.Constants.INPUTS;
+import static org.openecomp.core.converter.datatypes.Constants.NODE_TYPE;
+import static org.openecomp.core.converter.datatypes.Constants.OUTPUTS;
+import static org.openecomp.core.converter.datatypes.Constants.REQUIREMENTS;
 
 public class VnfTopologyTemplateConverter {
 
@@ -63,12 +63,12 @@ public class VnfTopologyTemplateConverter {
 
     private void convertInputs(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
         Map<String, Object> inputs = readerService.getInputs();
-        addInputsOrOutputsToServiceTemplate(serviceTemplate, inputs, Constants.inputs);
+        addInputsOrOutputsToServiceTemplate(serviceTemplate, inputs, Constants.INPUTS);
     }
 
     private void convertOutputs(ServiceTemplate serviceTemplate, ServiceTemplateReaderService readerService) {
         Map<String, Object> outputs = readerService.getOutputs();
-        addInputsOrOutputsToServiceTemplate(serviceTemplate, outputs, Constants.outputs);
+        addInputsOrOutputsToServiceTemplate(serviceTemplate, outputs, Constants.OUTPUTS);
     }
 
     private void addInputsOrOutputsToServiceTemplate(ServiceTemplate serviceTemplate, Map<String, Object> mapToConvert,
@@ -93,9 +93,9 @@ public class VnfTopologyTemplateConverter {
 
     private void addToServiceTemplateAccordingToSection(ServiceTemplate serviceTemplate, String inputsOrOutputs,
             String parameterId, ParameterDefinition parameterDefinition) {
-        if (inputsOrOutputs.equals(inputs)) {
+        if (inputsOrOutputs.equals(INPUTS)) {
             DataModelUtil.addInputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
-        } else if (inputsOrOutputs.equals(outputs)) {
+        } else if (inputsOrOutputs.equals(OUTPUTS)) {
             DataModelUtil.addOutputParameterToTopologyTemplate(serviceTemplate, parameterId, parameterDefinition);
         }
     }
@@ -163,11 +163,11 @@ public class VnfTopologyTemplateConverter {
     private SubstitutionMapping convertSubstitutionMappings(Map<String, Object> substitutionMappings) {
         SubstitutionMapping substitutionMapping = new SubstitutionMapping();
 
-        substitutionMapping.setNode_type((String) substitutionMappings.get(nodeType));
+        substitutionMapping.setNode_type((String) substitutionMappings.get(NODE_TYPE));
         substitutionMapping.setCapabilities(
-                convertSubstitutionMappingsSections(capabilities, substitutionMappings.get(capabilities)));
+                convertSubstitutionMappingsSections(CAPABILITIES, substitutionMappings.get(CAPABILITIES)));
         substitutionMapping.setRequirements(
-                convertSubstitutionMappingsSections(requirements, substitutionMappings.get(requirements)));
+                convertSubstitutionMappingsSections(REQUIREMENTS, substitutionMappings.get(REQUIREMENTS)));
 
         return substitutionMapping;
     }
index a74ec8e..e39a5a6 100644 (file)
 package org.openecomp.core.impl.services;
 
 import static org.openecomp.core.converter.datatypes.Constants.POLICIES;
-import static org.openecomp.core.converter.datatypes.Constants.inputs;
-import static org.openecomp.core.converter.datatypes.Constants.metadata;
-import static org.openecomp.core.converter.datatypes.Constants.nodeTemplates;
-import static org.openecomp.core.converter.datatypes.Constants.nodeTypes;
-import static org.openecomp.core.converter.datatypes.Constants.outputs;
-import static org.openecomp.core.converter.datatypes.Constants.substitutionMappings;
-import static org.openecomp.core.converter.datatypes.Constants.topologyTemplate;
+import static org.openecomp.core.converter.datatypes.Constants.INPUTS;
+import static org.openecomp.core.converter.datatypes.Constants.METADATA;
+import static org.openecomp.core.converter.datatypes.Constants.NODE_TEMPLATES;
+import static org.openecomp.core.converter.datatypes.Constants.NODE_TYPES;
+import static org.openecomp.core.converter.datatypes.Constants.OUTPUTS;
+import static org.openecomp.core.converter.datatypes.Constants.SUBSTITUTION_MAPPINGS;
+import static org.openecomp.core.converter.datatypes.Constants.TOPOLOGY_TEMPLATE;
 import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DATA_TYPES;
 import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.IMPORTS;
 import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION;
@@ -72,7 +72,7 @@ public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderSe
 
     @Override
     public Object getMetadata() {
-        return this.readServiceTemplate.get(metadata);
+        return this.readServiceTemplate.get(METADATA);
     }
 
     @Override
@@ -82,38 +82,38 @@ public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderSe
 
     @Override
     public Map<String, Object> getNodeTypes() {
-        return Objects.isNull(this.readServiceTemplate.get(nodeTypes)) ? new HashMap<>()
-            : (Map<String, Object>) this.readServiceTemplate.get(nodeTypes);
+        return Objects.isNull(this.readServiceTemplate.get(NODE_TYPES)) ? new HashMap<>()
+            : (Map<String, Object>) this.readServiceTemplate.get(NODE_TYPES);
     }
 
     @Override
     public Object getTopologyTemplate() {
-        return this.readServiceTemplate.get(topologyTemplate);
+        return this.readServiceTemplate.get(TOPOLOGY_TEMPLATE);
     }
 
     @Override
     public Map<String, Object> getNodeTemplates() {
         return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
-            : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(nodeTemplates);
+            : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(NODE_TEMPLATES);
     }
 
     @Override
     public Map<String, Object> getInputs() {
         return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
-            : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(inputs);
+            : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(INPUTS);
     }
 
     @Override
     public Map<String, Object> getOutputs() {
         return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
-            : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(outputs);
+            : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate()).get(OUTPUTS);
     }
 
     @Override
     public Map<String, Object> getSubstitutionMappings() {
         return Objects.isNull(this.getTopologyTemplate()) ? new HashMap<>()
             : (Map<String, Object>) ((Map<String, Object>) this.getTopologyTemplate())
-                .get(substitutionMappings);
+                .get(SUBSTITUTION_MAPPINGS);
     }
 
     @Override
index bcfc3d8..5d25635 100644 (file)
@@ -41,8 +41,8 @@ import java.util.*;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.openecomp.core.converter.datatypes.Constants.globalStName;
-import static org.openecomp.core.converter.datatypes.Constants.mainStName;
+import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
+import static org.openecomp.core.converter.datatypes.Constants.MAIN_ST_NAME;
 
 public class ToscaConverterImplTest {
 
@@ -167,7 +167,7 @@ public class ToscaConverterImplTest {
 
   private void validateConvertorOutput(String outputFilesPath, ToscaServiceModel toscaServiceModel)
       throws IOException {
-    ServiceTemplate mainSt = toscaServiceModel.getServiceTemplates().get(mainStName);
+    ServiceTemplate mainSt = toscaServiceModel.getServiceTemplates().get(MAIN_ST_NAME);
     Map<String, ServiceTemplate> expectedOutserviceTemplates = new HashMap<>();
     loadServiceTemplates(outputFilesPath, new ToscaExtensionYamlUtil(),
         expectedOutserviceTemplates);
@@ -227,12 +227,12 @@ public class ToscaConverterImplTest {
     YamlUtil yamlUtil = new YamlUtil();
     if (Objects.nonNull(gloablSubstitutionServiceTemplate)) {
       assertEquals("difference global substitution service template: ",
-          yamlUtil.objectToYaml(expectedOutserviceTemplates.get(globalStName)),
+          yamlUtil.objectToYaml(expectedOutserviceTemplates.get(GLOBAL_ST_NAME)),
           yamlUtil.objectToYaml(gloablSubstitutionServiceTemplate));
     }
     if (Objects.nonNull(mainServiceTemplate)) {
       assertEquals("difference main service template: ",
-          yamlUtil.objectToYaml(expectedOutserviceTemplates.get(mainStName)),
+          yamlUtil.objectToYaml(expectedOutserviceTemplates.get(MAIN_ST_NAME)),
           yamlUtil.objectToYaml(mainServiceTemplate));
     }
   }