Repository navigation
Nativo adapter: Update bid type resolution #4690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,6 +264,83 @@ public void makeBidsShouldReturnErrorAndOriginalBidWhenBidExtCannotBeParsed() | |
| assertThat(result.getValue().getFirst().getBid().getExt()).isEqualTo(invalidExt); | ||
| } | ||
|
|
||
| @Test | ||
| public void makeBidsShouldReturnNativeBidWhenMtypeIsNative() throws JsonProcessingException { | ||
| // given | ||
| final BidRequest bidRequest = givenBidRequest(imp -> imp.id("imp1")); | ||
| final Bid bid = givenBid("bid1", "imp1", 4); | ||
| final BidderCall<BidRequest> httpCall = givenHttpCall(bidRequest, givenBidResponse(singletonList(bid))); | ||
|
|
||
| // when | ||
| final Result<List<BidderBid>> result = target.makeBids(httpCall, bidRequest); | ||
|
|
||
| // then | ||
| assertThat(result.getErrors()).isEmpty(); | ||
| assertThat(result.getValue()).containsExactly(BidderBid.of(bid, BidType.xNative, "USD")); | ||
| } | ||
|
|
||
| @Test | ||
| public void makeBidsShouldReturnBannerBidWhenMtypeIsBanner() throws JsonProcessingException { | ||
| // given | ||
| final BidRequest bidRequest = givenBidRequest(imp -> imp.id("imp1")); | ||
| final Bid bid = givenBid("bid1", "imp1", 1); | ||
| final BidderCall<BidRequest> httpCall = givenHttpCall(bidRequest, givenBidResponse(singletonList(bid))); | ||
|
|
||
| // when | ||
| final Result<List<BidderBid>> result = target.makeBids(httpCall, bidRequest); | ||
|
|
||
| // then | ||
| assertThat(result.getErrors()).isEmpty(); | ||
| assertThat(result.getValue()).containsExactly(BidderBid.of(bid, BidType.banner, "USD")); | ||
| } | ||
|
Comment on lines
+282
to
+295
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
|
||
| @Test | ||
| public void makeBidsShouldReturnVideoBidWhenMtypeIsVideo() throws JsonProcessingException { | ||
| // given | ||
| final BidRequest bidRequest = givenBidRequest(imp -> imp.id("imp1")); | ||
| final Bid bid = givenBid("bid1", "imp1", 2); | ||
| final BidderCall<BidRequest> httpCall = givenHttpCall(bidRequest, givenBidResponse(singletonList(bid))); | ||
|
|
||
| // when | ||
| final Result<List<BidderBid>> result = target.makeBids(httpCall, bidRequest); | ||
|
|
||
| // then | ||
| assertThat(result.getErrors()).isEmpty(); | ||
| assertThat(result.getValue()).containsExactly(BidderBid.of(bid, BidType.video, "USD")); | ||
| } | ||
|
Comment on lines
+297
to
+310
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
|
||
| @Test | ||
| public void makeBidsShouldReturnAudioBidWhenMtypeIsAudio() throws JsonProcessingException { | ||
| // given | ||
| final BidRequest bidRequest = givenBidRequest(imp -> imp.id("imp1")); | ||
| final Bid bid = givenBid("bid1", "imp1", 3); | ||
| final BidderCall<BidRequest> httpCall = givenHttpCall(bidRequest, givenBidResponse(singletonList(bid))); | ||
|
|
||
| // when | ||
| final Result<List<BidderBid>> result = target.makeBids(httpCall, bidRequest); | ||
|
|
||
| // then | ||
| assertThat(result.getErrors()).isEmpty(); | ||
| assertThat(result.getValue()).containsExactly(BidderBid.of(bid, BidType.audio, "USD")); | ||
| } | ||
|
Comment on lines
+312
to
+325
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove banner from imp |
||
|
|
||
| @Test | ||
| public void makeBidsShouldReturnBidTypeFromImpWhenMtypeIsUnrecognized() throws JsonProcessingException { | ||
| // given | ||
| final BidRequest bidRequest = givenBidRequest(imp -> imp.id("imp1") | ||
| .banner(Banner.builder().build()) | ||
| .xNative(Native.builder().build())); | ||
| final Bid bid = givenBid("bid1", "imp1", 7); | ||
| final BidderCall<BidRequest> httpCall = givenHttpCall(bidRequest, givenBidResponse(singletonList(bid))); | ||
|
|
||
| // when | ||
| final Result<List<BidderBid>> result = target.makeBids(httpCall, bidRequest); | ||
|
|
||
| // then | ||
| assertThat(result.getErrors()).isEmpty(); | ||
| assertThat(result.getValue()).containsExactly(BidderBid.of(bid, BidType.banner, "USD")); | ||
| } | ||
|
|
||
| private static BidRequest givenBidRequest(UnaryOperator<Imp.ImpBuilder> impCustomizer) { | ||
| return BidRequest.builder() | ||
| .imp(singletonList(impCustomizer.apply(Imp.builder().id("imp1")).build())) | ||
|
|
@@ -282,11 +359,16 @@ private static BidRequest givenBidRequestWithRenderer(UnaryOperator<Imp.ImpBuild | |
| } | ||
|
|
||
| private static Bid givenBid(String id, String impId) { | ||
| return givenBid(id, impId, null); | ||
| } | ||
|
|
||
| private static Bid givenBid(String id, String impId, Integer mtype) { | ||
| return Bid.builder() | ||
| .id(id) | ||
| .impid(impId) | ||
| .price(BigDecimal.valueOf(1.5)) | ||
| .adm("adm001") | ||
| .mtype(mtype) | ||
| .build(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change test name to
makeBidsShouldReturnNativeBidWhenMtypeIsNative. Remove banner and native from imp