aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
index 69f9f5704d..7537935816 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/CsarInfoTest.java
@@ -20,24 +20,34 @@
package org.openecomp.sdc.be.components.csar;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.net.URISyntaxException;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.config.NonManoArtifactType;
+import org.openecomp.sdc.be.config.NonManoConfiguration;
+import org.openecomp.sdc.be.config.NonManoFolderType;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.model.NodeTypeInfo;
import org.openecomp.sdc.be.model.User;
@@ -112,4 +122,30 @@ public class CsarInfoTest {
assertEquals(MAIN_TEMPLATE_NAME, csarInfo.getMainTemplateName());
assertEquals(csarInfo.getMainTemplateName(), nodeTypeInfo.getTemplateFileName());
}
+
+ @Test
+ public void getSoftwareInformationPathTest() {
+ final NonManoConfiguration nonManoConfigurationMock = Mockito.mock(NonManoConfiguration.class);
+ final CsarInfo csarInfo = new CsarInfo(nonManoConfigurationMock);
+ final NonManoFolderType testNonManoFolderType = new NonManoFolderType();
+ testNonManoFolderType.setLocation("sw-location-test");
+ testNonManoFolderType.setType("informational-test");
+ when(nonManoConfigurationMock.getNonManoType(NonManoArtifactType.ONAP_SW_INFORMATION)).thenReturn(testNonManoFolderType);
+ final Map<String, byte[]> csarFileMap = new HashMap<>();
+ final String expectedPath = testNonManoFolderType.getPath() + "/" + "software-file.yaml";
+ csarFileMap.put(expectedPath, new byte[0]);
+ csarInfo.setCsar(csarFileMap);
+ final Optional<String> softwareInformationPath = csarInfo.getSoftwareInformationPath();
+ assertThat("The software information yaml path should be present", softwareInformationPath.isPresent(), is(true));
+ softwareInformationPath.ifPresent(path -> {
+ assertThat("The software information yaml ", path, is(equalTo(expectedPath)));
+ });
+ }
+
+ @Test
+ public void getSoftwareInformationPathTest_emptyCsar() {
+ csarInfo.setCsar(new HashMap<>());
+ final Optional<String> softwareInformationPath = csarInfo.getSoftwareInformationPath();
+ assertThat("The software information yaml path should not be present", softwareInformationPath.isPresent(), is(false));
+ }
}