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;
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"));
}
}
+ /**
+ * 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
*/