Skip to content

Commit 129795d

Browse files
committed
fixup after 4th review
1 parent 37d6883 commit 129795d

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

src/main/java/org/prebid/server/bidder/mobkoi/MobkoiBidder.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.List;
3333
import java.util.Objects;
3434
import java.util.Optional;
35-
import java.util.stream.Collectors;
3635

3736
public class MobkoiBidder implements Bidder<BidRequest> {
3837

@@ -50,7 +49,6 @@ public MobkoiBidder(String endpointUrl, JacksonMapper mapper) {
5049

5150
@Override
5251
public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest bidRequest) {
53-
5452
final Imp firstImp = bidRequest.getImp().getFirst();
5553

5654
final ExtImpMobkoi extImpMobkoi;
@@ -87,15 +85,18 @@ private Imp modifyImp(Imp firstImp, ExtImpMobkoi extImpMobkoi) {
8785

8886
if (StringUtils.isNotBlank(extImpMobkoi.getPlacementId())) {
8987
return firstImp.toBuilder().tagid(extImpMobkoi.getPlacementId()).build();
90-
} else {
91-
throw new PreBidException("invalid because it comes with neither request.imp[0].tagId nor "
92-
+ "req.imp[0].ext.Bidder.placementId");
9388
}
89+
90+
throw new PreBidException("invalid because it comes with neither request.imp[0].tagId nor "
91+
+ "req.imp[0].ext.Bidder.placementId");
9492
}
9593

94+
// url is already validated with `bidder-params` json schema
9695
private String resolveEndpoint(String customUri) {
9796
try {
98-
HttpUtil.validateUrl(customUri);
97+
if (customUri == null) {
98+
return endpointUrl;
99+
}
99100
final URI uri = new URI(customUri);
100101
return uri.resolve("/bid").toString();
101102
} catch (IllegalArgumentException | URISyntaxException e) {
@@ -148,6 +149,6 @@ private static List<BidderBid> bidsFromResponse(BidResponse bidResponse) {
148149
.filter(Objects::nonNull)
149150
.flatMap(Collection::stream)
150151
.map(bid -> BidderBid.of(bid, BidType.banner, "mobkoi", bidResponse.getCur()))
151-
.collect(Collectors.toList());
152+
.toList();
152153
}
153154
}

src/test/java/org/prebid/server/bidder/mobkoi/MobkoiBidderTest.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import static java.util.Arrays.asList;
2727
import static java.util.Collections.singletonList;
28+
import static java.util.function.UnaryOperator.identity;
2829
import static org.assertj.core.api.Assertions.assertThat;
2930
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
3031
import static org.prebid.server.bidder.model.BidderError.badInput;
@@ -80,7 +81,7 @@ public void makeHttpRequestsShouldAddPlacementIdOnlyInFirstImpressionTagId() {
8081
// given
8182
final ObjectNode mobkoiExt = impExt("pid", null);
8283
final Imp givenImp1 = givenImp(impBuilder -> impBuilder.ext(mobkoiExt));
83-
final Imp givenImp2 = givenImp(impBuilder -> impBuilder);
84+
final Imp givenImp2 = givenImp(identity());
8485
final BidRequest bidRequest = BidRequest.builder().imp(asList(givenImp1, givenImp2)).build();
8586

8687
// when
@@ -108,20 +109,6 @@ public void makeHttpRequestsShouldUseConstructorEndpointWhenNoCustomEndpointIsDe
108109
assertThat(results.getErrors()).isEmpty();
109110
}
110111

111-
@Test
112-
public void makeHttpRequestsShouldConstructorEndpointWhenTheCustomIsInvalidInMobkoiExtension() {
113-
// given
114-
final ObjectNode mobkoiExt = impExt("pid", "invalid-URI");
115-
final BidRequest bidRequest = givenBidRequest(impBuilder -> impBuilder.ext(mobkoiExt));
116-
117-
// when
118-
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);
119-
120-
// then
121-
assertThat(result.getValue()).extracting(HttpRequest::getUri).containsExactly("https://test.endpoint.com/bid");
122-
assertThat(result.getErrors()).isEmpty();
123-
}
124-
125112
@Test
126113
public void makeHttpRequestsShouldUseCustomEndpointWhenDefinedInMobkoiExtension() {
127114
// given

0 commit comments

Comments
 (0)