@Test public void testResponse_videoAd() { OpenRtb.BidRequest request = TestUtil.newBidRequest(TestData.newRequest(0, false, false).setVideo(TestData.newVideo(0))); Bid bid = TestData.newBid(false).setAdm("http://my-video").setCrid("creativeId").build(); NetworkBid.BidResponse.Ad.Builder ad = mapper.mapResponseAd(request, bid); assertThat(ad).isNotNull(); assertThat(ad.getVideoUrl()).isEqualTo("http://my-video"); assertThat(ad.getBuyerCreativeId()).isEqualTo("creativeId"); assertThat(ad.hasHtmlSnippet()).isFalse(); }
@Test public void testResponse_htmlSnippetAd() { OpenRtb.BidRequest request = TestUtil.newBidRequest(TestData.newRequest()); Bid bid = TestData.newBid(false) .setAdid("adId") .setCrid("creativeId") .setAdm("<img src=\"foo\">") .build(); NetworkBid.BidResponse.Ad.Builder ad = mapper.mapResponseAd(request, bid); assertThat(ad).isNotNull(); assertThat(ad.getHtmlSnippet()).isEqualTo("<img src=\"foo\">"); assertThat(ad.getBuyerCreativeId()).isEqualTo("creativeId"); assertThat(ad.hasVideoUrl()).isFalse(); }
@Test public void testResponse_multisizeBannerGood() { Imp.Builder imp = Imp.newBuilder() .setId("1") .setBanner( Banner.newBuilder().setId("1").setWmin(100).setWmax(200).setHmin(300).setHmax(400)) .setExtension( DcExt.adSlot, NetworkBid.BidRequest.AdSlot.newBuilder() .setId(0) .addAllWidth(asList(100, 200)) .addAllHeight(asList(300, 400)) .build()); Bid bid1 = TestData.newBid(false).build(); Bid bid2 = TestData.newBid(true).build(); OpenRtb.BidRequest request = OpenRtb.BidRequest.newBuilder().setId("1").addImp(imp).build(); NetworkBid.BidResponse.Ad.Builder ad1 = mapper.mapResponseAd(request, bid1); assertThat(!ad1.hasWidth() && !ad1.hasHeight()).isTrue(); NetworkBid.BidResponse.Ad.Builder ad2 = mapper.mapResponseAd(request, bid2); assertThat(ad2.getWidth()).isEqualTo(bid2.getW()); assertThat(ad2.getHeight()).isEqualTo(bid2.getH()); }