use of org.prebid.mobile.tasksmanager.BackgroundThreadExecutor in project prebid-mobile-android by prebid.
the class PrebidServerAdapterTest method testInvalidPrebidServerIdSyntaxForAppNexusHostedPrebidServer.
// @Test
// TODO: Activate this test after setting up test server
public void testInvalidPrebidServerIdSyntaxForAppNexusHostedPrebidServer() {
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
// invalid account id
PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888d");
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("6ace8c7d-88c0-4623-8117-75bc3f0a2e45", 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_ACCOUNT_ID, uuid);
}
use of org.prebid.mobile.tasksmanager.BackgroundThreadExecutor in project prebid-mobile-android by prebid.
the class PrebidServerAdapterTest method testMergingBidsFromDifferentSeats.
@Test
public void testMergingBidsFromDifferentSeats() {
server.enqueue(new MockResponse().setResponseCode(200).setBody(MockPrebidServerResponses.oneBidFromAppNexusOneBidFromRubicon()));
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();
HashMap<String, String> bids = new HashMap<String, String>();
bids.put("hb_bidder", "rubicon");
bids.put("hb_bidder_rubicon", "rubicon");
bids.put("hb_cache_id", "bd8d6eeb-8ad1-402c-a1f8-09565bb0bda7");
bids.put("hb_cache_id_rubicon", "bd8d6eeb-8ad1-402c-a1f8-09565bb0bda7");
bids.put("hb_creative_loadtype", "html");
bids.put("hb_env", "mobile-app");
bids.put("hb_env_rubicon", "mobile-app");
bids.put("hb_pb", "1.20");
bids.put("hb_pb_rubicon", "1.20");
bids.put("hb_size", "300x250");
bids.put("hb_size_rubicon", "300x250");
bids.put("hb_bidder_appnexus", "appnexus");
bids.put("hb_cache_id_appnexus", "f5b7ff9f-4311-459d-a5ac-5d4d3d034e47");
bids.put("hb_creative_loadtype", "html");
bids.put("hb_env_appnexus", "mobile-app");
bids.put("hb_pb_appnexus", "0.50");
bids.put("hb_size_appnexus", "300x250");
verify(mockListener).onDemandReady(bids, uuid);
}
Aggregations