### Question:
AuctionResultImpl implements AuctionResult { @Nullable @VisibleForTesting static CreativeFormat identifyCreativeFormat(@NonNull Ad ad) { if (ad.hasDisplay()) { Ad.Display display = ad.getDisplay(); if (display.hasBanner() || !TextUtils.isEmpty(display.getAdm())) { return CreativeFormat.Banner; } else if (display.hasNative()) { return CreativeFormat.Native; } } else if (ad.hasVideo()) { return CreativeFormat.Video; } return null; } AuctionResultImpl(@NonNull Response.Seatbid seatbid,
                      @NonNull Response.Seatbid.Bid bid,
                      @NonNull Ad ad,
                      @NonNull NetworkConfig networkConfig); @NonNull @Override String getId(); @Nullable @Override String getDemandSource(); @Override double getPrice(); @Nullable @Override String getDeal(); @Override @Nullable String getSeat(); @Override @NonNull String getCreativeId(); @Nullable @Override String getCid(); @Override @Nullable String[] getAdDomains(); @Override @NonNull String getNetworkKey(); @Nullable @Override CreativeFormat getCreativeFormat(); @NonNull @Override Map<String, String> getCustomParams(); @NonNull @Override String toString();  }### Answer:
@Test public void identifyCreativeFormat_withEmptyAd_creativeFormatIsNull() { Ad ad = Ad.newBuilder() .build(); CreativeFormat creativeFormat = AuctionResultImpl.identifyCreativeFormat(ad); assertNull(creativeFormat); }
@Test public void identifyCreativeFormat_containsEmptyDisplay_creativeFormatIsNull() { Ad.Display display = Ad.Display.newBuilder() .build(); Ad ad = Ad.newBuilder() .setDisplay(display) .build(); CreativeFormat creativeFormat = AuctionResultImpl.identifyCreativeFormat(ad); assertNull(creativeFormat); }
@Test public void identifyCreativeFormat_containsDisplayWithAdm_creativeFormatIsBanner() { Ad.Display display = Ad.Display.newBuilder() .setAdm("test_adm") .build(); Ad ad = Ad.newBuilder() .setDisplay(display) .build(); CreativeFormat creativeFormat = AuctionResultImpl.identifyCreativeFormat(ad); assertEquals(CreativeFormat.Banner, creativeFormat); }
@Test public void identifyCreativeFormat_containsDisplayWithBanner_creativeFormatIsBanner() { Ad.Display.Banner banner = Ad.Display.Banner.newBuilder() .build(); Ad.Display display = Ad.Display.newBuilder() .setBanner(banner) .build(); Ad ad = Ad.newBuilder() .setDisplay(display) .build(); CreativeFormat creativeFormat = AuctionResultImpl.identifyCreativeFormat(ad); assertEquals(CreativeFormat.Banner, creativeFormat); }
@Test public void identifyCreativeFormat_containsDisplayWithNative_creativeFormatIsNative() { Ad.Display.Native nativeAd = Ad.Display.Native.newBuilder() .build(); Ad.Display display = Ad.Display.newBuilder() .setNative(nativeAd) .build(); Ad ad = Ad.newBuilder() .setDisplay(display) .build(); CreativeFormat creativeFormat = AuctionResultImpl.identifyCreativeFormat(ad); assertEquals(CreativeFormat.Native, creativeFormat); }
@Test public void identifyCreativeFormat_containsVideo_creativeFormatIsVideo() { Ad.Video video = Ad.Video.newBuilder() .build(); Ad ad = Ad.newBuilder() .setVideo(video) .build(); CreativeFormat creativeFormat = AuctionResultImpl.identifyCreativeFormat(ad); assertEquals(CreativeFormat.Video, creativeFormat); }