use of org.prebid.mobile.OnCompleteListener2 in project prebid-mobile-android by prebid.
the class AdManagerComplexTest method testFetchDemandBidsAutoRefresh.
@Test
public void testFetchDemandBidsAutoRefresh() throws Exception {
final IntegerWrapper requestCountWrapper = new IntegerWrapper();
fetchDemandHelper(31_000, new FetchDemandCompleteListener() {
@Override
public void preFetchDemand() {
mockServer.enqueue(new MockResponse().setResponseCode(200).setBody("{\n" + " \"seatbid\": [\n" + " {\n" + " \"bid\": [\n" + " {\n" + " \"ext\": {\n" + " \"prebid\": {\n" + " \"targeting\": {\n" + " \"hb_cache_id\": \"top_bid_1\",\n" + " \"key1\": \"value1\"\n" + " }\n" + " }\n" + " }\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + "}"));
}
@Override
public void executeFetchDemand(AdUnit adUnit, final List<Map<String, String>> resultList) {
adUnit.fetchDemand(new OnCompleteListener2() {
@Override
public void onComplete(ResultCode resultCode, Map<String, String> unmodifiableMap) {
requestCountWrapper.value++;
resultList.add(new HashMap(unmodifiableMap));
}
});
}
@Override
public void postFetchDemand(List<Map<String, String>> resultList) {
Map<String, String> result = resultList.get(1);
assertEquals("top_bid_1", result.get("hb_cache_id"));
assertEquals("value1", result.get("key1"));
}
});
assertEquals(2, requestCountWrapper.value);
}
Aggregations