Search in sources :

Example 1 with AppSwitchNotAvailableException

use of com.braintreepayments.api.exceptions.AppSwitchNotAvailableException in project braintree_android by braintree.

the class VenmoUnitTest method performAppSwitch_sendsAnalyticsEventWhenUnavailableAndPostException.

@Test
public void performAppSwitch_sendsAnalyticsEventWhenUnavailableAndPostException() {
    Configuration configuration = getConfigurationFromFixture();
    BraintreeFragment fragment = new MockFragmentBuilder().configuration(configuration).build();
    Venmo.authorizeAccount(fragment, false);
    ArgumentCaptor<AppSwitchNotAvailableException> captor = ArgumentCaptor.forClass(AppSwitchNotAvailableException.class);
    InOrder order = inOrder(fragment);
    order.verify(fragment).sendAnalyticsEvent("pay-with-venmo.selected");
    order.verify(fragment).sendAnalyticsEvent("pay-with-venmo.app-switch.failed");
    verify(fragment).postCallback(captor.capture());
    assertEquals("Venmo is not installed", captor.getValue().getMessage());
}
Also used : AppSwitchNotAvailableException(com.braintreepayments.api.exceptions.AppSwitchNotAvailableException) InOrder(org.mockito.InOrder) Configuration(com.braintreepayments.api.models.Configuration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with AppSwitchNotAvailableException

use of com.braintreepayments.api.exceptions.AppSwitchNotAvailableException in project braintree_android by braintree.

the class VenmoUnitTest method authorizeAccount_postsExceptionWhenNotEnabled.

@Test
public void authorizeAccount_postsExceptionWhenNotEnabled() throws JSONException {
    Configuration configuration = new TestConfigurationBuilder().buildConfiguration();
    BraintreeFragment fragment = new MockFragmentBuilder().configuration(configuration).build();
    Venmo.authorizeAccount(fragment, false);
    ArgumentCaptor<AppSwitchNotAvailableException> captor = ArgumentCaptor.forClass(AppSwitchNotAvailableException.class);
    verify(fragment).postCallback(captor.capture());
    assertEquals("Venmo is not enabled", captor.getValue().getMessage());
}
Also used : AppSwitchNotAvailableException(com.braintreepayments.api.exceptions.AppSwitchNotAvailableException) Configuration(com.braintreepayments.api.models.Configuration) TestConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with AppSwitchNotAvailableException

use of com.braintreepayments.api.exceptions.AppSwitchNotAvailableException in project braintree_android by braintree.

the class VenmoUnitTest method authorizeAccount_postsExceptionWhenNotInstalled.

@Test
public void authorizeAccount_postsExceptionWhenNotInstalled() {
    Configuration configuration = getConfigurationFromFixture();
    BraintreeFragment fragment = new MockFragmentBuilder().configuration(configuration).build();
    Venmo.authorizeAccount(fragment, false);
    ArgumentCaptor<AppSwitchNotAvailableException> captor = ArgumentCaptor.forClass(AppSwitchNotAvailableException.class);
    verify(fragment).postCallback(captor.capture());
    assertEquals("Venmo is not installed", captor.getValue().getMessage());
}
Also used : AppSwitchNotAvailableException(com.braintreepayments.api.exceptions.AppSwitchNotAvailableException) Configuration(com.braintreepayments.api.models.Configuration) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

AppSwitchNotAvailableException (com.braintreepayments.api.exceptions.AppSwitchNotAvailableException)3 Configuration (com.braintreepayments.api.models.Configuration)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 TestConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder)1 InOrder (org.mockito.InOrder)1