aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java10
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileContentHandler.java52
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java10
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java53
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java13
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/DuplicateResourceIdsInDifferentFilesErrorBuilder.java16
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java19
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java13
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java76
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java14
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java21
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java35
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java177
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java48
23 files changed, 391 insertions, 239 deletions
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
index 1c5293004d..72485d7162 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
@@ -42,6 +42,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -67,7 +68,7 @@ public class CommonUtil {
throws IOException {
Pair<FileContentHandler,List<String> > pair = getFileContentMapFromOrchestrationCandidateZip(uploadFileData);
- if(type.equals(OnboardingTypesEnum.ZIP)) {
+ if(isFileOriginFromZip(type.toString())) {
validateNoFolders(pair.getRight());
}
@@ -133,7 +134,7 @@ public class CommonUtil {
return -1;
}
- public static boolean validateFilesExtensions(Set<String> allowedExtensions, FileContentHandler
+ private static boolean validateFilesExtensions(Set<String> allowedExtensions, FileContentHandler
files) {
for (String fileName : files.getFileList()) {
if (!allowedExtensions.contains(FilenameUtils.getExtension(fileName))) {
@@ -147,4 +148,9 @@ public class CommonUtil {
Set<String> allowedExtensions = new HashSet<>(Arrays.asList("yml", "yaml"));
return validateFilesExtensions(allowedExtensions, files);
}
+
+ public static boolean isFileOriginFromZip(String fileOrigin){
+ return Objects.nonNull(fileOrigin)
+ && fileOrigin.toLowerCase().equals(OnboardingTypesEnum.ZIP.toString());
+ }
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileContentHandler.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileContentHandler.java
index 8de222e688..d5cd56e058 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileContentHandler.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileContentHandler.java
@@ -23,10 +23,13 @@ package org.openecomp.core.utilities.file;
import org.apache.commons.collections4.MapUtils;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
+import java.util.function.Function;
public class FileContentHandler {
@@ -45,12 +48,31 @@ public class FileContentHandler {
return null;
}
- ByteArrayInputStream is = new ByteArrayInputStream(content);
- return is;
+ return new ByteArrayInputStream(content);
}
- public void addFile(String fileName, byte[] contect) {
- files.put(fileName, contect);
+ /**
+ * Applies a business logic to a file's content while taking care of all retrieval logic.
+ *
+ * @param fileName name of a file inside this content handler.
+ * @param processor the business logic to work on the file's input stream, which may not be set
+ * (check the {@link Optional} if no such file can be found
+ * @param <T> return type, may be {@link java.lang.Void}
+ *
+ * @return result produced by the processor
+ */
+ public <T> T processFileContent(String fileName, Function<Optional<InputStream>, T> processor) {
+
+ // do not throw IOException to mimic the existing uses of getFileContent()
+ try (InputStream contentInputStream = getFileContent(fileName)) {
+ return processor.apply(Optional.ofNullable(contentInputStream));
+ } catch (IOException e) {
+ throw new ProcessingException("Failed to process file: " + fileName, e);
+ }
+ }
+
+ public void addFile(String fileName, byte[] content) {
+ files.put(fileName, content);
}
public void addFile(String fileName, InputStream is) {
@@ -94,4 +116,26 @@ public class FileContentHandler {
public boolean containsFile(String fileName) {
return files.containsKey(fileName);
}
+
+ /**
+ * An application-specific runtime exception
+ */
+ private static class ProcessingException extends RuntimeException {
+
+ public ProcessingException() {
+ super();
+ }
+
+ public ProcessingException(String message) {
+ super(message);
+ }
+
+ public ProcessingException(Throwable cause) {
+ super(cause);
+ }
+
+ public ProcessingException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+ }
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
index 04e64c33a9..85fe305060 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
@@ -20,13 +20,11 @@ public enum OnboardingTypesEnum {
if (inStr == null) {
return null;
}
+
Optional<OnboardingTypesEnum> onboardingTypesOptional = asList(OnboardingTypesEnum.values()).stream()
- .filter(onboardingTypesEnum -> onboardingTypesEnum.toString().equals(inStr)).findAny();
- if( onboardingTypesOptional.isPresent()){
- return onboardingTypesOptional.get();
- }else {
- return null;
- }
+ .filter(onboardingTypesEnum -> onboardingTypesEnum.toString().equals(inStr.toLowerCase()))
+ .findAny();
+ return onboardingTypesOptional.orElse(null);
}
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java
new file mode 100644
index 0000000000..527ba22c1d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java
@@ -0,0 +1,53 @@
+package org.openecomp.core.utilities.file;
+
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Optional;
+
+import static org.testng.Assert.*;
+
+/**
+ * @author EVITALIY
+ * @since 24 Oct 17
+ */
+public class FileContentHandlerTest {
+
+ private static final String FILE_NAME = "test-file.txt";
+
+ @Test
+ public void testProcessFileContent() throws Exception {
+
+ final int size = 13;
+ FileContentHandler contentHandler = new FileContentHandler();
+ final byte[] content = new byte[size];
+ Arrays.fill(content, (byte) 44);
+ contentHandler.addFile(FILE_NAME, content);
+ assertEquals(contentHandler.processFileContent(FILE_NAME, optional -> {
+
+ try {
+ byte[] buffer = new byte[size];
+ assertTrue(optional.isPresent());
+ assertEquals(size, optional.get().read(buffer));
+ return buffer;
+ } catch (IOException e) {
+ throw new RuntimeException("Unexpected error", e);
+ }
+
+ }), content);
+ }
+
+ @Test
+ public void testProcessEmptyFileContent() throws Exception {
+ FileContentHandler contentHandler = new FileContentHandler();
+ contentHandler.addFile(FILE_NAME, new byte[0]);
+ assertFalse(contentHandler.processFileContent(FILE_NAME, Optional::isPresent));
+ }
+
+ @Test
+ public void testProcessNoFileContent() throws Exception {
+ FileContentHandler contentHandler = new FileContentHandler();
+ assertFalse(contentHandler.processFileContent("filename", Optional::isPresent));
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java
index fc01e2e8b0..6312e5a575 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java
@@ -23,16 +23,18 @@ package org.openecomp.sdc.heat.datatypes.model;
import org.junit.Test;
import org.openecomp.sdc.tosca.services.YamlUtil;
+import java.io.IOException;
import java.io.InputStream;
public class EnvironmentTest {
@Test
- public void testYamlToServiceTemplateObj() {
+ public void testYamlToServiceTemplateObj() throws IOException {
YamlUtil yamlUtil = new YamlUtil();
- InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/envSettings.env");
- Environment envVars = yamlUtil.yamlToObject(yamlFile, Environment.class);
- envVars.toString();
+ try (InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/envSettings.env")) {
+ Environment envVars = yamlUtil.yamlToObject(yamlFile, Environment.class);
+ envVars.toString();
+ }
}
@Test
@@ -46,9 +48,8 @@ public class EnvironmentTest {
if (heatResourceName.length() == lastIndexOfUnderscore) {
System.out.println(heatResourceName);
} else {
- String heatResourceNameSuffix = heatResourceName.substring(lastIndexOfUnderscore + 1);
+
try {
- int heatResourceNameSuffixInt = Integer.parseInt(heatResourceNameSuffix);
System.out.println(heatResourceName.substring(0, lastIndexOfUnderscore));
} catch (NumberFormatException ignored) {
System.out.println(heatResourceName);
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java
index 3715b0f999..dd8abdc0b9 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java
@@ -26,6 +26,7 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.services.YamlUtil;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
@@ -37,12 +38,13 @@ public class HeatOrchestrationTemplateTest {
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
@Test
- public void testYamlToServiceTemplateObj() {
+ public void testYamlToServiceTemplateObj() throws IOException {
YamlUtil yamlUtil = new YamlUtil();
- InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/testHeat.yml");
- HeatOrchestrationTemplate heatOrchestrationTemplate =
- yamlUtil.yamlToObject(yamlFile, HeatOrchestrationTemplate.class);
- heatOrchestrationTemplate.toString();
+ try (InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/testHeat.yml")) {
+ HeatOrchestrationTemplate heatOrchestrationTemplate =
+ yamlUtil.yamlToObject(yamlFile, HeatOrchestrationTemplate.class);
+ heatOrchestrationTemplate.toString();
+ }
}
@Test
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
index a0034a3828..ddbcaf72b9 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
@@ -25,14 +25,12 @@ import org.openecomp.config.api.ConfigurationManager;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
-import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
@@ -42,6 +40,7 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida
import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
import org.openecomp.sdc.translator.services.heattotosca.Constants;
import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
+import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
import java.io.InputStream;
@@ -385,10 +384,7 @@ public class TranslationContext {
}
if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + originalNodeTemplateId + " occures more than once in different addOn files")
- .build());
+ throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(originalNodeTemplateId).build());
}
nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
index b86038d175..5d1bb1c61e 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
@@ -31,6 +31,7 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.RequirementAssignmentData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData;
+import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
import java.util.ArrayList;
import java.util.Collection;
@@ -154,10 +155,7 @@ public class ConsolidationDataUtil {
if(isNestedResourceIdOccuresInDifferentNestedFiles(context, nestedHeatFileName,
nestedNodeTemplateId)){
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + nestedNodeTemplateId + " occures more than once in different addOn "
- + "files").build());
+ throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(nestedNodeTemplateId).build());
}
ConsolidationData consolidationData = context.getConsolidationData();
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
index 16a6301968..d3f2a721c9 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
@@ -24,6 +24,7 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.RequirementAssignmentData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData;
+import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
import java.util.ArrayList;
import java.util.Collection;
@@ -637,20 +638,16 @@ public class ConsolidationService {
NodeTemplate startingPortNodeTemplate = nodeTemplates.get(portNodeTemplateIdList.get(0));
if (Objects.isNull(startingPortNodeTemplate)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + portNodeTemplateIdList.get(0) + " occures more than once in different addOn files")
- .build());
+ throw new CoreException(
+ new DuplicateResourceIdsInDifferentFilesErrorBuilder(portNodeTemplateIdList.get(0)).build());
}
for (int i = 1; i < portNodeTemplateIdList.size(); i++) {
NodeTemplate portNodeTemplate = nodeTemplates.get(portNodeTemplateIdList.get(i));
if (Objects.isNull(portNodeTemplate)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + portNodeTemplateIdList.get(i) + " occures more than once in different addOn "
- + "files").build());
+ throw new CoreException(
+ new DuplicateResourceIdsInDifferentFilesErrorBuilder(portNodeTemplateIdList.get(i)).build());
}
if (!isPropertySimilarBetweenNodeTemplates(propertyToCheck, portNodeTemplateIdList, nodeTemplates)) {
@@ -695,9 +692,8 @@ public class ConsolidationService {
for (int i = 1; i < entityNodeTemplateIds.size(); i++) {
NodeTemplate currentNodeTemplate = idToNodeTemplate.get(entityNodeTemplateIds.get(i));
if (Objects.isNull(currentNodeTemplate)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + entityNodeTemplateIds.get(i) + " occures more than once in different addOn files").build());
+ throw new CoreException(
+ new DuplicateResourceIdsInDifferentFilesErrorBuilder(entityNodeTemplateIds.get(i)).build());
}
if(propertyExistCondition != isPropertyExistInNodeTemplate(propertyToCheck, currentNodeTemplate)){
return false;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/DuplicateResourceIdsInDifferentFilesErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/DuplicateResourceIdsInDifferentFilesErrorBuilder.java
new file mode 100644
index 0000000000..a75e8b391d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/DuplicateResourceIdsInDifferentFilesErrorBuilder.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.translator.services.heattotosca.errors;
+
+import org.openecomp.sdc.common.errors.BaseErrorBuilder;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+
+public final class DuplicateResourceIdsInDifferentFilesErrorBuilder extends BaseErrorBuilder {
+
+ private static final String DUPLICATE_RESOURCE_ID_MSG = "Resource with id %s occurs more than once in " +
+ "different addOn files";
+
+ public DuplicateResourceIdsInDifferentFilesErrorBuilder(String resourceId) {
+ getErrorCodeBuilder().withId(TranslatorErrorCodes.DUPLICATE_RESOURCE_ID_IN_DIFFERENT_FILES)
+ .withCategory(ErrorCategory.APPLICATION)
+ .withMessage(String.format(DUPLICATE_RESOURCE_ID_MSG, resourceId));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java
index bfcf834ae1..5afb1ae3c2 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java
@@ -29,4 +29,5 @@ public class TranslatorErrorCodes {
"REFERENCE_TO_UNSUPPORTED_RESOURCE";
public static final String NOT_IN_SYNC_NUMBER_OF_INTERFACES = "NOT_IN_SYNC_NUMBER_OF_INTERFACES";
public static final String INVALID_PROPERTY_VALUE = "INVALID_PROPERTY_VALUE";
+ public static final String DUPLICATE_RESOURCE_ID_IN_DIFFERENT_FILES = "DUPLICATE_RESOURCE_ID_IN_DIFFERENT_FILES";
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java
index b1946b3f9b..9399b91ce1 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java
@@ -2,7 +2,10 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.fulltest;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseFullTranslationTest;
@@ -19,6 +22,9 @@ public class UnifiedCompositionMixPatternFullTest extends BaseFullTranslationTes
// do not delete this function. it prevents the superclass setup from running
}
+ @Rule
+ public ExpectedException exception = ExpectedException.none();
+
@Test
public void testMixPatterns() throws IOException {
inputFilesPath =
@@ -52,16 +58,13 @@ public class UnifiedCompositionMixPatternFullTest extends BaseFullTranslationTes
@Test
public void testDuplicateResourceIdsInDiffAddOnFiles() throws IOException {
+ exception.expect(CoreException.class);
+ exception.expectMessage("Resource with id lb_0_int_oam_int_0_port occurs more " +
+ "than once in different addOn files");
+
inputFilesPath =
"/mock/services/heattotosca/fulltest/mixPatterns/duplicateResourceIdsInDiffAddOnFiles/in";
-
- try {
- testTranslationWithInit();
- }catch(Exception e){
- log.debug("",e);
- Assert.assertEquals(e.getMessage(), "Resource with id lb_0_int_oam_int_0_port occures more " +
- "than once in different addOn files");
- }
+ testTranslationWithInit();
}
@Test
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
index ccadeced62..3f9768b9d7 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
@@ -26,6 +26,7 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
import java.util.List;
+import java.util.Objects;
public class VspDetails implements VersionableEntity {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
index f7ca6463cb..dd303c7bb9 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
@@ -53,7 +53,7 @@ public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
private static final String DESCRIPTION = "DESCRIPTION";
private static final String NESTED_PATTERN = "NESTED_PATTERN";
- private Map<String, Pattern> patterns;
+ private final Map<String, Pattern> patterns;
public HeatFileAnalyzerRowDataImpl() {
patterns = new HashMap<>();
@@ -72,16 +72,17 @@ public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
throws IOException {
AnalyzedZipHeatFiles analyzedZipHeatFiles = new AnalyzedZipHeatFiles();
- BufferedReader bfReader;
for (Map.Entry<String, byte[]> fileData : files.entrySet()) {
String fileName = fileData.getKey();
if (!HeatFileAnalyzer.isYamlFile(fileName)) {
analyzedZipHeatFiles.addOtherNonModuleFile(fileName);
continue;
}
+
boolean foundHeatIdentifier = false;
- try (InputStream is = new ByteArrayInputStream(fileData.getValue())) {
- bfReader = new BufferedReader(new InputStreamReader(is));
+ try (InputStream is = new ByteArrayInputStream(fileData.getValue());
+ BufferedReader bfReader = new BufferedReader(new InputStreamReader(is))) {
+
String line;
boolean isResourcesSection = false;
Set<String> nestedFilesNames = new HashSet<>();
@@ -108,11 +109,9 @@ public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
}
analyzedZipHeatFiles.addNestedFiles(fetchFileNamesToReturn(nestedFilesNames,
foundHeatIdentifier));
- if (Objects.nonNull(bfReader)) {
- bfReader.close();
- }
}
}
+
return analyzedZipHeatFiles;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
index ca5329344b..41510ecc13 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
@@ -38,6 +38,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.impl.HeatFileAnalyzerRow
import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.AnalyzedZipHeatFiles;
+import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
@@ -45,8 +46,10 @@ import java.util.Objects;
import java.util.Optional;
public class CandidateEntityBuilder {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private CandidateService candidateService;
+
+ private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
+
+ private final CandidateService candidateService;
public CandidateEntityBuilder(CandidateService candidateService) {
this.candidateService = candidateService;
@@ -57,35 +60,28 @@ public class CandidateEntityBuilder {
Map<String, List<ErrorMessage>> uploadErrors, String user) throws Exception {
//mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
- InputStream zipFileManifest = contentMap.getFileContent(SdcCommon.MANIFEST_NAME);
- HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl();
- AnalyzedZipHeatFiles analyzedZipHeatFiles =
- heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
- HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles);
+ try (InputStream zipFileManifest = contentMap.getFileContent(SdcCommon.MANIFEST_NAME)) {
+ HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl();
+ AnalyzedZipHeatFiles analyzedZipHeatFiles =
+ heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
+ HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles);
- CandidateDataEntityTo candidateDataEntityTo =
- new CandidateDataEntityTo(vspDetails.getId(), user, uploadedFileData, tree, contentMap,
- vspDetails.getVersion());
- candidateDataEntityTo.setErrors(uploadErrors);
- OrchestrationTemplateCandidateData candidateDataEntity =
- candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
- analyzedZipHeatFiles);
+ CandidateDataEntityTo candidateDataEntityTo =
+ new CandidateDataEntityTo(vspDetails.getId(), user, uploadedFileData, tree, contentMap,
+ vspDetails.getVersion());
+ candidateDataEntityTo.setErrors(uploadErrors);
+ OrchestrationTemplateCandidateData candidateDataEntity =
+ candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
+ analyzedZipHeatFiles);
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
- return candidateDataEntity;
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP Id", vspDetails.getId());
+ return candidateDataEntity;
+ }
}
-// public OrchestrationTemplateCandidateData buildOrchestrationTemplateFromCsar(VspDetails vspDetails,
-// byte[] uploadedFileData,
-// FileContentHandler contentMap,
-// Map<String, List<ErrorMessage>> uploadErrors,
-// String user){
-//
-// }
-
private HeatStructureTree getHeatStructureTree(VspDetails vspDetails,
FileContentHandler contentMap,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) {
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles);
HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap);
heatTreeManager.createTree();
@@ -94,22 +90,24 @@ public class CandidateEntityBuilder {
private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails,
FileContentHandler fileContentHandler,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) {
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP Id", vspDetails.getId());
+
+ try (InputStream manifest = fileContentHandler.getFileContent(SdcCommon.MANIFEST_NAME)) {
- InputStream manifest = fileContentHandler.getFileContent(SdcCommon.MANIFEST_NAME);
- if (Objects.isNull(manifest)) {
- Optional<ManifestContent> manifestContentOptional =
- candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
- if (!manifestContentOptional.isPresent()) {
- throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
+ if (Objects.isNull(manifest)) {
+ Optional<ManifestContent> manifestContentOptional =
+ candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
+ if (!manifestContentOptional.isPresent()) {
+ throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
+ }
+ ManifestContent manifestContent = manifestContentOptional.get();
+ fileContentHandler.addFile(
+ SdcCommon.MANIFEST_NAME,
+ String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
}
- ManifestContent manifestContent = manifestContentOptional.get();
- fileContentHandler.addFile(
- SdcCommon.MANIFEST_NAME,
- String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
+ } finally {
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP Id", vspDetails.getId());
}
-
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java
new file mode 100644
index 0000000000..6545ca1fdd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilder.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_EXTENSION;
+
+public class OrchestrationTemplateFileExtensionErrorBuilder {
+ private static final String INVALID_EXTENSION_MSG = "Invalid file extension. Valid extensions " +
+ "are : zip, csar.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public OrchestrationTemplateFileExtensionErrorBuilder(){
+ builder.withId(INVALID_EXTENSION);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_EXTENSION_MSG));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
index da64f5a2e5..d3c2a22fff 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
@@ -127,4 +127,6 @@ public class VendorSoftwareProductErrorCodes {
public static final String DELETE_IMAGE_NOT_ALLOWED = "DELETE_IMAGE_NOT_ALLOWED";
public static final String UPDATE_IMAGE_NOT_ALLOWED = "UPDATE_IMAGE_NOT_ALLOWED";
+ public static final String INVALID_EXTENSION = "INVALID_EXTENSION";
+
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java
index 323bd8a5fb..d17f79bb6c 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/datatypes/CsarFileTypes.java
@@ -5,5 +5,6 @@ public enum CsarFileTypes {
globalServiceTemplate,
externalFile,
toscaMetadata,
- definitionsFile,;
+ definitionsFile,
+ Artifacts;
}
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 348739e780..9b694c5207 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
@@ -54,7 +54,8 @@ public class ToscaConverterImpl implements ToscaConverter {
break;
case externalFile:
- artifacts.addFile(fileEntry.getKey(), fileEntry.getValue());
+ artifacts.addFile(
+ getConcreteArtifactFileName(fileEntry.getKey()), fileEntry.getValue());
break;
case definitionsFile:
@@ -94,6 +95,17 @@ public class ToscaConverterImpl implements ToscaConverter {
}
}
+ private String getConcreteArtifactFileName(String fileName){
+ int artifactIndex = fileName.indexOf(CsarFileTypes.Artifacts.name());
+ if(artifactIndex < 0){
+ return fileName;
+ }
+
+ int artifactDirectoryIndex =
+ artifactIndex + CsarFileTypes.Artifacts.name().length() + 1;
+ return fileName.substring(artifactDirectoryIndex);
+ }
+
private void updateToscaServiceModel(ToscaServiceModel toscaServiceModel,
Map<String, ServiceTemplate> serviceTemplates,
FileContentHandler externalFilesHandler,
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
index f29ca4a427..471e3891c7 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
@@ -41,22 +41,18 @@ public class ToscaConverterImplTest {
private static final String VIRTUAL_LINK = "virtualLink";
private static final String UNBOUNDED = "UNBOUNDED";
- private static String inputFilesPath;
- private static String outputFilesPath;
- private static Map<String, ServiceTemplate> expectedOutserviceTemplates;
-
@Test
public void testConvertMainSt() throws IOException {
- inputFilesPath = "/mock/toscaConverter/convertMainSt/in";
- outputFilesPath = "/mock/toscaConverter/convertMainSt/out";
+ String inputFilesPath = "/mock/toscaConverter/convertMainSt/in";
+ String outputFilesPath = "/mock/toscaConverter/convertMainSt/out";
FileContentHandler fileContentHandler =
createFileContentHandlerFromInput(inputFilesPath);
- expectedOutserviceTemplates = new HashMap<>();
+ Map<String, ServiceTemplate> expectedOutserviceTemplates = new HashMap<>();
loadServiceTemplates(outputFilesPath, new ToscaExtensionYamlUtil(),
- expectedOutserviceTemplates);
+ expectedOutserviceTemplates);
ToscaServiceModel toscaServiceModel = toscaConverter.convert(fileContentHandler);
ServiceTemplate mainSt = toscaServiceModel.getServiceTemplates().get(mainStName);
@@ -201,18 +197,15 @@ public class ToscaConverterImplTest {
private static void addServiceTemplateFiles(Map<String, ServiceTemplate> serviceTemplates,
File[] files,
- ToscaExtensionYamlUtil toscaExtensionYamlUtil)
- throws IOException {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil) throws IOException {
+
for (File file : files) {
+
try (InputStream yamlFile = new FileInputStream(file)) {
ServiceTemplate serviceTemplateFromYaml =
toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml, toscaExtensionYamlUtil);
serviceTemplates.put(file.getName(), serviceTemplateFromYaml);
- try {
- yamlFile.close();
- } catch (IOException ignore) {
- }
}
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
index c7f4e3f6d1..e8c9c602f8 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java
@@ -46,6 +46,7 @@ import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.tosca.services.YamlUtil;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
@@ -271,27 +272,29 @@ public class ToscaModelTest {
@Test
- public void testYamlToServiceTemplateObj() {
- InputStream yamlFile = new YamlUtil().loadYamlFileIs("/mock/model/serviceTemplate.yaml");
- ServiceTemplate serviceTemplateFromYaml =
- new YamlUtil().yamlToObject(yamlFile, ServiceTemplate.class);
- Assert.assertNotNull(serviceTemplateFromYaml);
+ public void testYamlToServiceTemplateObj() throws IOException {
+ try (InputStream yamlFile = new YamlUtil().loadYamlFileIs("/mock/model/serviceTemplate.yaml")) {
+ ServiceTemplate serviceTemplateFromYaml =
+ new YamlUtil().yamlToObject(yamlFile, ServiceTemplate.class);
+ Assert.assertNotNull(serviceTemplateFromYaml);
+ }
}
@Test
- public void testYamlToServiceTemplateIncludingHeatExtend() {
+ public void testYamlToServiceTemplateIncludingHeatExtend() throws IOException {
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- InputStream yamlFile =
- toscaExtensionYamlUtil.loadYamlFileIs("/mock/model/serviceTemplateHeatExtend.yaml");
- ServiceTemplate serviceTemplateFromYaml =
- toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
- ParameterDefinitionExt parameterDefinitionExt =
- (ParameterDefinitionExt) serviceTemplateFromYaml.getTopology_template().getInputs()
- .get("inParam1");
- Assert.assertNotNull(parameterDefinitionExt.getLabel());
- String backToYamlString = toscaExtensionYamlUtil.objectToYaml(serviceTemplateFromYaml);
- Assert.assertNotNull(backToYamlString);
+ try (InputStream yamlFile =
+ toscaExtensionYamlUtil.loadYamlFileIs("/mock/model/serviceTemplateHeatExtend.yaml")) {
+ ServiceTemplate serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ ParameterDefinitionExt parameterDefinitionExt =
+ (ParameterDefinitionExt) serviceTemplateFromYaml.getTopology_template().getInputs()
+ .get("inParam1");
+ Assert.assertNotNull(parameterDefinitionExt.getLabel());
+ String backToYamlString = toscaExtensionYamlUtil.objectToYaml(serviceTemplateFromYaml);
+ Assert.assertNotNull(backToYamlString);
+ }
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
index 7ae91abfa5..aad21634a8 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
@@ -78,9 +78,9 @@ public class ToscaAnalyzerServiceImplTest {
public ExpectedException thrown = ExpectedException.none();
@Mock
- NodeTemplate nodeTemplateMock;
+ private NodeTemplate nodeTemplateMock;
@Mock
- ToscaServiceModel toscaServiceModelMock;
+ private ToscaServiceModel toscaServiceModelMock;
@BeforeClass
public static void onlyOnceSetUp() throws IOException {
@@ -97,27 +97,29 @@ public class ToscaAnalyzerServiceImplTest {
@Test
public void testGetRequirements() throws Exception {
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- InputStream yamlFile = toscaExtensionYamlUtil
- .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml");
- ServiceTemplate
- serviceTemplateFromYaml =
- toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
-
- NodeTemplate port_0 =
- serviceTemplateFromYaml.getTopology_template().getNode_templates().get("cmaui_port_0");
- List<RequirementAssignment> reqList =
- toscaAnalyzerService.getRequirements(port_0, ToscaConstants.BINDING_REQUIREMENT_ID);
- assertEquals(1, reqList.size());
-
- reqList.clear();
- NodeTemplate port_1 =
- serviceTemplateFromYaml.getTopology_template().getNode_templates().get("cmaui1_port_1");
- reqList = toscaAnalyzerService.getRequirements(port_1, ToscaConstants.LINK_REQUIREMENT_ID);
- assertEquals(2, reqList.size());
-
- reqList.clear();
- reqList = toscaAnalyzerService.getRequirements(port_0, ToscaConstants.LINK_REQUIREMENT_ID);
- assertEquals(0, reqList.size());
+ try (InputStream yamlFile = toscaExtensionYamlUtil
+ .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml")) {
+
+ ServiceTemplate
+ serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+
+ NodeTemplate port_0 =
+ serviceTemplateFromYaml.getTopology_template().getNode_templates().get("cmaui_port_0");
+ List<RequirementAssignment> reqList =
+ toscaAnalyzerService.getRequirements(port_0, ToscaConstants.BINDING_REQUIREMENT_ID);
+ assertEquals(1, reqList.size());
+
+ reqList.clear();
+ NodeTemplate port_1 =
+ serviceTemplateFromYaml.getTopology_template().getNode_templates().get("cmaui1_port_1");
+ reqList = toscaAnalyzerService.getRequirements(port_1, ToscaConstants.LINK_REQUIREMENT_ID);
+ assertEquals(2, reqList.size());
+
+ reqList.clear();
+ reqList = toscaAnalyzerService.getRequirements(port_0, ToscaConstants.LINK_REQUIREMENT_ID);
+ assertEquals(0, reqList.size());
+ }
}
@Test
@@ -171,44 +173,45 @@ public class ToscaAnalyzerServiceImplTest {
.getSubstituteServiceTemplateName("invalid1", invalidSubstitutableNodeTemplate1);
assertEquals(false, substituteServiceTemplateName.isPresent());
- if (substitutableNodeTemplate.isPresent()) {
- NodeTemplate invalidSubstitutableNodeTemplate2 = substitutableNodeTemplate.get();
- Object serviceTemplateFilter = invalidSubstitutableNodeTemplate2.getProperties()
- .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
+ substitutableNodeTemplate.ifPresent(nodeTemplate -> {
+ Object serviceTemplateFilter = nodeTemplate.getProperties()
+ .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
((Map) serviceTemplateFilter).clear();
toscaAnalyzerService
- .getSubstituteServiceTemplateName("invalid2", invalidSubstitutableNodeTemplate2);
+ .getSubstituteServiceTemplateName("invalid2", nodeTemplate);
- }
+ });
}
@Test
public void testGetSubstitutableNodeTemplates() throws Exception {
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- InputStream yamlFile = toscaExtensionYamlUtil
- .loadYamlFileIs("/mock/analyzerService/ServiceTemplateSubstituteTest.yaml");
- ServiceTemplate serviceTemplateFromYaml =
- toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
-
- Map<String, NodeTemplate> substitutableNodeTemplates =
- toscaAnalyzerService.getSubstitutableNodeTemplates(serviceTemplateFromYaml);
- assertEquals(2, substitutableNodeTemplates.size());
- assertNotNull(substitutableNodeTemplates.get("test_nested1"));
- assertNotNull(substitutableNodeTemplates.get("test_nested2"));
+ try (InputStream yamlFile = toscaExtensionYamlUtil
+ .loadYamlFileIs("/mock/analyzerService/ServiceTemplateSubstituteTest.yaml")) {
+ ServiceTemplate serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+
+ Map<String, NodeTemplate> substitutableNodeTemplates =
+ toscaAnalyzerService.getSubstitutableNodeTemplates(serviceTemplateFromYaml);
+ assertEquals(2, substitutableNodeTemplates.size());
+ assertNotNull(substitutableNodeTemplates.get("test_nested1"));
+ assertNotNull(substitutableNodeTemplates.get("test_nested2"));
+
+ ServiceTemplate emptyServiceTemplate = new ServiceTemplate();
+ emptyServiceTemplate.setTopology_template(new TopologyTemplate());
+ substitutableNodeTemplates =
+ toscaAnalyzerService.getSubstitutableNodeTemplates(emptyServiceTemplate);
+ assertEquals(0, substitutableNodeTemplates.size());
+ }
- ServiceTemplate emptyServiceTemplate = new ServiceTemplate();
- emptyServiceTemplate.setTopology_template(new TopologyTemplate());
- substitutableNodeTemplates =
- toscaAnalyzerService.getSubstitutableNodeTemplates(emptyServiceTemplate);
- assertEquals(0, substitutableNodeTemplates.size());
-
- yamlFile = toscaExtensionYamlUtil
- .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml");
- serviceTemplateFromYaml = toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
- substitutableNodeTemplates =
- toscaAnalyzerService.getSubstitutableNodeTemplates(serviceTemplateFromYaml);
- assertEquals(0, substitutableNodeTemplates.size());
+ try (InputStream yamlFile = toscaExtensionYamlUtil
+ .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml")) {
+ ServiceTemplate serviceTemplateFromYaml = toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ Map<String, NodeTemplate> substitutableNodeTemplates =
+ toscaAnalyzerService.getSubstitutableNodeTemplates(serviceTemplateFromYaml);
+ assertEquals(0, substitutableNodeTemplates.size());
+ }
}
@Test
@@ -217,35 +220,36 @@ public class ToscaAnalyzerServiceImplTest {
thrown.expectMessage(
"Invalid Tosca model data, missing 'Node Template' entry for 'Node Template' id cmaui_port_9");
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- InputStream yamlFile = toscaExtensionYamlUtil
- .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml");
- ServiceTemplate nestedServiceTemplateFromYaml =
- toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
-
- Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService
- .getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml",
- nestedServiceTemplateFromYaml, "local_storage_server_cmaui");
- assertEquals(true, mappedNodeTemplate.isPresent());
- if (mappedNodeTemplate.isPresent()) {
- assertEquals("server_cmaui", mappedNodeTemplate.get().getKey());
- assertNotNull(mappedNodeTemplate.get().getValue());
+ try (InputStream yamlFile = toscaExtensionYamlUtil
+ .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml")) {
+ ServiceTemplate nestedServiceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+
+ Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService
+ .getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml",
+ nestedServiceTemplateFromYaml, "local_storage_server_cmaui");
+ assertEquals(true, mappedNodeTemplate.isPresent());
+ mappedNodeTemplate.ifPresent(stringNodeTemplateEntry -> {
+ assertEquals("server_cmaui", stringNodeTemplateEntry.getKey());
+ assertNotNull(stringNodeTemplateEntry.getValue());
+ });
+
+ mappedNodeTemplate = toscaAnalyzerService
+ .getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml",
+ nestedServiceTemplateFromYaml, "link_cmaui_port_invalid");
+ assertEquals(true, mappedNodeTemplate.isPresent());
+ mappedNodeTemplate.ifPresent(stringNodeTemplateEntry -> {
+ assertEquals("server_cmaui", stringNodeTemplateEntry.getKey());
+ assertNotNull(stringNodeTemplateEntry.getValue());
+ });
+
+ ServiceTemplate mainServiceTemplate = toscaServiceModel.getServiceTemplates()
+ .get(toscaServiceModel.getEntryDefinitionServiceTemplate());
+ mappedNodeTemplate = toscaAnalyzerService.getSubstitutionMappedNodeTemplateByExposedReq(
+ toscaServiceModel.getEntryDefinitionServiceTemplate(), mainServiceTemplate,
+ "local_storage_server_cmaui");
+ assertEquals(false, mappedNodeTemplate.isPresent());
}
-
- mappedNodeTemplate = toscaAnalyzerService
- .getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml",
- nestedServiceTemplateFromYaml, "link_cmaui_port_invalid");
- assertEquals(true, mappedNodeTemplate.isPresent());
- if (mappedNodeTemplate.isPresent()) {
- assertEquals("server_cmaui", mappedNodeTemplate.get().getKey());
- assertNotNull(mappedNodeTemplate.get().getValue());
- }
-
- ServiceTemplate mainServiceTemplate = toscaServiceModel.getServiceTemplates()
- .get(toscaServiceModel.getEntryDefinitionServiceTemplate());
- mappedNodeTemplate = toscaAnalyzerService.getSubstitutionMappedNodeTemplateByExposedReq(
- toscaServiceModel.getEntryDefinitionServiceTemplate(), mainServiceTemplate,
- "local_storage_server_cmaui");
- assertEquals(false, mappedNodeTemplate.isPresent());
}
@Test
@@ -283,14 +287,15 @@ public class ToscaAnalyzerServiceImplTest {
thrown.expectMessage(
"Invalid Tosca model data, missing 'Node Template' entry for 'Node Template' id cmaui_port_9");
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- InputStream yamlFile = toscaExtensionYamlUtil
- .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml");
- ServiceTemplate nestedServiceTemplateFromYaml =
- toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+ try (InputStream yamlFile = toscaExtensionYamlUtil
+ .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml")) {
+ ServiceTemplate nestedServiceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
- toscaAnalyzerService
- .getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml",
- nestedServiceTemplateFromYaml, "link_cmaui_port_invalid");
+ toscaAnalyzerService
+ .getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml",
+ nestedServiceTemplateFromYaml, "link_cmaui_port_invalid");
+ }
}
@Test
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
index 4d025e1540..66dda12b4b 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
@@ -41,7 +41,7 @@ import java.util.zip.ZipFile;
public class ToscaFileOutputServiceCsarImplTest {
- private ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCSARImpl =
+ private final ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCSARImpl =
new ToscaFileOutputServiceCsarImpl();
@Test
@@ -112,21 +112,22 @@ public class ToscaFileOutputServiceCsarImplTest {
String resultFileName = "resultFile.zip";
File file = new File(resultFileName);
- FileOutputStream fos = new FileOutputStream(file);
- fos.write(csarFile);
- fos.close();
+ try (FileOutputStream fos = new FileOutputStream(file)) {
+ fos.write(csarFile);
+ }
- ZipFile zipFile = new ZipFile(resultFileName);
+ try (ZipFile zipFile = new ZipFile(resultFileName)) {
- Enumeration<? extends ZipEntry> entries = zipFile.entries();
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
- int count = 0;
- while (entries.hasMoreElements()) {
- count++;
- entries.nextElement();
+ int count = 0;
+ while (entries.hasMoreElements()) {
+ count++;
+ entries.nextElement();
+ }
+ Assert.assertEquals(7, count);
}
- Assert.assertEquals(7, count);
- zipFile.close();
+
Files.delete(Paths.get(file.getPath()));
}
@@ -150,21 +151,22 @@ public class ToscaFileOutputServiceCsarImplTest {
String resultFileName = "resultFile.zip";
File file = new File(resultFileName);
- FileOutputStream fos = new FileOutputStream(file);
- fos.write(csarFile);
- fos.close();
+ try (FileOutputStream fos = new FileOutputStream(file)) {
+ fos.write(csarFile);
+ }
- ZipFile zipFile = new ZipFile(resultFileName);
+ try (ZipFile zipFile = new ZipFile(resultFileName)) {
- Enumeration<? extends ZipEntry> entries = zipFile.entries();
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
- int count = 0;
- while (entries.hasMoreElements()) {
- count++;
- entries.nextElement();
+ int count = 0;
+ while (entries.hasMoreElements()) {
+ count++;
+ entries.nextElement();
+ }
+ Assert.assertEquals(2, count);
}
- Assert.assertEquals(2, count);
- zipFile.close();
+
Files.delete(Paths.get(file.getPath()));
}
}