X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-widget-ms%2Fwidget-ms%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fportalapp%2Fwidget%2Fservice%2Fimpl%2FStorageServiceImplTest.java;h=fc5352708fce7fbdaa1b23bc3150685837191604;hb=aa9b320ff93511280cf51b03d38fb9254af6b530;hp=336f857cc7a6d4a75835f2b3fea22a9fd1b4fad5;hpb=fe3a67c11b65d7989a6ef648c3f34eee8abe7394;p=portal.git diff --git a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/StorageServiceImplTest.java b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/StorageServiceImplTest.java index 336f857c..fc535270 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/StorageServiceImplTest.java +++ b/ecomp-portal-widget-ms/widget-ms/src/test/java/org/onap/portalapp/widget/service/impl/StorageServiceImplTest.java @@ -39,6 +39,8 @@ package org.onap.portalapp.widget.service.impl; import static org.mockito.Mockito.when; +import java.io.File; +import java.io.FileOutputStream; import java.util.ArrayList; import java.util.List; @@ -179,5 +181,60 @@ public void testcheckZipFileInvalid() { } + @Test(expected=IllegalArgumentException.class) + public void testSaveMultiPartFile() { + MockMultipartFile mockMultipartFile = new MockMultipartFile( + "fileData", + "test.zip", + "text/plain", + "test".getBytes()); + + WidgetCatalog catalog=new WidgetCatalog(); + catalog.setServiceId(2l); + catalog.setName("test"); + + storageServiceImpl.save(mockMultipartFile, catalog, 2l); + + + } + + @Test(expected=IllegalArgumentException.class) + public void testInitSave()throws Exception { + MockMultipartFile mockMultipartFile = new MockMultipartFile( + "fileData", + "test.zip", + "text/plain", + "test".getBytes()); + File convFile = new File(mockMultipartFile.getOriginalFilename()); + FileOutputStream fos = new FileOutputStream(convFile); + fos.write(mockMultipartFile.getBytes()); + fos.close(); + WidgetCatalog catalog=new WidgetCatalog(); + catalog.setServiceId(2l); + catalog.setName("test"); + storageServiceImpl.initSave(convFile, catalog, 2l); + convFile.delete(); + + + } + + @Test + public void testWidgetFramework()throws Exception { + List widgetFiles=new ArrayList<>(); + WidgetFile file=new WidgetFile(); + file.setCss("test".getBytes()); + file.setController("test function() Test".getBytes()); + file.setMarkup("Test".getBytes()); + file.setFramework("test".getBytes()); + widgetFiles.add(file); + + when(sessionFactory.getCurrentSession()).thenReturn(currentSession); + when(currentSession.beginTransaction()).thenReturn(transaction); + when(currentSession.createCriteria(WidgetFile.class)).thenReturn(criteria); + when(criteria.list()).thenReturn(widgetFiles); + storageServiceImpl.getWidgetFramework(2l); + + } + }