aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src
diff options
context:
space:
mode:
authorbilal.iqbal <bilal.iqbal@est.tech>2019-03-25 14:31:14 +0000
committerbilal.iqbal <bilal.iqbal@est.tech>2019-03-25 14:31:14 +0000
commit62f5ad6b806d0bda1bb918061a5aa4b5b4dbe8b8 (patch)
tree75d0c2d82c6be3b71d79b4174aca009681e9c0b1 /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src
parent53903f1d96affe2c21e3ffbdd45aea8f7af0714d (diff)
Change SOL004 baseline from v2.5.1 to v2.6.1
Change-Id: Ic524e25a5f0a9952dd0a2c578034c60e51c7a290 Issue-ID: SDC-2190 Signed-off-by: bilal.iqbal <bilal.iqbal@est.tech>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src')
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java21
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java4
2 files changed, 17 insertions, 8 deletions
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<String, ServiceTemplate> 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<String, byte[]> csarFiles, Map<String, ServiceTemplate> 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<String, byte[]> csarFiles, Map<String, ServiceTemplate> 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<String, ServiceTemplate> 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)