Search in sources :

Example 1 with SubscriberId

use of org.whispersystems.signalservice.api.subscriptions.SubscriberId in project Signal-Android by WhisperSystems.

the class DonationsServiceTest method givenASubscriberId_whenIGetAnUnsuccessfulResponse_thenItIsMappedWithTheCorrectStatusCodeAndEmptyObject.

@Test
public void givenASubscriberId_whenIGetAnUnsuccessfulResponse_thenItIsMappedWithTheCorrectStatusCodeAndEmptyObject() throws Exception {
    // GIVEN
    SubscriberId subscriberId = SubscriberId.generate();
    when(pushServiceSocket.getSubscription(subscriberId.serialize())).thenThrow(new NonSuccessfulResponseCodeException(403));
    // WHEN
    TestObserver<ServiceResponse<ActiveSubscription>> testObserver = testSubject.getSubscription(subscriberId).test();
    // THEN
    TEST_SCHEDULER.triggerActions();
    verify(pushServiceSocket).getSubscription(subscriberId.serialize());
    testObserver.assertComplete().assertValue(value -> value.getStatus() == 403 && !value.getResult().isPresent());
}
Also used : ServiceResponse(org.whispersystems.signalservice.internal.ServiceResponse) SubscriberId(org.whispersystems.signalservice.api.subscriptions.SubscriberId) NonSuccessfulResponseCodeException(org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException) Test(org.junit.Test)

Example 2 with SubscriberId

use of org.whispersystems.signalservice.api.subscriptions.SubscriberId in project Signal-Android by WhisperSystems.

the class DonationsServiceTest method givenASubscriberId_whenIGetASuccessfulResponse_thenItIsMappedWithTheCorrectStatusCodeAndNonEmptyObject.

@Test
public void givenASubscriberId_whenIGetASuccessfulResponse_thenItIsMappedWithTheCorrectStatusCodeAndNonEmptyObject() throws Exception {
    // GIVEN
    SubscriberId subscriberId = SubscriberId.generate();
    when(pushServiceSocket.getSubscription(subscriberId.serialize())).thenReturn(getActiveSubscription());
    // WHEN
    TestObserver<ServiceResponse<ActiveSubscription>> testObserver = testSubject.getSubscription(subscriberId).test();
    // THEN
    TEST_SCHEDULER.triggerActions();
    verify(pushServiceSocket).getSubscription(subscriberId.serialize());
    testObserver.assertComplete().assertValue(value -> value.getStatus() == 200 && value.getResult().isPresent());
}
Also used : ServiceResponse(org.whispersystems.signalservice.internal.ServiceResponse) SubscriberId(org.whispersystems.signalservice.api.subscriptions.SubscriberId) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 SubscriberId (org.whispersystems.signalservice.api.subscriptions.SubscriberId)2 ServiceResponse (org.whispersystems.signalservice.internal.ServiceResponse)2 NonSuccessfulResponseCodeException (org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException)1