From 62f5ad6b806d0bda1bb918061a5aa4b5b4dbe8b8 Mon Sep 17 00:00:00 2001 From: "bilal.iqbal" Date: Mon, 25 Mar 2019 14:31:14 +0000 Subject: Change SOL004 baseline from v2.5.1 to v2.6.1 Change-Id: Ic524e25a5f0a9952dd0a2c578034c60e51c7a290 Issue-ID: SDC-2190 Signed-off-by: bilal.iqbal --- .../openecomp/core/impl/ToscaSolConverterImpl.java | 21 +++++++++++++++------ .../core/impl/ToscaSolConverterImplTest.java | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core') diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java index 78a23f43ea..46a5904299 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java @@ -55,19 +55,21 @@ public class ToscaSolConverterImpl extends AbstractToscaConverter { Map serviceTemplates = new HashMap<>(); FileContentHandler artifacts = new FileContentHandler(); GlobalSubstitutionServiceTemplate gsst = new GlobalSubstitutionServiceTemplate(); - String mServiceDefinitionFileName = getMainServiceDefinitionFileName(fileContentHandler); - handleMainServiceTemplate(csarFiles, serviceTemplates, gsst, mServiceDefinitionFileName); + String mServiceDefinitionPath = getMainServiceDefinitionFileName(fileContentHandler); + handleMainServiceTemplate(csarFiles, serviceTemplates, gsst, mServiceDefinitionPath); handleExternalArtifacts(csarFiles, serviceTemplates, artifacts); handleMetadataFile(csarFiles); - updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, mServiceDefinitionFileName); + updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, getSimpleName(mServiceDefinitionPath)); return toscaServiceModel; } private void handleMainServiceTemplate(Map csarFiles, Map serviceTemplates, GlobalSubstitutionServiceTemplate gsst, String mServiceDefinitionFileName) { - handleServiceTemplate(mServiceDefinitionFileName, mServiceDefinitionFileName, csarFiles, serviceTemplates); - handleImportDefinitions(mServiceDefinitionFileName, csarFiles, mServiceDefinitionFileName.substring(0, - mServiceDefinitionFileName.lastIndexOf("/")), gsst); + if(mServiceDefinitionFileName != null){ + handleServiceTemplate(getSimpleName(mServiceDefinitionFileName), mServiceDefinitionFileName, csarFiles, serviceTemplates); + String parentDir = mServiceDefinitionFileName.substring(0, mServiceDefinitionFileName.lastIndexOf("/")); + handleImportDefinitions(mServiceDefinitionFileName, csarFiles, parentDir, gsst); + } } private void handleExternalArtifacts(Map csarFiles, Map serviceTemplates, FileContentHandler artifacts) { @@ -128,4 +130,11 @@ public class ToscaSolConverterImpl extends AbstractToscaConverter { throw new IOException(e.getMessage()); } } + + private String getSimpleName(String path){ + if(path != null && path.contains("/")){ + path = path.substring(path.lastIndexOf("/") + 1); + } + return path; + } } \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java index ad2e61523f..45d6332e06 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java @@ -71,9 +71,9 @@ public class ToscaSolConverterImplTest { Map serviceTemplateMap = toscaServiceModel.getServiceTemplates(); String entryDefinitionTemplateName = toscaServiceModel.getEntryDefinitionServiceTemplate(); Assert.assertTrue("Artifacts should contain external files", contentHandler.containsFile("Main.mf")); - Assert.assertTrue("Main service template should exist", serviceTemplateMap.containsKey("Definitions/Main.yaml")); + Assert.assertTrue("Main service template should exist", serviceTemplateMap.containsKey("Main.yaml")); Assert.assertEquals("Entry Definition name should be same as passed in TOSCA.meta", - "Definitions/Main.yaml", entryDefinitionTemplateName); + "Main.yaml", entryDefinitionTemplateName); } @Test(expected = IOException.class) -- cgit 1.2.3-korg