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

Tradplus #3508

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Tradplus #3508

wants to merge 11 commits into from

Conversation

tradplus
Copy link

TradPlus is a leading, stable, and reliable ad monetization platform that is committed to providing global developers with fair, transparent and efficient monetization solutions. We also provide ADX and Saas ADX services. We serve 2,000+ global developers. Moreover, Our SDK has been certified by IAB Tech Lab and also joins Google Play SDK Index. And we have Information Security Management Certification.

Our advertising business spans the world. This is our official website: https://tradplusad.com/en. You can get more details about TradPlus.

this is TradPlus adapter version 1.0.

Thank!


@Override
public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest bidRequest) {
final Map<ExtImpTradPlus, List<Imp>> extToImps = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

using a map here is an overhead since only one single imp is really utilized to retrieve the ext object, please get rid of it

Copy link
Author

Choose a reason for hiding this comment

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

I have changed these codes,please review these codes.

Comment on lines 96 to 99
private static List<Imp> removeFirstImpExt(List<Imp> imps) {
imps.set(0, imps.getFirst().toBuilder().ext(null).build());
return imps;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks redundant since the list of imps always has a single imp

Copy link
Author

Choose a reason for hiding this comment

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

I have changed these codes,please review these codes.

public Result<List<BidderBid>> makeBids(BidderCall<BidRequest> httpCall, BidRequest bidRequest) {
try {
final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class);
return Result.of(extractBids(bidResponse, httpCall.getRequest().getPayload()), Collections.emptyList());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Result.withValues()

Copy link
Author

Choose a reason for hiding this comment

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

I have changed these codes,please review these codes.

import static org.prebid.server.proto.openrtb.ext.response.BidType.video;
import static org.prebid.server.proto.openrtb.ext.response.BidType.xNative;

public class TradPlusBidderTest extends VertxTest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there is no any test that covers the outgoing http request:

  • payload: the basic logic of using only a single imp ignoring others
  • headers
  • impIds object

Copy link
Author

Choose a reason for hiding this comment

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

done, please review these codes.

@@ -455,6 +455,8 @@ adapters.telaria.enabled=true
adapters.telaria.endpoint=http://localhost:8090/telaria-exchange/
adapters.theadx.enabled=true
adapters.theadx.endpoint=http://localhost:8090/theadx-exchange
adapters.tradplus.enabled=true
adapters.tradplus.endpoint=http://localhost:8090/tradplus-exchange
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add the macros to the url to check them in the integration test

Copy link
Author

Choose a reason for hiding this comment

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

done.

private ExtImpTradPlus parseImpExt(ObjectNode extNode) {
final ExtImpTradPlus extImpTradPlus;
try {
extImpTradPlus = mapper.mapper().convertValue(extNode, EXT_TYPE_REFERENCE).getBidder();
Copy link
Collaborator

Choose a reason for hiding this comment

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

just return here

Copy link
Author

Choose a reason for hiding this comment

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

done.

Comment on lines 93 to 95
final MultiMap headers = HttpUtil.headers();
headers.set(HttpUtil.X_OPENRTB_VERSION_HEADER, X_OPENRTB_VERSION);
return headers;
Copy link
Collaborator

Choose a reason for hiding this comment

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

return HttpUtil.headers().set(HttpUtil.X_OPENRTB_VERSION_HEADER, X_OPENRTB_VERSION);

Copy link
Author

Choose a reason for hiding this comment

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

done.


@Override
public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest bidRequest) {
final List<HttpRequest<BidRequest>> httpRequests = new ArrayList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see the point to have the list if it's always only a single one

Copy link
Author

Choose a reason for hiding this comment

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

I have changed these codes,please review these codes.

try {
final ExtImpTradPlus extImpTradPlus = parseImpExt(bidRequest.getImp().getFirst().getExt());
validateImpExt(extImpTradPlus);
httpRequests.add(makeHttpRequest(extImpTradPlus, bidRequest.getImp(), bidRequest));
Copy link
Collaborator

Choose a reason for hiding this comment

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

return the request here

Copy link
Author

Choose a reason for hiding this comment

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

done.

Comment on lines 81 to 82
.satisfies(headers -> assertThat(headers.get(X_OPENRTB_VERSION_HEADER))
.isEqualTo("2.5"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

please assert the default headers as well

Copy link
Author

Choose a reason for hiding this comment

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

done.

Comment on lines +59 to +63
assertThat(result.getValue()).hasSize(1)
.extracting(HttpRequest::getPayload)
.extracting(BidRequest::getImp)
.extracting(List::size)
.containsOnly(2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

imp ext clean-up isn't covered

Copy link
Author

Choose a reason for hiding this comment

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

done.

BidRequest.builder()
.imp(singletonList(Imp.builder().id("123").build()))
.build(),
mapper.writeValueAsString(
Copy link
Collaborator

Choose a reason for hiding this comment

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

please hide the mapper.writeValueAsString call inside the givenBidResponse

Copy link
Author

Choose a reason for hiding this comment

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

done.

Copy link
Collaborator

@AntoxaAntoxic AntoxaAntoxic Oct 25, 2024

Choose a reason for hiding this comment

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

it's not done

why do you serialize twice?


// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
Copy link
Collaborator

Choose a reason for hiding this comment

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

        assertThat(result.getValue())
                .extracting(HttpRequest::getPayload)
                .flatExtracting(BidRequest::getImp)
                .extracting(Imp::getExt)
                .containsOnlyNulls();

}

private static List<BidderBid> extractBids(BidResponse bidResponse, BidRequest bidRequest) {
return bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid()) ? Collections.emptyList() : bidsFromResponse(bidResponse, bidRequest.getImp());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suspect this line fails checkstyle, please run it locally to check

Copy link
Collaborator

Choose a reason for hiding this comment

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

Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/main/java/org/prebid/server/bidder/tradplus/TradPlusBidder.java:27:8: Unused import - java.util.ArrayList. [UnusedImports]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/main/java/org/prebid/server/bidder/tradplus/TradPlusBidder.java:56:37: Variable 'httpRequest' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/main/java/org/prebid/server/bidder/tradplus/TradPlusBidder.java:79: Line is longer than 120 characters (found 123). [LineLength]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/main/java/org/prebid/server/bidder/tradplus/TradPlusBidder.java:80: Line is longer than 120 characters (found 135). [LineLength]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/main/java/org/prebid/server/bidder/tradplus/TradPlusBidder.java:106: Line is longer than 120 characters (found 167). [LineLength]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/main/java/org/prebid/server/bidder/tradplus/TradPlusBidder.java:110: Line is longer than 120 characters (found 243). [LineLength]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/main/java/org/prebid/server/bidder/tradplus/TradPlusBidder.java:125: Line is longer than 120 characters (found 134). [LineLength]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/tradplus/TradPlusBidderTest.java:324: Line is longer than 120 characters (found 131). [LineLength]

@AntoxaAntoxic
Copy link
Collaborator

The build is still red, please fix the checkstyle

also please do not forget about this comment as well

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.

2 participants