@Test
 public void testRequest_deals() {
   NetworkBid.BidRequest dcRequest = TestData.newRequest(5, false, false).build();
   OpenRtb.BidRequest request = mapper.toOpenRtbBidRequest(dcRequest).build();
   Pmp pmp = request.getImp(0).getPmp();
   assertThat(pmp.getExtension(DcExt.adData).getDirectDealCount()).isEqualTo(3);
   assertThat(pmp.getDealsCount()).isEqualTo(2);
   Pmp.Deal deal = pmp.getDeals(1);
   assertThat(deal.getId()).isEqualTo("44");
   assertThat(deal.getBidfloor()).isWithin(1e-9).of(1.2);
 }
 @Test
 public void testReqResp_NullMapper() {
   NullDoubleClickOpenRtbMapper mapper = NullDoubleClickOpenRtbMapper.INSTANCE;
   assertThat(
           mapper.toExchangeBidResponse(
               OpenRtb.BidRequest.getDefaultInstance(), OpenRtb.BidResponse.getDefaultInstance()))
       .isNull();
   assertThat(mapper.toOpenRtbBidRequest(TestData.newRequest())).isNull();
   assertThat(mapper.toExchangeBidRequest(OpenRtb.BidRequest.getDefaultInstance())).isNull();
   assertThat(
           mapper.toOpenRtbBidResponse(
               TestData.newRequest(), NetworkBid.BidResponse.getDefaultInstance()))
       .isNull();
 }
 @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 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 testRequest_ping() {
   NetworkBid.BidRequest dcRequest =
       NetworkBid.BidRequest.newBuilder().setId(TestUtil.REQUEST_ID).setIsPing(true).build();
   OpenRtb.BidRequest request = mapper.toOpenRtbBidRequest(dcRequest).build();
   assertThat(request)
       .isEqualTo(
           OpenRtb.BidRequest.newBuilder()
               .setId(
                   Base64.getUrlEncoder()
                       .withoutPadding()
                       .encodeToString(dcRequest.getId().toByteArray()))
               .build());
 }
 @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());
 }