aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test
diff options
context:
space:
mode:
authorkooper <sergey.sachkov@est.tech>2019-03-04 13:47:51 +0000
committerkooper <sergey.sachkov@est.tech>2019-03-04 13:47:51 +0000
commit11e9d33f2f50ad3990905fba184b7c10d255070a (patch)
tree32e1a0ba3d5da03a41202e9bf28c28f099601972 /openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test
parent7deb4e0e5f6cf06b7fbb27c6bda4e91f847f4075 (diff)
Add manifest non mano set support
Issue-ID: SDC-2141 Change-Id: I056e8f7c1da8f17ce8583207660882f85a4d11a4 Signed-off-by: kooper <sergey.sachkov@est.tech>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java133
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/resources/nonManoConfig.yaml7
2 files changed, 140 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java
new file mode 100644
index 0000000000..ae69415f1d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java
@@ -0,0 +1,133 @@
+package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.sdc.tosca.parser.utils.YamlToObjectConverter;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.tosca.csar.Manifest;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ETSIServiceImplTest {
+ private ETSIService etsiService;
+ private String sol004MetaFile = "TOSCA-Meta-Version: 1.0\n" +
+ "CSAR-Version: 1.0\n" +
+ "Created-By: Kuku\n" +
+ "Entry-Definitions: MainServiceTemplate.yaml\n" +
+ "Entry-Manifest: MainServiceTemplate.mf\n" +
+ "Entry-Change-Log: MainServiceTemplate.log";
+ private String metaFile = "TOSCA-Meta-Version: 1.0\n" +
+ "CSAR-Version: 1.0\n" +
+ "Created-By: Kuku\n" +
+ "Entry-Definitions: MainServiceTemplate.yaml";
+
+ private String finalNonManoLocation = "Deployment/VES_EVENTS/test.xml";
+ private String finalOtherNonManoLocation = "Informational/OTHER/test.xml";
+
+ @Before
+ public void setUp() throws IOException {
+ YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter();
+ Configuration configuration = yamlToObjectConverter.convert("src/test/resources",
+ Configuration.class, "nonManoConfig.yaml");
+ etsiService = new ETSIServiceImpl(configuration);
+ }
+
+ @After
+ public void tearDown() {
+ etsiService = null;
+ }
+
+ @Test
+ public void testIsSol004TrueOrigin() {
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ fileContentHandler.addFile("TOSCA-Metadata/TOSCA.meta.original", sol004MetaFile.getBytes(StandardCharsets.UTF_8));
+ assertTrue(etsiService.isSol004WithToscaMetaDirectory(fileContentHandler));
+ }
+
+ @Test
+ public void testIsSol004True() {
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ fileContentHandler.addFile("TOSCA-Metadata/TOSCA.meta", sol004MetaFile.getBytes(StandardCharsets.UTF_8));
+ assertTrue(etsiService.isSol004WithToscaMetaDirectory(fileContentHandler));
+ }
+
+ @Test
+ public void testIsSol004False() {
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ fileContentHandler.addFile("TOSCA-Metadata/TOSCA.meta.original", metaFile.getBytes(StandardCharsets.UTF_8));
+ assertFalse(etsiService.isSol004WithToscaMetaDirectory(fileContentHandler));
+ }
+
+ @Test
+ public void testIsSol004FalseWithNull() {
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ assertFalse(etsiService.isSol004WithToscaMetaDirectory(fileContentHandler));
+ }
+
+ @Test
+ public void testMoveNonManoFileToArtifactFolder() throws IOException {
+ Map<String, List<String>> nonManoSources = new HashMap<>();
+ List<String> sources = new ArrayList<>();
+ sources.add("Some/test.xml");
+ nonManoSources.put("Some", sources);
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ fileContentHandler.addFile("Some/test.xml", new byte[1]);
+ Manifest manifest = mock(Manifest.class);
+ when(manifest.getNonManoSources()).thenReturn(nonManoSources);
+ etsiService.moveNonManoFileToArtifactFolder(fileContentHandler, manifest);
+ assertTrue(fileContentHandler.containsFile(finalNonManoLocation));
+ }
+
+ @Test
+ public void testMoveNonManoFileToArtifactFolderFileNotInFolder() throws IOException {
+ Map<String, List<String>> nonManoSources = new HashMap<>();
+ List<String> sources = new ArrayList<>();
+ sources.add("test.xml");
+ nonManoSources.put("foo", sources);
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ fileContentHandler.addFile("test.xml", new byte[1]);
+ Manifest manifest = mock(Manifest.class);
+ when(manifest.getNonManoSources()).thenReturn(nonManoSources);
+ etsiService.moveNonManoFileToArtifactFolder(fileContentHandler, manifest);
+ assertFalse(fileContentHandler.containsFile(finalOtherNonManoLocation));
+ }
+
+ @Test
+ public void testMoveNonManoFileToArtifactFolderNoMove() throws IOException {
+ Map<String, List<String>> nonManoSources = new HashMap<>();
+ List<String> sources = new ArrayList<>();
+ sources.add(finalNonManoLocation);
+ nonManoSources.put("Some", sources);
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ fileContentHandler.addFile(finalNonManoLocation, new byte[1]);
+ Manifest manifest = mock(Manifest.class);
+ when(manifest.getNonManoSources()).thenReturn(nonManoSources);
+ etsiService.moveNonManoFileToArtifactFolder(fileContentHandler, manifest);
+ assertTrue(fileContentHandler.containsFile(finalNonManoLocation));
+ }
+
+ @Test
+ public void testMoveNonManoFileToArtifactFolderMoveToKeyFolder() throws IOException {
+ Map<String, List<String>> nonManoSources = new HashMap<>();
+ List<String> sources = new ArrayList<>();
+ sources.add("Artifacts/Deployment/test.xml");
+ nonManoSources.put("Some", sources);
+ FileContentHandler fileContentHandler = new FileContentHandler();
+ fileContentHandler.addFile("Artifacts/Deployment/test.xml", new byte[1]);
+ Manifest manifest = mock(Manifest.class);
+ when(manifest.getNonManoSources()).thenReturn(nonManoSources);
+ etsiService.moveNonManoFileToArtifactFolder(fileContentHandler, manifest);
+ assertTrue(fileContentHandler.containsFile(finalNonManoLocation));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/resources/nonManoConfig.yaml b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/resources/nonManoConfig.yaml
new file mode 100644
index 0000000000..32c6b1ce57
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/resources/nonManoConfig.yaml
@@ -0,0 +1,7 @@
+nonManoKeyFolderMapping:
+ Some:
+ location: VES_EVENTS
+ type: Deployment
+ Other:
+ location: VES_EVENTS
+ type: Informational \ No newline at end of file