Skip to content

Commit 97c61ec

Browse files
fix comments
1 parent 86b00f3 commit 97c61ec

File tree

5 files changed

+15
-57
lines changed

5 files changed

+15
-57
lines changed

src/main/java/org/prebid/server/bidder/adverxo/AdverxoBidder.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package org.prebid.server.bidder.adverxo;
22

3-
import com.fasterxml.jackson.core.JsonProcessingException;
43
import com.fasterxml.jackson.core.type.TypeReference;
5-
import com.fasterxml.jackson.databind.JsonNode;
64
import com.iab.openrtb.request.BidRequest;
75
import com.iab.openrtb.request.Imp;
86
import com.iab.openrtb.response.Bid;
@@ -86,9 +84,9 @@ private ExtImpAdverxo parseImpExt(Imp imp) {
8684
}
8785

8886
private String resolveEndpoint(ExtImpAdverxo extImp) {
87+
final String adUnitId = String.valueOf(extImp.getAdUnitId());
8988
return endpointUrl
90-
.replace(ADUNIT_MACROS_ENDPOINT,
91-
extImp.getAdUnitId() == null ? StringUtils.EMPTY : String.valueOf(extImp.getAdUnitId()))
89+
.replace(ADUNIT_MACROS_ENDPOINT, adUnitId == null ? "0" : adUnitId)
9290
.replace(AUTH_MACROS_ENDPOINT, HttpUtil.encodeUrl(StringUtils.defaultString(extImp.getAuth())));
9391
}
9492

@@ -135,7 +133,6 @@ public Result<List<BidderBid>> makeBids(BidderCall<BidRequest> httpCall, BidRequ
135133
}
136134

137135
private List<BidderBid> extractBids(BidResponse bidResponse) {
138-
139136
if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) {
140137
return Collections.emptyList();
141138
}
@@ -152,7 +149,7 @@ private List<BidderBid> extractBids(BidResponse bidResponse) {
152149

153150
private BidderBid makeBid(Bid bid, String currency) {
154151
final BidType bidType = getBidType(bid.getMtype());
155-
final String resolvedAdm = resolveAdmForBidType(bid, bidType);
152+
final String resolvedAdm = bidType == BidType.xNative ? resolveAdm(bid.getAdm(), bid.getPrice()) : bid.getAdm();
156153
final Bid processedBid = processBidMacros(bid, resolvedAdm);
157154

158155
return BidderBid.of(processedBid, bidType, currency);
@@ -167,20 +164,6 @@ private static BidType getBidType(Integer mType) {
167164
};
168165
}
169166

170-
private String resolveAdmForBidType(Bid bid, BidType bidType) {
171-
if (bidType != BidType.xNative) {
172-
return bid.getAdm();
173-
}
174-
175-
try {
176-
final JsonNode admNode = mapper.mapper().readTree(bid.getAdm());
177-
final JsonNode nativeNode = admNode.get("native");
178-
return nativeNode != null ? nativeNode.toString() : bid.getAdm();
179-
} catch (JsonProcessingException e) {
180-
throw new PreBidException("Error parsing native ADM: " + e.getMessage());
181-
}
182-
}
183-
184167
private static Bid processBidMacros(Bid bid, String adm) {
185168
final String price = bid.getPrice() != null ? bid.getPrice().toPlainString() : "0";
186169

@@ -192,4 +175,8 @@ private static Bid processBidMacros(Bid bid, String adm) {
192175
private static String replaceMacro(String input, String value) {
193176
return input != null ? input.replace(PRICE_MACRO, value) : null;
194177
}
178+
179+
private static String resolveAdm(String bidAdm, BigDecimal price) {
180+
return StringUtils.isNotBlank(bidAdm) ? bidAdm.replace("${AUCTION_PRICE}", String.valueOf(price)) : bidAdm;
181+
}
195182
}

src/main/java/org/prebid/server/proto/openrtb/ext/request/adverxo/ExtImpAdverxo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ public class ExtImpAdverxo {
1010

1111
@JsonProperty("adUnitId")
1212
Integer adUnitId;
13-
@JsonProperty("auth")
1413
String auth;
1514
}

src/main/java/org/prebid/server/spring/config/bidder/AdverxoBidderConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ BidderConfigurationProperties configurationProperties() {
3131
@Bean
3232
BidderDeps adverxoBidderDeps(BidderConfigurationProperties adverxoConfigurationProperties,
3333
@NotBlank @Value("${external-url}") String externalUrl,
34-
JacksonMapper mapper, CurrencyConversionService currencyConversionService) {
34+
JacksonMapper mapper,
35+
CurrencyConversionService currencyConversionService) {
3536

3637
return BidderDepsAssembler.forBidder(BIDDER_NAME)
3738
.withConfig(adverxoConfigurationProperties)

src/main/resources/bidder-config/adverxo.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ adapters:
77
enabled: false
88
endpoint: https://adport.pbsadverxo.com/auction?id={{adUnitId}}&auth={{auth}}
99
usersync:
10-
enabled: true
10+
enabled: false
1111
cookie-family-name: adport
1212
iframe:
1313
url: https://adport.pbsadverxo.com/usync?type=iframe&gdpr={{gdpr}}&consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}}
@@ -21,7 +21,7 @@ adapters:
2121
enabled: false
2222
endpoint: https://bidsmind.pbsadverxo.com/auction?id={{adUnitId}}&auth={{auth}}
2323
usersync:
24-
enabled: true
24+
enabled: false
2525
cookie-family-name: bidsmind
2626
iframe:
2727
url: https://bidsmind.pbsadverxo.com/usync?type=iframe&gdpr={{gdpr}}&consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}}
@@ -35,7 +35,7 @@ adapters:
3535
enabled: false
3636
endpoint: https://mobupps.pbsadverxo.com/auction?id={{adUnitId}}&auth={{auth}}
3737
usersync:
38-
enabled: true
38+
enabled: false
3939
cookie-family-name: mobupps
4040
iframe:
4141
url: https://mobupps.pbsadverxo.com/usync?type=iframe&gdpr={{gdpr}}&consent={{gdpr_consent}}&us_privacy={{us_privacy}}&redirect={{redirect_url}}

src/test/java/org/prebid/server/bidder/adverxo/AdverxoBidderTest.java

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ public void creationShouldFailOnInvalidEndpointUrl() {
6363
public void makeHttpRequestsShouldReturnErrorIfImpExtInvalid() {
6464
// given
6565
final BidRequest bidRequest = givenBidRequest(impBuilder ->
66-
impBuilder.ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))
67-
);
66+
impBuilder.ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode()))));
6867

6968
// when
7069
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
@@ -103,8 +102,7 @@ public void makeHttpRequestsShouldConvertCurrencyIfNeeded() {
103102
final BidRequest bidRequest = givenBidRequest(impBuilder ->
104103
impBuilder
105104
.bidfloor(bidFloor)
106-
.bidfloorcur(bidFloorCur)
107-
);
105+
.bidfloorcur(bidFloorCur));
108106

109107
// when
110108
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
@@ -291,34 +289,7 @@ public void makeBidsShouldHandleNativeAdmParsing() throws JsonProcessingExceptio
291289
final Result<List<BidderBid>> result = target.makeBids(httpCall, null);
292290

293291
// then
294-
assertThat(result.getValue().get(0).getBid().getAdm()).isEqualTo("{\"key\":\"value\"}");
295-
}
296-
297-
@Test
298-
public void makeBidsShouldReturnErrorWhenNativeAdmIsInvalid() throws JsonProcessingException {
299-
// given
300-
final String invalidAdm = "{invalid_json";
301-
final Bid bid = Bid.builder()
302-
.impid("123")
303-
.mtype(4)
304-
.adm(invalidAdm)
305-
.build();
306-
307-
final BidResponse bidResponse = BidResponse.builder()
308-
.seatbid(List.of(SeatBid.builder().bid(List.of(bid)).build()))
309-
.build();
310-
311-
final BidderCall<BidRequest> httpCall = givenHttpCall(
312-
BidRequest.builder().build(),
313-
mapper.writeValueAsString(bidResponse));
314-
315-
// when
316-
final Result<List<BidderBid>> result = target.makeBids(httpCall, null);
317-
318-
// then
319-
assertThat(result.getErrors()).hasSize(1);
320-
assertThat(result.getErrors().get(0).getMessage()).contains("Error parsing native ADM");
321-
assertThat(result.getValue()).isEmpty();
292+
assertThat(result.getValue().get(0).getBid().getAdm()).isEqualTo(adm);
322293
}
323294

324295
private static BidRequest givenBidRequest(UnaryOperator<Imp.ImpBuilder> impCustomizer) {

0 commit comments

Comments
 (0)