diff options
author | ojasdubey <ojas.dubey@amdocs.com> | 2017-12-13 16:23:43 +0530 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2017-12-27 09:37:31 +0000 |
commit | 6395962b153816a24eeada88a01449ce0c59dcbb (patch) | |
tree | 771af07152bfa586df9f9750af8cfe4e02169596 /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core | |
parent | 231e28d57fd0e9b4246027c852b20a5627069d36 (diff) |
Simplified the return condition
Note: Sonar violations will be handled as a separate
task
Change-Id: I862247f5c693f4d64dff4ce18f2f71e42c85355a
Issue-ID: SDC-749
Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core')
7 files changed, 84 insertions, 29 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java index 4ff8af495c..4a1f7c53cc 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java @@ -1,6 +1,25 @@ +/* + * 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. + */ + package org.openecomp.core.impl; +import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX; + import org.apache.commons.collections4.MapUtils; +import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.tosca.datatypes.model.Import; @@ -23,8 +42,10 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate { public static final String TEMPLATE_NAME_PROPERTY = "template_name"; public static final String DEFININTION_VERSION = "tosca_simple_yaml_1_0_0"; public static final String HEAT_INDEX = "openecomp_heat_index"; + public static final String HEAT_INDEX_IMPORT_FILE = "openecomp-heat/_index.yml"; + public static final String ONAP_INDEX_IMPORT_FILE = "onap/_index.yml"; private static final Map<String, ServiceTemplate> globalServiceTemplates = - GlobalTypesGenerator.getGlobalTypesServiceTemplate(); + GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.CSAR); public GlobalSubstitutionServiceTemplate() { super(); @@ -52,8 +73,11 @@ public class GlobalSubstitutionServiceTemplate extends ServiceTemplate { imports.add(stringImportMap); setImports(imports); Import imprtObj = new Import(); - imprtObj.setFile("openecomp-heat/_index.yml"); - stringImportMap.put("openecomp_heat_index", imprtObj); + imprtObj.setFile(HEAT_INDEX_IMPORT_FILE); + stringImportMap.put(HEAT_INDEX, imprtObj); + Import onapDefinitionsImport = new Import(); + onapDefinitionsImport.setFile(ONAP_INDEX_IMPORT_FILE); + stringImportMap.put(ONAP_INDEX, onapDefinitionsImport); } diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java index 39a53b499d..283f7fc3be 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java @@ -1,5 +1,38 @@ +/* + * 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. + */ + package org.openecomp.core.impl; +import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX; +import static org.openecomp.core.converter.datatypes.Constants.capabilities; +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.inputs; +import static org.openecomp.core.converter.datatypes.Constants.mainStName; +import static org.openecomp.core.converter.datatypes.Constants.manifestFileName; +import static org.openecomp.core.converter.datatypes.Constants.metadataFile; +import static org.openecomp.core.converter.datatypes.Constants.nodeType; +import static org.openecomp.core.converter.datatypes.Constants.openecompHeatIndex; +import static org.openecomp.core.converter.datatypes.Constants.outputs; +import static org.openecomp.core.converter.datatypes.Constants.requirements; +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; + import org.apache.commons.collections.MapUtils; import org.openecomp.core.converter.ServiceTemplateReaderService; import org.openecomp.core.converter.ToscaConverter; @@ -8,6 +41,7 @@ import org.openecomp.core.converter.datatypes.CsarFileTypes; import org.openecomp.core.converter.errors.SubstitutionMappingsConverterErrorBuilder; import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl; import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; @@ -41,20 +75,6 @@ import java.util.Optional; import java.util.jar.Manifest; import java.util.regex.Pattern; -import static org.openecomp.core.converter.datatypes.Constants.capabilities; -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.inputs; -import static org.openecomp.core.converter.datatypes.Constants.mainStName; -import static org.openecomp.core.converter.datatypes.Constants.manifestFileName; -import static org.openecomp.core.converter.datatypes.Constants.metadataFile; -import static org.openecomp.core.converter.datatypes.Constants.nodeType; -import static org.openecomp.core.converter.datatypes.Constants.openecompHeatIndex; -import static org.openecomp.core.converter.datatypes.Constants.outputs; -import static org.openecomp.core.converter.datatypes.Constants.requirements; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME; - public class ToscaConverterImpl implements ToscaConverter { public ToscaConverterImpl() { @@ -138,7 +158,7 @@ public class ToscaConverterImpl implements ToscaConverter { GlobalSubstitutionServiceTemplate globalSubstitutionServiceTemplate, Map<String, byte[]> csarFiles) { Collection<ServiceTemplate> globalServiceTemplates = - GlobalTypesGenerator.getGlobalTypesServiceTemplate().values(); + GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.CSAR).values(); addGlobalServiceTemplates(globalServiceTemplates, serviceTemplates); toscaServiceModel.setEntryDefinitionServiceTemplate(mainStName); toscaServiceModel.setServiceTemplates(serviceTemplates); @@ -224,7 +244,8 @@ public class ToscaConverterImpl implements ToscaConverter { private void convertImports(ServiceTemplate serviceTemplate) { serviceTemplate.setImports(new ArrayList<>()); serviceTemplate.getImports() - .add(createImportMap(openecompHeatIndex, "openecomp-heat/_index.yml")); + .add(createImportMap(openecompHeatIndex, HEAT_INDEX_IMPORT_FILE)); + serviceTemplate.getImports().add(createImportMap(ONAP_INDEX, ONAP_INDEX_IMPORT_FILE)); serviceTemplate.getImports().add(createImportMap(globalSubstitution, globalStName)); } diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java index 82a36950f3..0fec361561 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java @@ -1,5 +1,16 @@ package org.openecomp.core.converter.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.openecomp.core.converter.datatypes.Constants.ONAP_INDEX; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.DEFININTION_VERSION; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX; +import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.TEMPLATE_NAME_PROPERTY; +import static org.openecomp.sdc.common.utils.CommonUtil.validateAndUploadFileContent; + import org.apache.commons.io.IOUtils; import org.junit.Test; import org.openecomp.core.impl.GlobalSubstitutionServiceTemplate; @@ -12,16 +23,6 @@ import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; import java.net.URL; import java.util.Map; import java.util.Set; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.DEFININTION_VERSION; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX; -import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.TEMPLATE_NAME_PROPERTY; -import static org.openecomp.sdc.common.utils.CommonUtil.validateAndUploadFileContent; public class ToscaConvertorDefinitionsTest { @@ -48,6 +49,7 @@ public class ToscaConvertorDefinitionsTest { assertFalse(serviceTemplate.getImports().isEmpty()); assertEquals(1 ,serviceTemplate.getImports().size()); assertTrue(serviceTemplate.getImports().get(0).containsKey(HEAT_INDEX)); + assertTrue(serviceTemplate.getImports().get(0).containsKey(ONAP_INDEX)); assertEquals(DEFININTION_VERSION, serviceTemplate.getTosca_definitions_version()); diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/conversionWithInt/out/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/conversionWithInt/out/MainServiceTemplate.yaml index 10f7c21363..1a5c61efbe 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/conversionWithInt/out/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/conversionWithInt/out/MainServiceTemplate.yaml @@ -12,6 +12,8 @@ metadata: imports: - openecomp_heat_index: file: openecomp-heat/_index.yml +- onap_index: + file: onap/_index.yml - GlobalSubstitutionTypes: file: GlobalSubstitutionTypesServiceTemplate.yaml topology_template: diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertCsar/out/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertCsar/out/MainServiceTemplate.yaml index e54533e7c2..590ee413b8 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertCsar/out/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertCsar/out/MainServiceTemplate.yaml @@ -14,6 +14,8 @@ metadata: imports: - openecomp_heat_index: file: openecomp-heat/_index.yml +- onap_index: + file: onap/_index.yml - GlobalSubstitutionTypes: file: GlobalSubstitutionTypesServiceTemplate.yaml topology_template: diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml index ff43b5a7e7..88ae60529d 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertMainSt/out/MainServiceTemplate.yaml @@ -13,6 +13,8 @@ metadata: imports: - openecomp_heat_index: file: openecomp-heat/_index.yml +- onap_index: + file: onap/_index.yml - GlobalSubstitutionTypes: file: GlobalSubstitutionTypesServiceTemplate.yaml node_types: diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertParameters/out/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertParameters/out/MainServiceTemplate.yaml index 8dbe0517f5..d30f46e360 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertParameters/out/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/resources/mock/toscaConverter/convertParameters/out/MainServiceTemplate.yaml @@ -13,6 +13,8 @@ metadata: imports: - openecomp_heat_index: file: openecomp-heat/_index.yml +- onap_index: + file: onap/_index.yml - GlobalSubstitutionTypes: file: GlobalSubstitutionTypesServiceTemplate.yaml topology_template: |