@Test public void extractAdUnits_obtainedMediationConfigContainsAdUnits_resultListIsFull() { BidMachineNetworkConfigParams networkConfigParams = new BidMachineNetworkConfigParams(); networkConfigParams.addMap(AdsFormat.Banner, new HashMap<String, String>() {{ put(CriteoConfig.AD_UNIT_ID, "ad_unit_banner_id"); }}); networkConfigParams.addMap(AdsFormat.Banner_320x50, new HashMap<String, String>() {{ put(CriteoConfig.AD_UNIT_ID, "ad_unit_banner_320_id"); }}); networkConfigParams.addMap(AdsFormat.Banner_300x250, new HashMap<String, String>() {{ put(CriteoConfig.AD_UNIT_ID, "ad_unit_banner_300_id"); }}); networkConfigParams.addMap(AdsFormat.Banner_728x90, new HashMap<String, String>() {{ put(CriteoConfig.AD_UNIT_ID, "ad_unit_banner_728_id"); }}); networkConfigParams.addMap(AdsFormat.Interstitial, new HashMap<String, String>() {{ put(CriteoConfig.AD_UNIT_ID, "ad_unit_interstitial_id"); }}); networkConfigParams.addMap(AdsFormat.InterstitialStatic, new HashMap<String, String>() {{ put(CriteoConfig.AD_UNIT_ID, "ad_unit_interstitial_static_id"); }}); networkConfigParams.addMap(AdsFormat.InterstitialVideo, new HashMap<String, String>() {{ put(CriteoConfig.AD_UNIT_ID, "ad_unit_interstitial_video_id"); }}); List<AdUnit> adUnitList = CriteoAdUnitController.extractAdUnits(networkConfigParams); assertNotNull(adUnitList); assertEquals(7, adUnitList.size()); BannerAdUnit bannerAdUnit = findAdUnitFromList(adUnitList, "ad_unit_banner_id"); assertNotNull(bannerAdUnit); assertEquals("ad_unit_banner_id", bannerAdUnit.getAdUnitId()); assertEquals(320, bannerAdUnit.getSize().getWidth()); assertEquals(50, bannerAdUnit.getSize().getHeight()); BannerAdUnit banner320AdUnit = findAdUnitFromList(adUnitList, "ad_unit_banner_320_id"); assertNotNull(banner320AdUnit); assertEquals("ad_unit_banner_320_id", banner320AdUnit.getAdUnitId()); assertEquals(320, banner320AdUnit.getSize().getWidth()); assertEquals(50, banner320AdUnit.getSize().getHeight()); BannerAdUnit banner300AdUnit = findAdUnitFromList(adUnitList, "ad_unit_banner_300_id"); assertNotNull(banner300AdUnit); assertEquals("ad_unit_banner_300_id", banner300AdUnit.getAdUnitId()); assertEquals(300, banner300AdUnit.getSize().getWidth()); assertEquals(250, banner300AdUnit.getSize().getHeight()); BannerAdUnit banner728AdUnit = findAdUnitFromList(adUnitList, "ad_unit_banner_728_id"); assertNotNull(banner728AdUnit); assertEquals("ad_unit_banner_728_id", banner728AdUnit.getAdUnitId()); assertEquals(728, banner728AdUnit.getSize().getWidth()); assertEquals(90, banner728AdUnit.getSize().getHeight()); AdUnit interstitialAdUnit = findAdUnitFromList(adUnitList, "ad_unit_interstitial_id"); assertNotNull(interstitialAdUnit); assertEquals("ad_unit_interstitial_id", interstitialAdUnit.getAdUnitId()); AdUnit interstitialStaticAdUnit = findAdUnitFromList(adUnitList, "ad_unit_interstitial_static_id"); assertNotNull(interstitialStaticAdUnit); assertEquals("ad_unit_interstitial_static_id", interstitialStaticAdUnit.getAdUnitId()); AdUnit interstitialVideoAdUnit = findAdUnitFromList(adUnitList, "ad_unit_interstitial_video_id"); assertNotNull(interstitialVideoAdUnit); assertEquals("ad_unit_interstitial_video_id", interstitialVideoAdUnit.getAdUnitId()); }
@Nullable static List<AdUnit> extractAdUnits(@NonNull NetworkConfigParams networkConfigParams) { EnumMap<AdsFormat, List<Map<String, String>>> networkMediationConfigs = networkConfigParams.obtainNetworkMediationConfigs(AdsFormat.values()); if (networkMediationConfigs == null) { return null; } List<AdUnit> adUnitList = new ArrayList<>(); for (Map.Entry<AdsFormat, List<Map<String, String>>> entry : networkMediationConfigs.entrySet()) { AdsFormat adsFormat = entry.getKey(); if (adsFormat == null) { continue; } List<Map<String, String>> configList = entry.getValue(); if (configList == null) { continue; } for (Map<String, String> config : configList) { String adUnitId = config.get(CriteoConfig.AD_UNIT_ID); if (TextUtils.isEmpty(adUnitId)) { continue; } assert adUnitId != null; AdUnit adUnit = null; switch (adsFormat) { case Banner: case Banner_320x50: adUnit = new BannerAdUnit(adUnitId, new AdSize(320, 50)); break; case Banner_300x250: adUnit = new BannerAdUnit(adUnitId, new AdSize(300, 250)); break; case Banner_728x90: adUnit = new BannerAdUnit(adUnitId, new AdSize(728, 90)); break; case Interstitial: case InterstitialStatic: case InterstitialVideo: adUnit = new InterstitialAdUnit(adUnitId); break; } if (adUnit != null) { adUnitMap.put(adUnitId, adUnit); adUnitList.add(adUnit); } } } return adUnitList; }
CriteoAdUnitController { @Nullable static List<AdUnit> extractAdUnits(@NonNull NetworkConfigParams networkConfigParams) { EnumMap<AdsFormat, List<Map<String, String>>> networkMediationConfigs = networkConfigParams.obtainNetworkMediationConfigs(AdsFormat.values()); if (networkMediationConfigs == null) { return null; } List<AdUnit> adUnitList = new ArrayList<>(); for (Map.Entry<AdsFormat, List<Map<String, String>>> entry : networkMediationConfigs.entrySet()) { AdsFormat adsFormat = entry.getKey(); if (adsFormat == null) { continue; } List<Map<String, String>> configList = entry.getValue(); if (configList == null) { continue; } for (Map<String, String> config : configList) { String adUnitId = config.get(CriteoConfig.AD_UNIT_ID); if (TextUtils.isEmpty(adUnitId)) { continue; } assert adUnitId != null; AdUnit adUnit = null; switch (adsFormat) { case Banner: case Banner_320x50: adUnit = new BannerAdUnit(adUnitId, new AdSize(320, 50)); break; case Banner_300x250: adUnit = new BannerAdUnit(adUnitId, new AdSize(300, 250)); break; case Banner_728x90: adUnit = new BannerAdUnit(adUnitId, new AdSize(728, 90)); break; case Interstitial: case InterstitialStatic: case InterstitialVideo: adUnit = new InterstitialAdUnit(adUnitId); break; } if (adUnit != null) { adUnitMap.put(adUnitId, adUnit); adUnitList.add(adUnit); } } } return adUnitList; } }
CriteoAdUnitController { @Nullable static List<AdUnit> extractAdUnits(@NonNull NetworkConfigParams networkConfigParams) { EnumMap<AdsFormat, List<Map<String, String>>> networkMediationConfigs = networkConfigParams.obtainNetworkMediationConfigs(AdsFormat.values()); if (networkMediationConfigs == null) { return null; } List<AdUnit> adUnitList = new ArrayList<>(); for (Map.Entry<AdsFormat, List<Map<String, String>>> entry : networkMediationConfigs.entrySet()) { AdsFormat adsFormat = entry.getKey(); if (adsFormat == null) { continue; } List<Map<String, String>> configList = entry.getValue(); if (configList == null) { continue; } for (Map<String, String> config : configList) { String adUnitId = config.get(CriteoConfig.AD_UNIT_ID); if (TextUtils.isEmpty(adUnitId)) { continue; } assert adUnitId != null; AdUnit adUnit = null; switch (adsFormat) { case Banner: case Banner_320x50: adUnit = new BannerAdUnit(adUnitId, new AdSize(320, 50)); break; case Banner_300x250: adUnit = new BannerAdUnit(adUnitId, new AdSize(300, 250)); break; case Banner_728x90: adUnit = new BannerAdUnit(adUnitId, new AdSize(728, 90)); break; case Interstitial: case InterstitialStatic: case InterstitialVideo: adUnit = new InterstitialAdUnit(adUnitId); break; } if (adUnit != null) { adUnitMap.put(adUnitId, adUnit); adUnitList.add(adUnit); } } } return adUnitList; }  }
CriteoAdUnitController { @Nullable static List<AdUnit> extractAdUnits(@NonNull NetworkConfigParams networkConfigParams) { EnumMap<AdsFormat, List<Map<String, String>>> networkMediationConfigs = networkConfigParams.obtainNetworkMediationConfigs(AdsFormat.values()); if (networkMediationConfigs == null) { return null; } List<AdUnit> adUnitList = new ArrayList<>(); for (Map.Entry<AdsFormat, List<Map<String, String>>> entry : networkMediationConfigs.entrySet()) { AdsFormat adsFormat = entry.getKey(); if (adsFormat == null) { continue; } List<Map<String, String>> configList = entry.getValue(); if (configList == null) { continue; } for (Map<String, String> config : configList) { String adUnitId = config.get(CriteoConfig.AD_UNIT_ID); if (TextUtils.isEmpty(adUnitId)) { continue; } assert adUnitId != null; AdUnit adUnit = null; switch (adsFormat) { case Banner: case Banner_320x50: adUnit = new BannerAdUnit(adUnitId, new AdSize(320, 50)); break; case Banner_300x250: adUnit = new BannerAdUnit(adUnitId, new AdSize(300, 250)); break; case Banner_728x90: adUnit = new BannerAdUnit(adUnitId, new AdSize(728, 90)); break; case Interstitial: case InterstitialStatic: case InterstitialVideo: adUnit = new InterstitialAdUnit(adUnitId); break; } if (adUnit != null) { adUnitMap.put(adUnitId, adUnit); adUnitList.add(adUnit); } } } return adUnitList; }   }
CriteoAdUnitController { @Nullable static List<AdUnit> extractAdUnits(@NonNull NetworkConfigParams networkConfigParams) { EnumMap<AdsFormat, List<Map<String, String>>> networkMediationConfigs = networkConfigParams.obtainNetworkMediationConfigs(AdsFormat.values()); if (networkMediationConfigs == null) { return null; } List<AdUnit> adUnitList = new ArrayList<>(); for (Map.Entry<AdsFormat, List<Map<String, String>>> entry : networkMediationConfigs.entrySet()) { AdsFormat adsFormat = entry.getKey(); if (adsFormat == null) { continue; } List<Map<String, String>> configList = entry.getValue(); if (configList == null) { continue; } for (Map<String, String> config : configList) { String adUnitId = config.get(CriteoConfig.AD_UNIT_ID); if (TextUtils.isEmpty(adUnitId)) { continue; } assert adUnitId != null; AdUnit adUnit = null; switch (adsFormat) { case Banner: case Banner_320x50: adUnit = new BannerAdUnit(adUnitId, new AdSize(320, 50)); break; case Banner_300x250: adUnit = new BannerAdUnit(adUnitId, new AdSize(300, 250)); break; case Banner_728x90: adUnit = new BannerAdUnit(adUnitId, new AdSize(728, 90)); break; case Interstitial: case InterstitialStatic: case InterstitialVideo: adUnit = new InterstitialAdUnit(adUnitId); break; } if (adUnit != null) { adUnitMap.put(adUnitId, adUnit); adUnitList.add(adUnit); } } } return adUnitList; }    }