use of com.kount.api.DataCollector.CompletionHandler in project braintree_android by braintree.
the class DataCollectorUnitTest method collectDeviceData_sendsAnalyticsEventsWhenFailed.
@Test
public void collectDeviceData_sendsAnalyticsEventsWhenFailed() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().kount(new TestKountConfigurationBuilder().kountMerchantId("600000")).build()).build();
final com.kount.api.DataCollector mockDataCollector = mock(com.kount.api.DataCollector.class);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((CompletionHandler) invocation.getArguments()[1]).failed((String) invocation.getArguments()[0], null);
return null;
}
}).when(mockDataCollector).collectForSession(anyString(), any(CompletionHandler.class));
mockStatic(com.kount.api.DataCollector.class);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return mockDataCollector;
}
}).when(com.kount.api.DataCollector.class);
com.kount.api.DataCollector.getInstance();
DataCollector.collectDeviceData(fragment, new BraintreeResponseListener<String>() {
@Override
public void onResponse(String s) {
verify(fragment).sendAnalyticsEvent("data-collector.kount.started");
verify(fragment).sendAnalyticsEvent("data-collector.kount.failed");
latch.countDown();
}
});
latch.await();
}
use of com.kount.api.DataCollector.CompletionHandler in project braintree_android by braintree.
the class DataCollectorUnitTest method collectDeviceData_sendsAnalyticsEventsWhenSuccessful.
@Test
public void collectDeviceData_sendsAnalyticsEventsWhenSuccessful() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().kount(new TestKountConfigurationBuilder().kountMerchantId("600000")).build()).build();
final com.kount.api.DataCollector mockDataCollector = mock(com.kount.api.DataCollector.class);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((CompletionHandler) invocation.getArguments()[1]).completed((String) invocation.getArguments()[0]);
return null;
}
}).when(mockDataCollector).collectForSession(anyString(), any(CompletionHandler.class));
mockStatic(com.kount.api.DataCollector.class);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return mockDataCollector;
}
}).when(com.kount.api.DataCollector.class);
com.kount.api.DataCollector.getInstance();
DataCollector.collectDeviceData(fragment, new BraintreeResponseListener<String>() {
@Override
public void onResponse(String s) {
verify(fragment).sendAnalyticsEvent("data-collector.kount.started");
verify(fragment).sendAnalyticsEvent("data-collector.kount.succeeded");
latch.countDown();
}
});
latch.await();
}
Aggregations