@Test public void testExtMapper() { ExtMapper extMapper = new ExtMapper() {}; extMapper.toOpenRtbBidRequest( NetworkBid.BidRequest.getDefaultInstance(), OpenRtb.BidRequest.newBuilder()); extMapper.toOpenRtbDevice( NetworkBid.BidRequest.getDefaultInstance(), OpenRtb.BidRequest.Device.newBuilder()); extMapper.toOpenRtbImp( NetworkBid.BidRequest.AdSlot.getDefaultInstance(), OpenRtb.BidRequest.Imp.newBuilder()); extMapper.toOpenRtbBanner( NetworkBid.BidRequest.AdSlot.getDefaultInstance(), OpenRtb.BidRequest.Imp.Banner.newBuilder()); extMapper.toOpenRtbVideo( NetworkBid.BidRequest.Video.getDefaultInstance(), OpenRtb.BidRequest.Imp.Video.newBuilder()); extMapper.toOpenRtbPmp( NetworkBid.BidRequest.AdSlot.MatchingAdData.getDefaultInstance(), OpenRtb.BidRequest.Imp.Pmp.newBuilder()); extMapper.toDoubleClickAd( OpenRtb.BidRequest.getDefaultInstance(), OpenRtb.BidResponse.SeatBid.Bid.getDefaultInstance(), NetworkBid.BidResponse.Ad.newBuilder()); }
@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()); }