Update the CsarInfoTest. 75/89675/5
authork.kedron <k.kedron@partner.samsung.com>
Tue, 11 Jun 2019 08:46:26 +0000 (10:46 +0200)
committerk.kedron <k.kedron@partner.samsung.com>
Fri, 14 Jun 2019 14:48:51 +0000 (16:48 +0200)
Used common ZipUtil.readData instead local load method.
Fix checkstyle (variable named).

Issue-ID: SDC-2327
Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
Change-Id: I6adaed83e45d43268b174fde0ba6ee991e3fb2b0

catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java

index 3c9ae07..3ae65c8 100644 (file)
@@ -27,9 +27,6 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -44,7 +41,7 @@ import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentEx
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.model.NodeTypeInfo;
 import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.common.util.ZipUtil;
+import org.openecomp.sdc.ZipUtil;
 
 @RunWith(MockitoJUnitRunner.class)
 public class CsarInfoTest {
@@ -55,7 +52,7 @@ public class CsarInfoTest {
     private User user;
 
     private static final String CSAR_UUID = "csarUUID";
-    private static final String PAYLOAD_NAME = "mock_service.csar";
+    private static final String PAYLOAD_NAME = "/mock_service.csar";
     private static final String RESOURCE_NAME = "resourceName";
     private static final String MAIN_TEMPLATE_NAME = "Definitions/tosca_mock_vf.yaml";
 
@@ -67,11 +64,11 @@ public class CsarInfoTest {
     public void setup() throws IOException, URISyntaxException {
 
         // given
-        Map<String, byte[]> payload = loadPayload(PAYLOAD_NAME);
-        String main_template_content = new String(payload.get(MAIN_TEMPLATE_NAME));
+        Map<String, byte[]> payload = ZipUtil.readData(PAYLOAD_NAME);
+        String mainTemplateContent = new String(payload.get(MAIN_TEMPLATE_NAME));
 
         csarInfo = new CsarInfo(user, CSAR_UUID, payload, RESOURCE_NAME,
-                MAIN_TEMPLATE_NAME, main_template_content, true);
+                MAIN_TEMPLATE_NAME, mainTemplateContent, true);
     }
 
     @Test
@@ -115,12 +112,4 @@ public class CsarInfoTest {
         assertEquals(MAIN_TEMPLATE_NAME, csarInfo.getMainTemplateName());
         assertEquals(csarInfo.getMainTemplateName(), nodeTypeInfo.getTemplateFileName());
     }
-
-    private Map<String, byte[]> loadPayload(String payloadName) throws IOException, URISyntaxException {
-
-        Path path = Paths.get(getClass().getResource("/" + payloadName).toURI());
-        byte[] data = Files.readAllBytes(path);
-
-        return ZipUtil.readZip(data);
-    }
 }