[Bidder Adapter] Add AdPlayx adapter - #4582
Conversation
## Type of Change - [x] New bidder adapter - [ ] Bug fix - [ ] Feature / Enhancement - [ ] Documentation update ## Description This PR adds the **AdPlayx** bidder adapter implementation (`adplayx`) to Prebid Server Java, supporting ORTB 2.6 requests for Banner and Video inventory. ### Key Changes Made: - Added `AdplayxBidder.java` to handle request construction with query parameters (`apptoken`, `placementid`) and bid response parsing. - Added `ExtImpAdplayx.java` model for extracting adapter parameters. - Added bidder configuration (`adplayx.yaml`, `AdplayxConfiguration.java`). - Added parameter validation schema (`static/bidder-params/adplayx.json`). - Added unit test suite `AdplayxBidderTest.java` targeting >80% code coverage using JUnit 5 and AssertJ. ## Checklist - [x] Code passes `checkstyle:check` without line length or final modifier violations. - [x] Unit tests pass locally (`mvn test -Dtest=AdplayxBidderTest`). - [x] Parameters match JSON schema defined in `static/bidder-params/adplayx.json`. - [x] Added configuration in `bidder-config/adplayx.yaml`. ## Testing Instructions Run unit tests locally: ```bash mvn test -Dtest=AdplayxBidderTest
CTMBNara
left a comment
There was a problem hiding this comment.
Update branch with latest master. Use Uri.java instead of macros (it will encode all the params, so make sure to not double encode them).
- Remove {{apptoken}} macro template from bidder config
- Append apptoken and placementid dynamically using URIBuilder
- Update unit tests to verify parameter building and single-encoding behavior
…/prebid-server-java into adding-adapter-adplayx
Resolved the review comments. |
Replace org.apache.http.client.utils.URIBuilder with org.prebid.server.util.Uri in AdplayxBidder to eliminate the deprecated Apache HTTP client dependency. - Updated buildEndpointUrl() to use Uri.of() and addQueryParam() - Updated AdplayxBidderTest assertions to align with Vert.x UriTemplate encoding style
CTMBNara
left a comment
There was a problem hiding this comment.
Add integration test. Use AxisTest as an example
| public class AdplayxBidder implements Bidder<BidRequest> { | ||
|
|
||
| private static final TypeReference<ExtPrebid<?, ExtImpAdplayx>> ADPLAYX_EXT_TYPE_REFERENCE = | ||
| new TypeReference<>() { }; |
There was a problem hiding this comment.
Format new TypeReference<>() { } according to project style
| } | ||
|
|
||
| private String buildEndpointUrl(ExtImpAdplayx extImp) { | ||
| return Uri.of(endpointUrl) |
There was a problem hiding this comment.
Move Uri.of(...) creation to adapter constructor
|
|
||
| final String uri = buildEndpointUrl(extImp); | ||
|
|
||
| // Clone bid request for this impression |
| httpRequests.add(HttpRequest.<BidRequest>builder() | ||
| .method(HttpMethod.POST) | ||
| .uri(uri) | ||
| .headers(HttpUtil.headers()) | ||
| .body(mapper.encodeToBytes(outgoingRequest)) | ||
| .payload(outgoingRequest) | ||
| .build()); |
There was a problem hiding this comment.
Use BidderUtil.defaultRequest
| if (StringUtils.isBlank(responseBody)) { | ||
| return Result.empty(); | ||
| } |
There was a problem hiding this comment.
No need for this check. Inline responseBody
| try { | ||
| final BidResponse bidResponse = mapper.decodeValue(responseBody, BidResponse.class); | ||
| if (bidResponse == null || bidResponse.getSeatbid() == null) { | ||
| return Result.empty(); | ||
| } | ||
|
|
||
| final List<BidderError> errors = new ArrayList<>(); | ||
| final List<BidderBid> bidderBids = new ArrayList<>(); | ||
|
|
||
| for (final SeatBid seatBid : bidResponse.getSeatbid()) { | ||
| for (final Bid bid : seatBid.getBid()) { | ||
| try { | ||
| final BidType bidType = getBidType(bid.getImpid(), bidRequest.getImp()); | ||
| bidderBids.add(BidderBid.of(bid, bidType, bidResponse.getCur())); | ||
| } catch (final PreBidException e) { | ||
| errors.add(BidderError.badServerResponse(e.getMessage())); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return Result.of(bidderBids, errors); | ||
| } catch (final Exception e) { | ||
| return Result.withError(BidderError.badServerResponse("Failed to decode response: " + e.getMessage())); | ||
| } | ||
| } | ||
|
|
||
| private BidType getBidType(String impId, List<Imp> imps) { | ||
| for (Imp imp : imps) { | ||
| if (imp.getId().equals(impId)) { | ||
| if (imp.getBanner() != null) { | ||
| return BidType.banner; | ||
| } | ||
| if (imp.getVideo() != null) { | ||
| return BidType.video; | ||
| } | ||
| if (imp.getAudio() != null) { | ||
| return BidType.audio; | ||
| } | ||
| if (imp.getXNative() != null) { | ||
| return BidType.xNative; | ||
| } | ||
| } | ||
| } | ||
| throw new PreBidException("Failed to find impression with id: " + impId); | ||
| } |
There was a problem hiding this comment.
Refactor this code to be similar to other adapters. See AxisBidder as an example
| @@ -0,0 +1,16 @@ | |||
| adapters: | |||
| adplayx: | |||
| enabled: true | |||
| app-media-types: | ||
| - banner | ||
| - video | ||
| site-media-types: | ||
| - banner | ||
| - video |
There was a problem hiding this comment.
I see a discrepancy between the code (supports all media types) and the supported media types (banner + video). If it's intended - then ok
Type of Change
Description
This PR adds the AdPlayx bidder adapter implementation (
adplayx) to Prebid Server Java, supporting ORTB 2.6 requests for Banner and Video inventory.Key Changes Made:
AdplayxBidder.javato handle request construction with query parameters (apptoken,placementid) and bid response parsing.ExtImpAdplayx.javamodel for extracting adapter parameters.adplayx.yaml,AdplayxConfiguration.java).static/bidder-params/adplayx.json).AdplayxBidderTest.javatargeting >80% code coverage using JUnit 5 and AssertJ.Checklist
checkstyle:checkwithout line length or final modifier violations.mvn test -Dtest=AdplayxBidderTest).static/bidder-params/adplayx.json.bidder-config/adplayx.yaml.Testing Instructions
Run unit tests locally: