### Question:
BidMachineFetcher { @NonNull static Map<String, String> toMap(@NonNull AdRequest adRequest) { Map<String, String> result = new HashMap<>(); AuctionResult auctionResult = adRequest.getAuctionResult(); if (auctionResult == null) { return result; } result.put(BidMachineFetcher.KEY_ID, auctionResult.getId()); result.put(BidMachineFetcher.KEY_PRICE, BidMachineFetcher.roundPrice(auctionResult.getPrice())); result.put(BidMachineFetcher.KEY_NETWORK_KEY, auctionResult.getNetworkKey()); String adType = identifyAdType(auctionResult.getCreativeFormat()); if (adType != null) { result.put(BidMachineFetcher.KEY_AD_TYPE, adType); } result.putAll(auctionResult.getCustomParams()); return result; }  static void setPriceRounding(double rounding); static void setPriceRounding(double rounding, RoundingMode roundingMode); @Nullable @SuppressWarnings({"unchecked"}) static Map<String, String> fetch(@NonNull AdRequest adRequest); @Nullable static T release(@NonNull T adRequest); @Nullable static T release(@NonNull AdsType adsType,
                                                  @NonNull Map<String, String> fetchedParams); @Nullable @SuppressWarnings("unchecked") static T release(@NonNull AdsType adsType,
                                                  @Nullable String requestId); static String roundPrice(double price); static void resetPriceRounding(); static final String KEY_ID; static final String KEY_PRICE; static final String KEY_AD_TYPE; static final String KEY_NETWORK_KEY; static final String AD_TYPE_DISPLAY; static final String AD_TYPE_VIDEO; static final String AD_TYPE_NATIVE; }### Answer:
@Test public void toMap_minimumParameters() { AdRequest adRequest = spy(new TestAdRequest.Builder(AdsType.Banner) .setAuctionId("test_id") .setAuctionPrice(0.25) .build()); Map<String, String> map = BidMachineFetcher.toMap(adRequest); assertEquals(3, map.size()); assertEquals("test_id", map.get(BidMachineFetcher.KEY_ID)); assertEquals("0.25", map.get(BidMachineFetcher.KEY_PRICE)); assertEquals("test_network", map.get(BidMachineFetcher.KEY_NETWORK_KEY)); assertFalse(map.containsKey(BidMachineFetcher.KEY_AD_TYPE)); }
@Test public void toMap_maximumParameters() { Map<String, String> customParams = new HashMap<>(); customParams.put("custom_key_1", "custom_value_1"); customParams.put("custom_key_2", "custom_value_2"); customParams.put("custom_key_3", "custom_value_3"); AdRequest adRequest = spy(new TestAdRequest.Builder(AdsType.Banner) .setAuctionId("test_id") .setAuctionPrice(0.25) .setAuctionNetworkName("test_network_name") .setAuctionCreativeFormat(CreativeFormat.Banner) .setAuctionCustomParams(customParams) .build()); Map<String, String> map = BidMachineFetcher.toMap(adRequest); assertEquals(7, map.size()); assertEquals("test_id", map.get(BidMachineFetcher.KEY_ID)); assertEquals("0.25", map.get(BidMachineFetcher.KEY_PRICE)); assertEquals("test_network_name", map.get(BidMachineFetcher.KEY_NETWORK_KEY)); assertEquals("display", map.get(BidMachineFetcher.KEY_AD_TYPE)); assertEquals("custom_value_1", map.get("custom_key_1")); assertEquals("custom_value_2", map.get("custom_key_2")); assertEquals("custom_value_3", map.get("custom_key_3")); }