Skip to content

New Adapter: Synapse HX#4532

Open
prebid-compas wants to merge 1 commit into
prebid:masterfrom
prebid-compas:implement-synapsehx-adapter
Open

New Adapter: Synapse HX#4532
prebid-compas wants to merge 1 commit into
prebid:masterfrom
prebid-compas:implement-synapsehx-adapter

Conversation

@prebid-compas

Copy link
Copy Markdown

🔧 Type of changes

  • new bid adapter
  • bid adapter update
  • new feature
  • new analytics adapter
  • new module
  • module update
  • bugfix
  • documentation
  • configuration
  • dependency update
  • tech debt (test coverage, refactorings, etc.)

✨ 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

  • verify email contact works
  • NO fully dynamic hostnames
  • geographic host parameters are NOT required
  • direct use of HTTP is prohibited - implement an existing Bidder interface that will do all the job
  • if the ORTB is just forwarded to the endpoint, use the generic adapter - define the new adapter as the alias of the generic adapter
  • cover an adapter configuration with an integration test

🧪 Test plan

How do you know the changes are safe to ship to production?

🏎 Quality check

  • Are your changes following our code style guidelines?
  • Are there any breaking changes in your code?
  • Does your test coverage exceed 90%?
  • Are there any erroneous console logs, debuggers or leftover code in your changes?

Comment on lines +37 to +38
private static final TypeReference<ExtPrebid<?, ExtImpSynapseHX>> SYNAPSE_HX_EXT_TYPE_REFERENCE =
new TypeReference<>() { };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

new TypeReference<>() {
};

Comment on lines +40 to +41
private static final TypeReference<ExtPrebid<ExtBidPrebid, ?>> EXT_PREBID_TYPE_REFERENCE =
new TypeReference<>() { };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here.

Comment on lines +96 to +105
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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This logic is not present in go + we have auction.filter-imp-media-type that will do the same job.

Comment on lines +72 to +79
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"));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please, extract to separate method.

Comment on lines +85 to +90
final URIBuilder uriBuilder;
try {
uriBuilder = new URIBuilder(endpoint);
} catch (URISyntaxException e) {
return Result.withError(BidderError.badInput("Invalid endpoint URI"));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please, extract to separate method.

@Test
public void makeHttpRequestsShouldReturnErrorWhenImpressionContainsOnlyAudioAndNative() {
// given
final Audio audio = Audio.builder().mimes(List.of("audio/mp3")).build();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

List.of -> static singletonList


// then
assertThat(result.getValue()).isEmpty();
assertThat(result.getErrors()).hasSize(1).contains(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

containsExactly

@Test
public void makeHttpRequestsShouldRemoveAudioAndNativeFromImpressionIfItContainsSupportedMediaTypes() {
// given
final Audio audio = Audio.builder().mimes(List.of("audio/mp3")).build();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here.

Comment on lines +178 to +201
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")));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please, split tests into smaller pieces.

"ext": {
"synapsehx": {
"tenantId": "tenant-id-0",
"adUnitId": "ad-unit-id-0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

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