-
Notifications
You must be signed in to change notification settings - Fork 207
GumGum: Collect the ad unit name for reporting #3912
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
base: master
Are you sure you want to change the base?
Conversation
src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java
Outdated
Show resolved
Hide resolved
src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java
Outdated
Show resolved
Hide resolved
src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java
Outdated
Show resolved
Hide resolved
src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java
Outdated
Show resolved
Hide resolved
src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java
Outdated
Show resolved
Hide resolved
src/main/java/org/prebid/server/bidder/gumgum/GumgumBidder.java
Outdated
Show resolved
Hide resolved
Thank you for the review, I am looking into the comments. |
@ShayanK16GumGum any updates on this one? |
The code changes are done, will push. @osulzhenko |
|
@osulzhenko looking into it and fixing. |
@ShayanK16GumGum any updates on this one? |
@osulzhenko I have pushed the changes. Please have a look. |
private String extractAdUnitCode(Imp imp) { | ||
final ExtPrebid<?, ExtImpGumgum> extPrebid = mapper.mapper() | ||
.convertValue(imp.getExt(), GUMGUM_EXT_TYPE_REFERENCE); | ||
|
||
return Optional.ofNullable(extPrebid.getPrebid()) | ||
.map(prebid -> mapper.mapper().convertValue(prebid, ExtImpPrebid.class)) | ||
.map(ExtImpPrebid::getAdUnitCode) | ||
.orElse(null); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this method, use the following approach:
private static final TypeReference<ExtPrebid<ExtImpPrebid, ExtImpGumgum>> GUMGUM_EXT_TYPE_REFERENCE =
new TypeReference<>() {
};
private ExtPrebid<ExtImpPrebid, ExtImpGumgum> parseImpExt(Imp imp) {
try {
return mapper.mapper().convertValue(imp.getExt(), GUMGUM_EXT_TYPE_REFERENCE);
} catch (IllegalArgumentException e) {
throw new PreBidException(e.getMessage());
}
}
final ExtPrebid<ExtImpPrebid, ExtImpGumgum> extImp = parseImpExt(imp);
final ExtImpGumgum extImpGumgum = extImp.getBidder();
final String adUnitCode = Optional.ofNullable(extImp.getPrebid())
.map(ExtImpPrebid::getAdUnitCode)
.orElse(null);
modifiedImps.add(modifyImp(imp, extImpGumgum, adUnitCode));
final String extZone = extImpGumgum.getZone();
if (StringUtils.isNotEmpty(extZone)) {
zone = extZone;
}
final BigInteger extPubId = extImpGumgum.getPubId();
if (extPubId != null && !extPubId.equals(BigInteger.ZERO)) {
pubId = extPubId;
}
|
||
@Test | ||
public void testMakeHttpRequestsShouldNotSetTagIdFromZoneWhenAdUnitIdIsMissing() throws IOException { | ||
//given:Imp without adUnitId but with zone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No explanation needed. The method name already does that. Just leave // given
//given | ||
final BidRequest bidRequest = givenBidRequest(impBuilder -> | ||
impBuilder.ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))); | ||
|
||
//when | ||
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest); | ||
|
||
//then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// given
// when
// then
and fix it in other places
//when | ||
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest); | ||
|
||
//deserialize byte[] body into BidRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this comment
final byte[] requestBody = result.getValue().get(0).getBody(); | ||
final BidRequest modifiedRequest = mapper.readValue(requestBody, BidRequest.class); | ||
|
||
//then | ||
assertThat(modifiedRequest.getImp()).hasSize(1); | ||
assertThat(modifiedRequest.getImp()) | ||
.extracting(Imp::getTagid) | ||
.containsExactly("adUnit123"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor other tests in the same style:
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getTagid)
.containsExactly("adUnit123");
🔧 Type of changes
✨ What's the context?
What's the context for the 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