@Test(expected = MapperException.class) public void testResponse_impWithoutAd() { OpenRtb.BidRequest request = OpenRtb.BidRequest.newBuilder().setId("1").addImp(Imp.newBuilder().setId("1")).build(); Bid bid = TestData.newBid(false).setAdm("snippet").build(); NetworkBid.BidResponse.Ad.Builder ad = mapper.mapResponseAd(request, bid); assertThat(ad).isNotNull(); }
@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()); }