Skip to content
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

IX: Add multi-format ad unit support #2078

Merged

Conversation

liliana-sortable
Copy link
Contributor

This is a port of prebid/prebid-server#2315

@@ -290,9 +292,28 @@ private static Response mergeNativeImpTrackers(Response response, List<EventTrac
.build();
}

private static BidType getBidType(String impId, List<Imp> imps) {
private static BidType getBidType(Bid bid, List<Imp> imps) {
Integer mType = bid.getMtype();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to project style, we prefer to use final keyword on variables declaration

private static BidType getBidType(String impId, List<Imp> imps) {
private static BidType getBidType(Bid bid, List<Imp> imps) {
Integer mType = bid.getMtype();
BidType bidType = mType != null ? switch (bid.getMtype()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems bidType resolving logic can be moved to separate function

return bidType;
}

Optional<String> prebidType = Optional.ofNullable(bid.getExt())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you will move logic from 315 line to separate method, then you code will be easily simplified to

return Optional.ofNullable(bid.getExt())
...
.orElseGet(()->methodWithLogicFrom315Line());

@@ -636,6 +636,68 @@ public void makeBidsShouldReturnValidAdmIfNativeIsPresentInImpAndAdm12() throws
.containsExactly(mapper.writeValueAsString(expectedNativeResponse));
}

@Test
public void makeBidsShouldReturnCorrectTypeMTypeInResponse() throws JsonProcessingException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeBidsShouldReturnVideoBidIfMtypeIsTwo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also pls create test for every mtype possible value

.map(prebid -> prebid.get("type"))
.map(JsonNode::asText)
.map(BidType::fromString)
.orElse(getBidTypeFromImp(imps, bid.getImpid()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using orElse argument value will always be calculated, to had it calculated only if really needed
pls use (.orElseGet(() -> getBidTypeFromImp(imps, bid.getImpid())))


// when
final Result<List<BidderBid>> result = ixBidder.makeBids(httpCall, null);
// then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls make 768 line empty

.mtype(4))));

// when
final Result<List<BidderBid>> result = ixBidder.makeBids(httpCall, null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer to have empty line betweengiven when then blocks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also pls check for similar occurences

src/main/java/org/prebid/server/bidder/ix/IxBidder.java Outdated Show resolved Hide resolved
Comment on lines 775 to 781
assertThat(result.getValue())
.extracting(BidderBid::getBid)
.extracting(Bid::getExt)
.extracting(ext -> ext.get("prebid"))
.extracting(node -> mapper.treeToValue(node, ExtBidPrebid.class))
.extracting(ExtBidPrebid::getType)
.containsExactly(BidType.video);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to assert our input?

Copy link
Contributor Author

@liliana-sortable liliana-sortable Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something could have altered the ext object while processing the incoming bid. We expect it to stay the same.
If it seems an unnecessary check I can take it out.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the adapter can affect this result. If logic appears that somehow changes this object, the corresponding test will be written.

@liliana-sortable liliana-sortable requested review from CTMBNara and removed request for SerhiiNahornyi December 6, 2022 19:28
@SerhiiNahornyi SerhiiNahornyi merged commit f9f6408 into prebid:master Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants