Search in sources :

Example 6 with ObjectGraph

use of dagger.ObjectGraph in project Signal-Android by WhisperSystems.

the class DeliveryReceiptJobTest method testNetworkError.

@Test
public void testNetworkError() throws IOException {
    SignalServiceMessageSender textSecureMessageSender = mock(SignalServiceMessageSender.class);
    long timestamp = System.currentTimeMillis();
    Mockito.doThrow(new PushNetworkException("network error")).when(textSecureMessageSender).sendDeliveryReceipt(any(SignalServiceAddress.class), eq(timestamp));
    DeliveryReceiptJob deliveryReceiptJob = new DeliveryReceiptJob(context, "+14152222222", timestamp, "foo");
    ObjectGraph objectGraph = ObjectGraph.create(new TestModule(textSecureMessageSender));
    objectGraph.inject(deliveryReceiptJob);
    try {
        deliveryReceiptJob.onRun();
        throw new AssertionError();
    } catch (IOException e) {
        assertTrue(deliveryReceiptJob.onShouldRetry(e));
    }
    Mockito.doThrow(new NotFoundException("not found")).when(textSecureMessageSender).sendDeliveryReceipt(any(SignalServiceAddress.class), eq(timestamp));
    try {
        deliveryReceiptJob.onRun();
        throw new AssertionError();
    } catch (IOException e) {
        assertFalse(deliveryReceiptJob.onShouldRetry(e));
    }
}
Also used : PushNetworkException(org.whispersystems.signalservice.api.push.exceptions.PushNetworkException) SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) ObjectGraph(dagger.ObjectGraph) NotFoundException(org.whispersystems.signalservice.api.push.exceptions.NotFoundException) SignalServiceAddress(org.whispersystems.signalservice.api.push.SignalServiceAddress) IOException(java.io.IOException) Test(org.junit.Test) BaseUnitTest(org.thoughtcrime.securesms.BaseUnitTest)

Example 7 with ObjectGraph

use of dagger.ObjectGraph in project Signal-Android by WhisperSystems.

the class DeliveryReceiptJobTest method testDelivery.

@Test
public void testDelivery() throws IOException {
    SignalServiceMessageSender textSecureMessageSender = mock(SignalServiceMessageSender.class);
    long timestamp = System.currentTimeMillis();
    DeliveryReceiptJob deliveryReceiptJob = new DeliveryReceiptJob(context, "+14152222222", timestamp, "foo");
    ObjectGraph objectGraph = ObjectGraph.create(new TestModule(textSecureMessageSender));
    objectGraph.inject(deliveryReceiptJob);
    deliveryReceiptJob.onRun();
    ArgumentCaptor<SignalServiceAddress> captor = ArgumentCaptor.forClass(SignalServiceAddress.class);
    verify(textSecureMessageSender).sendDeliveryReceipt(captor.capture(), eq(timestamp));
    assertTrue(captor.getValue().getRelay().get().equals("foo"));
    assertTrue(captor.getValue().getNumber().equals("+14152222222"));
}
Also used : SignalServiceMessageSender(org.whispersystems.signalservice.api.SignalServiceMessageSender) ObjectGraph(dagger.ObjectGraph) SignalServiceAddress(org.whispersystems.signalservice.api.push.SignalServiceAddress) Test(org.junit.Test) BaseUnitTest(org.thoughtcrime.securesms.BaseUnitTest)

Example 8 with ObjectGraph

use of dagger.ObjectGraph in project Rutgers-Course-Tracker by tevjef.

the class SectionInfoPresenterImplTest method setUp.

@Before
public void setUp() throws Exception {
    ObjectGraph og = ObjectGraph.create(new TestModule(), new MockModule());
    og.inject(this);
    sectioninfoPresenterImpl = new SectionInfoPresenterImpl(section);
    og.inject(sectioninfoPresenterImpl);
}
Also used : ObjectGraph(dagger.ObjectGraph) TestModule(com.tevinjeffrey.rutgersct.TestModule) Before(org.junit.Before)

Example 9 with ObjectGraph

use of dagger.ObjectGraph in project Rutgers-Course-Tracker by tevjef.

the class RetroRutgersTest method setUp.

@Before
public void setUp() throws Exception {
    ObjectGraph og = ObjectGraph.create(new TestModule());
    og.inject(this);
    retroRutgers = new RetroRutgers(rutgersService, backgroundThread);
}
Also used : ObjectGraph(dagger.ObjectGraph) TestModule(com.tevinjeffrey.rutgersct.TestModule) Before(org.junit.Before)

Example 10 with ObjectGraph

use of dagger.ObjectGraph in project Rutgers-Course-Tracker by tevjef.

the class ChooserPresenterImplTest method setUp.

@Before
public void setUp() throws Exception {
    ObjectGraph og = ObjectGraph.create(new TestModule(), new MockModule());
    og.inject(this);
    chooserPresenterImpl = new ChooserPresenterImpl();
    og.inject(chooserPresenterImpl);
}
Also used : ObjectGraph(dagger.ObjectGraph) TestModule(com.tevinjeffrey.rutgersct.TestModule) Before(org.junit.Before)

Aggregations

ObjectGraph (dagger.ObjectGraph)19 Test (org.junit.Test)8 Before (org.junit.Before)7 TestModule (com.tevinjeffrey.rutgersct.TestModule)6 ObjectGraphService.getObjectGraph (mortar.dagger1support.ObjectGraphService.getObjectGraph)6 BaseUnitTest (org.thoughtcrime.securesms.BaseUnitTest)2 SignalServiceMessageSender (org.whispersystems.signalservice.api.SignalServiceMessageSender)2 SignalServiceAddress (org.whispersystems.signalservice.api.push.SignalServiceAddress)2 Context (android.content.Context)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 MainApplication (com.karumi.rosie.sample.main.MainApplication)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 Matchers.anyString (org.mockito.Matchers.anyString)1 NotFoundException (org.whispersystems.signalservice.api.push.exceptions.NotFoundException)1 PushNetworkException (org.whispersystems.signalservice.api.push.exceptions.PushNetworkException)1