1 package net.pterodactylus.sone.web;
3 import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo;
4 import static org.mockito.ArgumentMatchers.anyInt;
5 import static org.mockito.ArgumentMatchers.eq;
6 import static org.mockito.Mockito.mock;
7 import static org.mockito.Mockito.when;
9 import net.pterodactylus.sone.data.Album;
10 import net.pterodactylus.util.web.Method;
12 import org.junit.Before;
13 import org.junit.Test;
16 * Unit test for {@link UploadImagePageTest}.
18 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
20 public class UploadImagePageTest extends WebPageTest {
22 private final UploadImagePage uploadImagePage = new UploadImagePage(template, webInterface);
24 private final Album parentAlbum = mock(Album.class);
27 public void setupParentAlbum() {
28 when(core.getAlbum("parent-id")).thenReturn(parentAlbum);
29 when(parentAlbum.getSone()).thenReturn(currentSone);
33 public void uploadingAnImageWithoutTitleRedirectsToEmptyImageTitlePage() throws Exception {
34 request("", Method.POST);
35 when(httpRequest.getPartAsStringFailsafe(eq("parent"), anyInt())).thenReturn("parent-id");
36 when(httpRequest.getPartAsStringFailsafe(eq("title"), anyInt())).thenReturn(" ");
37 expectedException.expect(redirectsTo("emptyImageTitle.html"));
38 uploadImagePage.processTemplate(freenetRequest, templateContext);