summaryrefslogtreecommitdiffstats
path: root/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
diff options
context:
space:
mode:
Diffstat (limited to 'nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java')
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
index 48d2cab0..99fd203a 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
@@ -31,7 +31,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.CbamVnfPackageBuilder;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.CbamVnfdBuilder;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfdBuilder;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapR1VnfdBuilder;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.springframework.http.HttpHeaders;
@@ -88,7 +88,7 @@ public class TestConverterApi extends TestBase {
private void verifyVnfPackageWritterToOutputStream(ByteArrayOutputStream bos) throws Exception {
String cbamVnfd = new String(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip.vnfd"));
- String expectedOnapVnfd = new OnapVnfdBuilder().toOnapVnfd(cbamVnfd);
+ String expectedOnapVnfd = new OnapR1VnfdBuilder().toOnapVnfd(cbamVnfd);
assertFileInZip(bos.toByteArray(), "TOSCA-Metadata/TOSCA.meta", TestUtil.loadFile("TOSCA.meta"));
assertFileInZip(bos.toByteArray(), "MainServiceTemplate.yaml", expectedOnapVnfd.getBytes());
assertFileInZip(bos.toByteArray(), "MainServiceTemplate.mf", TestUtil.loadFile("MainServiceTemplate.mf"));
@@ -134,6 +134,27 @@ public class TestConverterApi extends TestBase {
}
/**
+ * error is propagated if unable to extract version from HTTP request
+ */
+ @Test
+ public void testUnableToExtractVersion() throws Exception {
+ IOException expectedException = new IOException();
+ Part part = Mockito.mock(Part.class);
+ when(part.getInputStream()).thenReturn(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip")));
+ when(httpRequest.getPart("fileToUpload")).thenReturn(part);
+ when(httpRequest.getPart("version")).thenThrow(expectedException);
+ when(part.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes()));
+ try {
+ converterApi.convert(httpResponse, httpRequest);
+ fail();
+ } catch (Exception e) {
+ verify(logger).error("Unable to determine the desired ONAP package version", expectedException);
+ assertEquals("Unable to determine the desired ONAP package version", e.getMessage());
+ assertEquals(expectedException, e.getCause());
+ }
+ }
+
+ /**
* error is propagated if unable to extract package from HTTP request
*/
@Test