use of com.enonic.xp.web.multipart.MultipartItem in project xp by enonic.
the class GetMultipartScriptTest method createForm.
private void createForm() {
final MultipartForm form = Mockito.mock(MultipartForm.class);
final MultipartItem item1 = createItem("item1", 10, "jpg", "image/png");
final MultipartItem item2 = createItem("item2", 20, "jpg", "image/png");
Mockito.when(form.iterator()).thenReturn(List.of(item1, item2).iterator());
Mockito.when(form.get("item1", 0)).thenReturn(item1);
Mockito.when(this.multipartService.parse(Mockito.any())).thenReturn(form);
}
use of com.enonic.xp.web.multipart.MultipartItem in project xp by enonic.
the class ApplicationResourceTest method install.
@Test
public void install() throws Exception {
ApplicationResource resource = getResourceInstance();
ByteSource byteSource = ByteSource.wrap("bytes".getBytes());
Application application = createApplication();
MultipartItem multipartItem = Mockito.mock(MultipartItem.class);
Mockito.when(multipartItem.getBytes()).thenReturn(byteSource);
String fileName = application.getDisplayName();
Mockito.when(multipartItem.getFileName()).thenReturn(fileName);
MultipartForm multipartForm = Mockito.mock(MultipartForm.class);
Mockito.when(this.applicationService.installGlobalApplication(Mockito.isA(ByteSource.class), eq(fileName))).thenReturn(application);
Mockito.when(multipartForm.get("file")).thenReturn(multipartItem);
ApplicationInstallResultJson result = resource.install(multipartForm);
assertEquals(new ApplicationInstalledJson(application, false), result.getApplicationInstalledJson());
}
Aggregations