New Adapter: Synapse HX#4532
Conversation
| private static final TypeReference<ExtPrebid<?, ExtImpSynapseHX>> SYNAPSE_HX_EXT_TYPE_REFERENCE = | ||
| new TypeReference<>() { }; |
There was a problem hiding this comment.
new TypeReference<>() {
};
| private static final TypeReference<ExtPrebid<ExtBidPrebid, ?>> EXT_PREBID_TYPE_REFERENCE = | ||
| new TypeReference<>() { }; |
| private static Imp validateImp(Imp imp, List<BidderError> errors) { | ||
| if (imp.getBanner() == null && imp.getVideo() == null) { | ||
| errors.add(BidderError.badInput( | ||
| "imp[%s]: Unsupported media type, bidder supports only banner and video".formatted(imp.getId()))); | ||
| return null; | ||
| } | ||
| if (imp.getXNative() != null || imp.getAudio() != null) { | ||
| return imp.toBuilder().xNative(null).audio(null).build(); | ||
| } | ||
| return imp; |
There was a problem hiding this comment.
This logic is not present in go + we have auction.filter-imp-media-type that will do the same job.
| try { | ||
| tenantId = mapper.mapper() | ||
| .convertValue(firstImp.getExt(), SYNAPSE_HX_EXT_TYPE_REFERENCE) | ||
| .getBidder() | ||
| .getTenantId(); | ||
| } catch (IllegalArgumentException e) { | ||
| return Result.withError(BidderError.badInput("Failed to parse bidder parameters")); | ||
| } |
There was a problem hiding this comment.
Please, extract to separate method.
| final URIBuilder uriBuilder; | ||
| try { | ||
| uriBuilder = new URIBuilder(endpoint); | ||
| } catch (URISyntaxException e) { | ||
| return Result.withError(BidderError.badInput("Invalid endpoint URI")); | ||
| } |
There was a problem hiding this comment.
Please, extract to separate method.
| @Test | ||
| public void makeHttpRequestsShouldReturnErrorWhenImpressionContainsOnlyAudioAndNative() { | ||
| // given | ||
| final Audio audio = Audio.builder().mimes(List.of("audio/mp3")).build(); |
There was a problem hiding this comment.
List.of -> static singletonList
|
|
||
| // then | ||
| assertThat(result.getValue()).isEmpty(); | ||
| assertThat(result.getErrors()).hasSize(1).contains( |
| @Test | ||
| public void makeHttpRequestsShouldRemoveAudioAndNativeFromImpressionIfItContainsSupportedMediaTypes() { | ||
| // given | ||
| final Audio audio = Audio.builder().mimes(List.of("audio/mp3")).build(); |
| public void makeBidsShouldReportErrorAndSkipBidIfCannotParseBidType() throws JsonProcessingException { | ||
| // given | ||
| final BidderCall<BidRequest> httpCall = givenHttpCall(null, | ||
| givenBidResponse( | ||
| givenBid("Imp1", BidType.banner), | ||
| givenBidWithMType("Imp2", BidType.banner), | ||
| givenBid("Imp3", BidType.video), | ||
| givenBidWithMType("Imp4", BidType.video), | ||
| givenBid("Imp5", BidType.xNative), | ||
| givenBidWithMType("Imp6", BidType.xNative), | ||
| givenBid("Imp7", BidType.audio), | ||
| givenBidWithMType("Imp8", BidType.audio), | ||
| givenBid("Imp9", BidType.banner).toBuilder().ext(null).build())); | ||
|
|
||
| // when | ||
| final Result<List<BidderBid>> result = target.makeBids(httpCall, null); | ||
|
|
||
| // then | ||
| assertThat(result.getErrors()).hasSize(5).allSatisfy( | ||
| error -> assertThat( | ||
| error.getMessage()).startsWith("Unsupported media type")); | ||
| assertThat(result.getValue()).hasSize(4).allSatisfy( | ||
| bid -> assertThat(bid.getBid().getImpid()).isIn(List.of("Imp1", "Imp2", "Imp3", "Imp4"))); | ||
| } |
There was a problem hiding this comment.
Please, split tests into smaller pieces.
| "ext": { | ||
| "synapsehx": { | ||
| "tenantId": "tenant-id-0", | ||
| "adUnitId": "ad-unit-id-0" |
There was a problem hiding this comment.
Please remove unused fields, integration tests are used as happy-path tests. Logic has to be tested in unit tests. IT tests should be as simple as possible. You can take generic/test-generic-bid-request.json as a reference point.
🔧 Type of changes
✨ What's the context?
New bidder adapter for Synapse HX
Maintainer: prebid@compas-inc.com
Related Changes
🧠 Rationale behind the change
Why did you choose to make these changes? Were there any trade-offs you had to consider?
🔎 New Bid Adapter Checklist
🧪 Test plan
How do you know the changes are safe to ship to production?
🏎 Quality check