From 23a2a5e5f34fb41673e9f4fb259a2c1f81cd0d1b Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Fri, 23 Oct 2015 12:24:43 -0700 Subject: [PATCH] Fix test // FREEBIE --- .../jobs/AttachmentDownloadJobTest.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test/unitTest/java/org/thoughtcrime/securesms/jobs/AttachmentDownloadJobTest.java b/test/unitTest/java/org/thoughtcrime/securesms/jobs/AttachmentDownloadJobTest.java index 1c07b81848..0f483dec90 100644 --- a/test/unitTest/java/org/thoughtcrime/securesms/jobs/AttachmentDownloadJobTest.java +++ b/test/unitTest/java/org/thoughtcrime/securesms/jobs/AttachmentDownloadJobTest.java @@ -5,12 +5,11 @@ import android.content.Context; import org.junit.Before; import org.junit.Test; import org.thoughtcrime.securesms.BaseUnitTest; -import org.thoughtcrime.securesms.database.AttachmentDatabase.AttachmentId; +import org.thoughtcrime.securesms.attachments.Attachment; +import org.thoughtcrime.securesms.attachments.AttachmentId; import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob.InvalidPartException; -import org.thoughtcrime.securesms.util.Util; - -import ws.com.google.android.mms.pdu.PduPart; +import static org.mockito.Mockito.when; import static org.powermock.api.mockito.PowerMockito.mock; public class AttachmentDownloadJobTest extends BaseUnitTest { @@ -25,15 +24,19 @@ public class AttachmentDownloadJobTest extends BaseUnitTest { @Test(expected = InvalidPartException.class) public void testCreateAttachmentPointerInvalidId() throws Exception { - PduPart part = new PduPart(); - part.setContentDisposition(Util.toIsoBytes("a long and acceptable valid key like we all want")); - job.createAttachmentPointer(masterSecret, part); + 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); } @Test(expected = InvalidPartException.class) public void testCreateAttachmentPointerInvalidKey() throws Exception { - PduPart part = new PduPart(); - part.setContentDisposition(Util.toIsoBytes("1")); - job.createAttachmentPointer(masterSecret, part); + Attachment attachment = mock(Attachment.class); + when(attachment.getLocation()).thenReturn("something"); + when(attachment.getKey()).thenReturn(null); + + job.createAttachmentPointer(masterSecret, attachment); } }