use of org.prebid.mobile.tasksmanager.BackgroundThreadExecutor in project prebid-mobile-android by prebid.
the class PrebidServerAdapterTest method testInvalidPrebidServerConfigIdForRubiconHostedPrebidServer.
@Test
public void testInvalidPrebidServerConfigIdForRubiconHostedPrebidServer() {
server.enqueue(new MockResponse().setResponseCode(400).setBody(MockPrebidServerResponses.invalidConfigIdFromRubicon()));
HttpUrl hostUrl = server.url("/");
Host.CUSTOM.setHostUrl(hostUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setPrebidServerAccountId("1001");
PrebidMobile.setShareGeoLocation(true);
PrebidMobile.setApplicationContext(activity.getApplicationContext());
DemandAdapter.DemandAdapterListener mockListener = mock(DemandAdapter.DemandAdapterListener.class);
PrebidServerAdapter adapter = new PrebidServerAdapter();
HashSet<AdSize> sizes = new HashSet<>();
sizes.add(new AdSize(300, 250));
RequestParams requestParams = new RequestParams("1001-1_INVALID_CONFIG_ID", AdType.BANNER, sizes);
String uuid = UUID.randomUUID().toString();
adapter.requestDemand(requestParams, mockListener, uuid);
ShadowLooper bgLooper = Shadows.shadowOf(((BackgroundThreadExecutor) TasksManager.getInstance().backgroundThreadExecutor).getBackgroundHandler().getLooper());
bgLooper.runToEndOfTasks();
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
verify(mockListener).onDemandFailed(ResultCode.INVALID_CONFIG_ID, uuid);
}
use of org.prebid.mobile.tasksmanager.BackgroundThreadExecutor in project prebid-mobile-android by prebid.
the class PrebidServerAdapterTest method testSuccessfulBidRubiconResponseWithoutCacheId.
@Test
public void testSuccessfulBidRubiconResponseWithoutCacheId() {
server.enqueue(new MockResponse().setResponseCode(200).setBody(MockPrebidServerResponses.invalidBidRubiconResponseWithoutCacheId()));
HttpUrl hostUrl = server.url("/");
Host.CUSTOM.setHostUrl(hostUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setPrebidServerAccountId("12345");
PrebidMobile.setShareGeoLocation(true);
PrebidMobile.setApplicationContext(activity.getApplicationContext());
DemandAdapter.DemandAdapterListener mockListener = mock(DemandAdapter.DemandAdapterListener.class);
PrebidServerAdapter adapter = new PrebidServerAdapter();
HashSet<AdSize> sizes = new HashSet<>();
sizes.add(new AdSize(300, 250));
RequestParams requestParams = new RequestParams("67890", AdType.BANNER, sizes);
String uuid = UUID.randomUUID().toString();
adapter.requestDemand(requestParams, mockListener, uuid);
ShadowLooper bgLooper = Shadows.shadowOf(((BackgroundThreadExecutor) TasksManager.getInstance().backgroundThreadExecutor).getBackgroundHandler().getLooper());
bgLooper.runToEndOfTasks();
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
verify(mockListener).onDemandFailed(ResultCode.NO_BIDS, uuid);
}
use of org.prebid.mobile.tasksmanager.BackgroundThreadExecutor in project prebid-mobile-android by prebid.
the class PrebidServerAdapterTest method testNoBidRubiconResponse.
@Test
public void testNoBidRubiconResponse() {
server.enqueue(new MockResponse().setResponseCode(200).setBody(MockPrebidServerResponses.noBidFromRubicon()));
HttpUrl hostUrl = server.url("/");
Host.CUSTOM.setHostUrl(hostUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setPrebidServerAccountId("12345");
PrebidMobile.setShareGeoLocation(true);
PrebidMobile.setApplicationContext(activity.getApplicationContext());
DemandAdapter.DemandAdapterListener mockListener = mock(DemandAdapter.DemandAdapterListener.class);
PrebidServerAdapter adapter = new PrebidServerAdapter();
HashSet<AdSize> sizes = new HashSet<>();
sizes.add(new AdSize(320, 50));
RequestParams requestParams = new RequestParams("67890", AdType.BANNER, sizes);
String uuid = UUID.randomUUID().toString();
adapter.requestDemand(requestParams, mockListener, uuid);
ShadowLooper bgLooper = Shadows.shadowOf(((BackgroundThreadExecutor) TasksManager.getInstance().backgroundThreadExecutor).getBackgroundHandler().getLooper());
bgLooper.runToEndOfTasks();
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
verify(mockListener).onDemandFailed(ResultCode.NO_BIDS, uuid);
}
use of org.prebid.mobile.tasksmanager.BackgroundThreadExecutor in project prebid-mobile-android by prebid.
the class PrebidServerAdapterTest method testBlankResponseReturnsNoBid.
@Test
public void testBlankResponseReturnsNoBid() {
server.enqueue(new MockResponse().setResponseCode(204).setBody(""));
HttpUrl hostUrl = server.url("/");
Host.CUSTOM.setHostUrl(hostUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setPrebidServerAccountId("12345");
PrebidMobile.setShareGeoLocation(true);
PrebidMobile.setApplicationContext(activity.getApplicationContext());
DemandAdapter.DemandAdapterListener mockListener = mock(DemandAdapter.DemandAdapterListener.class);
PrebidServerAdapter adapter = new PrebidServerAdapter();
HashSet<AdSize> sizes = new HashSet<>();
sizes.add(new AdSize(320, 50));
RequestParams requestParams = new RequestParams("67890", AdType.BANNER, sizes);
String uuid = UUID.randomUUID().toString();
adapter.requestDemand(requestParams, mockListener, uuid);
ShadowLooper bgLooper = Shadows.shadowOf(((BackgroundThreadExecutor) TasksManager.getInstance().backgroundThreadExecutor).getBackgroundHandler().getLooper());
bgLooper.runToEndOfTasks();
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
verify(mockListener).onDemandFailed(ResultCode.NO_BIDS, uuid);
}
use of org.prebid.mobile.tasksmanager.BackgroundThreadExecutor in project prebid-mobile-android by prebid.
the class PrebidServerAdapterTest method testSuccessfulBidResponseWithoutCacheId3.
@Test
public void testSuccessfulBidResponseWithoutCacheId3() {
server.enqueue(new MockResponse().setResponseCode(200).setBody(MockPrebidServerResponses.invalidBidResponseTopBidNoCacheId()));
HttpUrl hostUrl = server.url("/");
Host.CUSTOM.setHostUrl(hostUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setPrebidServerAccountId("12345");
PrebidMobile.setShareGeoLocation(true);
PrebidMobile.setApplicationContext(activity.getApplicationContext());
DemandAdapter.DemandAdapterListener mockListener = mock(DemandAdapter.DemandAdapterListener.class);
PrebidServerAdapter adapter = new PrebidServerAdapter();
HashSet<AdSize> sizes = new HashSet<>();
sizes.add(new AdSize(300, 250));
RequestParams requestParams = new RequestParams("67890", AdType.BANNER, sizes);
String uuid = UUID.randomUUID().toString();
adapter.requestDemand(requestParams, mockListener, uuid);
ShadowLooper bgLooper = Shadows.shadowOf(((BackgroundThreadExecutor) TasksManager.getInstance().backgroundThreadExecutor).getBackgroundHandler().getLooper());
bgLooper.runToEndOfTasks();
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
verify(mockListener).onDemandFailed(ResultCode.NO_BIDS, uuid);
}
Aggregations