2015-10-01 19:28:29 +00:00
|
|
|
package org.thoughtcrime.securesms.jobs;
|
|
|
|
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.thoughtcrime.securesms.BaseUnitTest;
|
2015-10-23 19:24:43 +00:00
|
|
|
import org.thoughtcrime.securesms.attachments.Attachment;
|
|
|
|
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
2015-10-01 19:28:29 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob.InvalidPartException;
|
|
|
|
|
2015-10-23 19:24:43 +00:00
|
|
|
import static org.mockito.Mockito.when;
|
2015-10-01 19:28:29 +00:00
|
|
|
import static org.powermock.api.mockito.PowerMockito.mock;
|
|
|
|
|
|
|
|
public class AttachmentDownloadJobTest extends BaseUnitTest {
|
|
|
|
private AttachmentDownloadJob job;
|
|
|
|
|
|
|
|
@Before
|
|
|
|
@Override
|
|
|
|
public void setUp() throws Exception {
|
|
|
|
super.setUp();
|
2015-11-16 20:15:15 +00:00
|
|
|
job = new AttachmentDownloadJob(context, 1L, new AttachmentId(1L, 1L));
|
2015-10-01 19:28:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = InvalidPartException.class)
|
|
|
|
public void testCreateAttachmentPointerInvalidId() throws Exception {
|
2015-10-23 19:24:43 +00:00
|
|
|
Attachment attachment = mock(Attachment.class);
|
|
|
|
when(attachment.getLocation()).thenReturn(null);
|
|
|
|
when(attachment.getKey()).thenReturn("a long and acceptable valid key like we all want");
|
|
|
|
|
|
|
|
job.createAttachmentPointer(masterSecret, attachment);
|
2015-10-01 19:28:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected = InvalidPartException.class)
|
|
|
|
public void testCreateAttachmentPointerInvalidKey() throws Exception {
|
2015-10-23 19:24:43 +00:00
|
|
|
Attachment attachment = mock(Attachment.class);
|
|
|
|
when(attachment.getLocation()).thenReturn("something");
|
|
|
|
when(attachment.getKey()).thenReturn(null);
|
|
|
|
|
|
|
|
job.createAttachmentPointer(masterSecret, attachment);
|
2015-10-01 19:28:29 +00:00
|
|
|
}
|
|
|
|
}
|