@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(expected = MapperException.class) public void testResponse_nonExistingImp() { OpenRtb.BidRequest request = TestUtil.newBidRequest( NetworkBid.BidRequest.newBuilder() .setId(TestUtil.REQUEST_ID) .addAdslot(AdSlot.newBuilder().setId(5)) .addAdslot(AdSlot.newBuilder().setId(10))); mapper.toExchangeBidResponse(request, TestUtil.newBidResponse(TestData.newBid(false))); }
@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()); }