Search in sources :

Example 1 with OnCompleteListener2

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);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) BannerAdUnit(org.prebid.mobile.BannerAdUnit) AdUnit(org.prebid.mobile.AdUnit) HashMap(java.util.HashMap) OnCompleteListener2(org.prebid.mobile.OnCompleteListener2) HashMap(java.util.HashMap) Map(java.util.Map) ResultCode(org.prebid.mobile.ResultCode) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 Test (org.junit.Test)1 AdUnit (org.prebid.mobile.AdUnit)1 BannerAdUnit (org.prebid.mobile.BannerAdUnit)1 OnCompleteListener2 (org.prebid.mobile.OnCompleteListener2)1 ResultCode (org.prebid.mobile.ResultCode)1