diff --git a/src/main/java/org/prebid/server/bidder/somoaudience/SomoaudienceBidder.java b/src/main/java/org/prebid/server/bidder/somoaudience/SomoaudienceBidder.java deleted file mode 100644 index 8583373b18c..00000000000 --- a/src/main/java/org/prebid/server/bidder/somoaudience/SomoaudienceBidder.java +++ /dev/null @@ -1,202 +0,0 @@ -package org.prebid.server.bidder.somoaudience; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import io.vertx.core.MultiMap; -import io.vertx.core.http.HttpMethod; -import org.apache.commons.collections4.CollectionUtils; -import org.prebid.server.bidder.Bidder; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpCall; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.bidder.somoaudience.proto.SomoaudienceReqExt; -import org.prebid.server.exception.PreBidException; -import org.prebid.server.json.DecodeException; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.ExtRequest; -import org.prebid.server.proto.openrtb.ext.request.somoaudience.ExtImpSomoaudience; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.HttpUtil; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -public class SomoaudienceBidder implements Bidder { - - private static final TypeReference> SOMOAUDIENCE_EXT_TYPE_REFERENCE = - new TypeReference<>() { - }; - - private static final String CONFIG = "hb_pbs_1.0.0"; - - private final String endpointUrl; - private final JacksonMapper mapper; - - private final ExtRequest requestExtension; - - public SomoaudienceBidder(String endpointUrl, JacksonMapper mapper) { - this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl)); - this.mapper = Objects.requireNonNull(mapper); - - this.requestExtension = mapper.fillExtension(ExtRequest.empty(), SomoaudienceReqExt.of(CONFIG)); - } - - @Override - public Result>> makeHttpRequests(BidRequest bidRequest) { - final List errors = new ArrayList<>(); - - final List bannerImps = new ArrayList<>(); - final List videoAndNativeImps = new ArrayList<>(); - for (Imp imp : bidRequest.getImp()) { - if (imp.getBanner() != null) { - bannerImps.add(imp); - } else if (imp.getVideo() != null || imp.getXNative() != null) { - videoAndNativeImps.add(imp); - } else { - errors.add(BidderError.badInput(String.format( - "SomoAudience only supports [banner, video, native] imps. Ignoring imp id : %s", imp.getId()))); - } - } - final List> httpRequests = new ArrayList<>(); - - final HttpRequest bannerRequests = makeRequest(bidRequest, bannerImps, errors); - - if (bannerRequests != null) { - httpRequests.add(bannerRequests); - } - - for (Imp imp : videoAndNativeImps) { - final HttpRequest videoOrNativeRequest = makeRequest( - bidRequest, Collections.singletonList(imp), errors); - if (videoOrNativeRequest != null) { - httpRequests.add(videoOrNativeRequest); - } - } - - return Result.of(httpRequests, errors); - } - - private HttpRequest makeRequest(BidRequest bidRequest, List imps, List errors) { - final List validImps = new ArrayList<>(); - String placementHash = null; - for (Imp imp : imps) { - try { - final ExtImpSomoaudience extImpSomoaudience = parseImpExt(imp); - placementHash = extImpSomoaudience.getPlacementHash(); - final BigDecimal bidFloor = extImpSomoaudience.getBidFloor(); - final Imp modifiedImp = imp.toBuilder() - .ext(null) - .bidfloor(bidFloor) - .build(); - validImps.add(modifiedImp); - } catch (PreBidException e) { - errors.add(BidderError.badInput(e.getMessage())); - } - } - if (validImps.size() == 0) { - return null; - } - final BidRequest.BidRequestBuilder requestBuilder = bidRequest.toBuilder(); - - requestBuilder.imp(validImps); - requestBuilder.ext(requestExtension); - - final BidRequest outgoingRequest = requestBuilder.build(); - - final String url = String.format("%s?s=%s", endpointUrl, placementHash); - - return HttpRequest.builder() - .method(HttpMethod.POST) - .uri(url) - .body(mapper.encodeToBytes(outgoingRequest)) - .headers(headers(outgoingRequest.getDevice())) - .payload(outgoingRequest) - .build(); - } - - private ExtImpSomoaudience parseImpExt(Imp imp) { - try { - return mapper.mapper().convertValue(imp.getExt(), - SOMOAUDIENCE_EXT_TYPE_REFERENCE).getBidder(); - } catch (IllegalArgumentException e) { - throw new PreBidException(String.format( - "ignoring imp id=%s, error while decoding extImpBidder, err: %s", imp.getId(), e.getMessage())); - } - } - - private static MultiMap headers(Device device) { - final MultiMap headers = HttpUtil.headers(); - headers.add(HttpUtil.X_OPENRTB_VERSION_HEADER, "2.5"); - - if (device != null) { - HttpUtil.addHeaderIfValueIsNotEmpty(headers, HttpUtil.USER_AGENT_HEADER, device.getUa()); - HttpUtil.addHeaderIfValueIsNotEmpty(headers, HttpUtil.X_FORWARDED_FOR_HEADER, device.getIp()); - HttpUtil.addHeaderIfValueIsNotEmpty(headers, HttpUtil.ACCEPT_LANGUAGE_HEADER, device.getLanguage()); - - final Integer dnt = device.getDnt(); - if (dnt != null) { - headers.add(HttpUtil.DNT_HEADER, dnt.toString()); - } - } - return headers; - } - - @Override - public Result> makeBids(HttpCall httpCall, BidRequest bidRequest) { - try { - final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); - return extractBids(bidResponse, bidRequest.getImp()); - } catch (DecodeException e) { - return Result.withError(BidderError.badServerResponse(e.getMessage())); - } - } - - private static Result> extractBids(BidResponse bidResponse, List imps) { - return bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid()) - ? Result.empty() - : Result.withValues(createBiddersBid(bidResponse, imps)); - } - - private static List createBiddersBid(BidResponse bidResponse, List imps) { - - return bidResponse.getSeatbid().stream() - .filter(Objects::nonNull) - .map(SeatBid::getBid) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .map(bid -> BidderBid.of(bid, getBidType(bid.getImpid(), imps), bidResponse.getCur())) - .collect(Collectors.toList()); - } - - private static BidType getBidType(String impId, List imps) { - return imps.stream() - .filter(imp -> Objects.equals(imp.getId(), impId)) - .findAny() - .map(SomoaudienceBidder::bidTypeFromImp) - .orElse(BidType.banner); - } - - private static BidType bidTypeFromImp(Imp imp) { - BidType bidType = BidType.banner; - if (imp.getBanner() == null) { - if (imp.getVideo() != null) { - bidType = BidType.video; - } else if (imp.getXNative() != null) { - bidType = BidType.xNative; - } - } - return bidType; - } -} diff --git a/src/main/java/org/prebid/server/bidder/somoaudience/proto/SomoaudienceReqExt.java b/src/main/java/org/prebid/server/bidder/somoaudience/proto/SomoaudienceReqExt.java deleted file mode 100644 index 763cf65a170..00000000000 --- a/src/main/java/org/prebid/server/bidder/somoaudience/proto/SomoaudienceReqExt.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.prebid.server.bidder.somoaudience.proto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Value; - -@AllArgsConstructor(staticName = "of") -@Value -public class SomoaudienceReqExt { - - @JsonProperty("prebid") - String bidderConfig; -} diff --git a/src/main/java/org/prebid/server/proto/openrtb/ext/request/somoaudience/ExtImpSomoaudience.java b/src/main/java/org/prebid/server/proto/openrtb/ext/request/somoaudience/ExtImpSomoaudience.java deleted file mode 100644 index 82aebefe5ef..00000000000 --- a/src/main/java/org/prebid/server/proto/openrtb/ext/request/somoaudience/ExtImpSomoaudience.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.prebid.server.proto.openrtb.ext.request.somoaudience; - -import lombok.AllArgsConstructor; -import lombok.Value; - -import java.math.BigDecimal; - -@AllArgsConstructor(staticName = "of") -@Value -public class ExtImpSomoaudience { - - String placementHash; - - BigDecimal bidFloor; -} diff --git a/src/main/java/org/prebid/server/spring/config/bidder/SomoaudienceConfiguration.java b/src/main/java/org/prebid/server/spring/config/bidder/SomoaudienceConfiguration.java deleted file mode 100644 index ddf3fcdbb81..00000000000 --- a/src/main/java/org/prebid/server/spring/config/bidder/SomoaudienceConfiguration.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.prebid.server.spring.config.bidder; - -import org.prebid.server.bidder.BidderDeps; -import org.prebid.server.bidder.somoaudience.SomoaudienceBidder; -import org.prebid.server.json.JacksonMapper; -import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; -import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; -import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; -import org.prebid.server.spring.env.YamlPropertySourceFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -import javax.validation.constraints.NotBlank; - -@Configuration -@PropertySource(value = "classpath:/bidder-config/somoaudience.yaml", factory = YamlPropertySourceFactory.class) -public class SomoaudienceConfiguration { - - private static final String BIDDER_NAME = "somoaudience"; - - @Bean("somoaudienceConfigurationProperties") - @ConfigurationProperties("adapters.somoaudience") - BidderConfigurationProperties configurationProperties() { - return new BidderConfigurationProperties(); - } - - @Bean - BidderDeps somoaudienceBidderDeps(BidderConfigurationProperties somoaudienceConfigurationProperties, - @NotBlank @Value("${external-url}") String externalUrl, - JacksonMapper mapper) { - - return BidderDepsAssembler.forBidder(BIDDER_NAME) - .withConfig(somoaudienceConfigurationProperties) - .usersyncerCreator(UsersyncerCreator.create(externalUrl)) - .bidderCreator(config -> new SomoaudienceBidder(config.getEndpoint(), mapper)) - .assemble(); - } -} diff --git a/src/main/resources/bidder-config/somoaudience.yaml b/src/main/resources/bidder-config/somoaudience.yaml deleted file mode 100644 index 54d4472109e..00000000000 --- a/src/main/resources/bidder-config/somoaudience.yaml +++ /dev/null @@ -1,20 +0,0 @@ -adapters: - somoaudience: - endpoint: http://publisher-east.mobileadtrading.com/rtb/bid - meta-info: - maintainer-email: publishers@somoaudience.com - app-media-types: - - banner - - native - site-media-types: - - banner - - native - - video - supported-vendors: - vendor-id: 341 - usersync: - url: https://publisher-east.mobileadtrading.com/usersync?ru= - redirect-url: /setuid?bidder=somoaudience&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&uid=${UID} - cookie-family-name: somoaudience - type: redirect - support-cors: false diff --git a/src/main/resources/static/bidder-params/somoaudience.json b/src/main/resources/static/bidder-params/somoaudience.json deleted file mode 100644 index 214d0ff07de..00000000000 --- a/src/main/resources/static/bidder-params/somoaudience.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "SomoAudience Adapter Params", - "description": "A schema which validates params accepted by the SomoAudience adapter", - "type": "object", - "properties": { - "placement_hash": { - "type": "string", - "description": "A hash defining the placement selling the impression" - }, - "bid_floor": { - "type": "number", - "description": "Bid Floor for Impression", - "minimum": 0 - } - }, - "required": [ - "placement_hash" - ] -} diff --git a/src/test/java/org/prebid/server/bidder/somoaudience/SomoaudienceBidderTest.java b/src/test/java/org/prebid/server/bidder/somoaudience/SomoaudienceBidderTest.java deleted file mode 100644 index 85c0f5d0420..00000000000 --- a/src/test/java/org/prebid/server/bidder/somoaudience/SomoaudienceBidderTest.java +++ /dev/null @@ -1,424 +0,0 @@ -package org.prebid.server.bidder.somoaudience; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.iab.openrtb.request.Audio; -import com.iab.openrtb.request.Banner; -import com.iab.openrtb.request.BidRequest; -import com.iab.openrtb.request.Device; -import com.iab.openrtb.request.Imp; -import com.iab.openrtb.request.Native; -import com.iab.openrtb.request.Regs; -import com.iab.openrtb.request.User; -import com.iab.openrtb.request.Video; -import com.iab.openrtb.response.Bid; -import com.iab.openrtb.response.BidResponse; -import com.iab.openrtb.response.SeatBid; -import io.netty.handler.codec.http.HttpHeaderValues; -import io.vertx.core.http.HttpMethod; -import org.junit.Before; -import org.junit.Test; -import org.prebid.server.VertxTest; -import org.prebid.server.bidder.model.BidderBid; -import org.prebid.server.bidder.model.BidderError; -import org.prebid.server.bidder.model.HttpCall; -import org.prebid.server.bidder.model.HttpRequest; -import org.prebid.server.bidder.model.HttpResponse; -import org.prebid.server.bidder.model.Result; -import org.prebid.server.bidder.somoaudience.proto.SomoaudienceReqExt; -import org.prebid.server.proto.openrtb.ext.ExtPrebid; -import org.prebid.server.proto.openrtb.ext.request.ExtRegs; -import org.prebid.server.proto.openrtb.ext.request.ExtRequest; -import org.prebid.server.proto.openrtb.ext.request.ExtUser; -import org.prebid.server.proto.openrtb.ext.request.somoaudience.ExtImpSomoaudience; -import org.prebid.server.proto.openrtb.ext.response.BidType; -import org.prebid.server.util.HttpUtil; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static java.util.function.Function.identity; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class SomoaudienceBidderTest extends VertxTest { - - private static final String ENDPOINT_URL = "http://somoaudience.com"; - - private SomoaudienceBidder somoaudienceBidder; - - @Before - public void setUp() { - somoaudienceBidder = new SomoaudienceBidder(ENDPOINT_URL, jacksonMapper); - } - - @Test - public void makeHttpRequestsShouldReturnHttpRequestWithCorrectBodyHeadersAndMethod() { - // given - final BidRequest bidRequest = givenBidRequest(identity()); - - // when - final Result>> result = somoaudienceBidder.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).extracting(HttpRequest::getMethod).containsExactly(HttpMethod.POST); - assertThat(result.getValue()).extracting(HttpRequest::getUri) - .containsExactly("http://somoaudience.com?s=placementId"); - assertThat(result.getValue()).flatExtracting(httpRequest -> httpRequest.getHeaders().entries()) - .extracting(Map.Entry::getKey, Map.Entry::getValue) - .containsOnly( - tuple(HttpUtil.CONTENT_TYPE_HEADER.toString(), HttpUtil.APPLICATION_JSON_CONTENT_TYPE), - tuple(HttpUtil.ACCEPT_HEADER.toString(), HttpHeaderValues.APPLICATION_JSON.toString()), - tuple(HttpUtil.X_OPENRTB_VERSION_HEADER.toString(), "2.5"), - tuple(HttpUtil.USER_AGENT_HEADER.toString(), "User Agent"), - tuple(HttpUtil.X_FORWARDED_FOR_HEADER.toString(), "ip"), - tuple(HttpUtil.ACCEPT_LANGUAGE_HEADER.toString(), "en"), - tuple(HttpUtil.DNT_HEADER.toString(), "1")); - assertThat(result.getValue()).extracting(HttpRequest::getPayload).containsExactly( - givenBidRequest(bidRequestBuilder -> bidRequestBuilder - .ext(jacksonMapper.fillExtension(ExtRequest.empty(), - SomoaudienceReqExt.of("hb_pbs_1.0.0"))), - impBuilder -> impBuilder.ext(null).bidfloor(BigDecimal.valueOf(1.39)))); - } - - @Test - public void makeHttpRequestsShouldAddOnlyDeviceNotEmptyValuesToHeaders() { - // given - final BidRequest bidRequest = givenBidRequest(bidRequestBuilder -> - bidRequestBuilder.device(Device.builder() - .ua("User Agent") - .ip("") - .dnt(1) - .language(null) - .build()), identity()); - - // when - final Result>> result = somoaudienceBidder.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).flatExtracting(httpRequest -> httpRequest.getHeaders().entries()) - .extracting(Map.Entry::getKey) - .doesNotContain(HttpUtil.ACCEPT_LANGUAGE_HEADER.toString(), - HttpUtil.X_FORWARDED_FOR_HEADER.toString()); - } - - @Test - public void makeHttpRequestsShouldReturnCorrectRequestBodyAndUri() { - // given - final BidRequest bidRequest = BidRequest.builder().imp(asList( - givenImp(impBuilder -> impBuilder.ext(mapper.valueToTree(ExtPrebid.of( - null, ExtImpSomoaudience.of("placement1", BigDecimal.valueOf(1.54)))))), - givenImp(impBuilder -> impBuilder.ext(mapper.valueToTree(ExtPrebid.of( - null, ExtImpSomoaudience.of("placement2", BigDecimal.valueOf(1.33)))))), - givenImp(impBuilder -> impBuilder - .video(Video.builder().build()) - .banner(null) - .ext(mapper.valueToTree(ExtPrebid.of( - null, ExtImpSomoaudience.of("placement3", BigDecimal.valueOf(1.97)))))), - - givenImp(impBuilder -> impBuilder - .xNative(Native.builder().build()) - .banner(null) - .ext(mapper.valueToTree(ExtPrebid.of( - null, ExtImpSomoaudience.of("placement4", BigDecimal.valueOf(2.52)))))))) - .build(); - - // when - final Result>> result = somoaudienceBidder.makeHttpRequests(bidRequest); - - // then - final BidRequest expectedBannersString = BidRequest.builder() - .imp(asList( - Imp.builder().banner(Banner.builder().build()).bidfloor(BigDecimal.valueOf(1.54)).build(), - Imp.builder().banner(Banner.builder().build()).bidfloor(BigDecimal.valueOf(1.33)).build())) - .ext(jacksonMapper.fillExtension(ExtRequest.empty(), SomoaudienceReqExt.of("hb_pbs_1.0.0"))) - .build(); - final BidRequest videoRequest = - expectedRequest(impBuilder -> impBuilder.video(Video.builder().build()), 1.97); - final BidRequest nativeRequest = - expectedRequest(impBuilder -> impBuilder.xNative(Native.builder().build()), 2.52); - - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .extracting(HttpRequest::getUri, HttpRequest::getPayload) - .containsExactlyInAnyOrder( - tuple("http://somoaudience.com?s=placement2", expectedBannersString), - tuple("http://somoaudience.com?s=placement3", videoRequest), - tuple("http://somoaudience.com?s=placement4", nativeRequest)); - } - - @Test - public void makeHttpRequestShouldReturnErrorMessageWhenMediaTypeIsAudio() { - // given - final BidRequest bidRequest = BidRequest.builder() - .imp(singletonList(Imp.builder() - .id("impId") - .audio(Audio.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of( - null, ExtImpSomoaudience.of("placementId", null)))).build())) - .build(); - - // when - final Result>> result = somoaudienceBidder.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()) - .containsExactly(BidderError.badInput( - "SomoAudience only supports [banner, video, native] imps. Ignoring imp id : impId")); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeHttpRequestShouldReturnHttpRequestWithErrorMessage() { - // given - final BidRequest bidRequest = BidRequest.builder() - .imp(asList(givenImp(impBuilder -> impBuilder - .id("impId") - .ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode())))), - givenImp(impBuilder -> impBuilder - .id("impId2") - .ext(mapper.valueToTree(ExtPrebid.of( - null, ExtImpSomoaudience.of("placementId", null))))))) - .build(); - - // when - final Result>> result = somoaudienceBidder.makeHttpRequests(bidRequest); - - // then - assertThat(result.getErrors()).hasSize(1) - .allSatisfy(error -> { - assertThat(error.getMessage()).startsWith("ignoring imp id=impId, error while decoding"); - assertThat(error.getType()).isEqualTo(BidderError.Type.bad_input); - }); - assertThat(result.getValue()).extracting(HttpRequest::getUri) - .containsExactly("http://somoaudience.com?s=placementId"); - assertThat(result.getValue()) - .extracting(HttpRequest::getPayload) - .containsExactly( - expectedRequest(impBuilder -> impBuilder.id("impId2").banner(Banner.builder().build()), null)); - } - - @Test - public void makeBidsShouldReturnBidWithoutErrors() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(givenBidResponse(identity())); - final BidRequest bidRequest = BidRequest.builder().imp(singletonList(Imp.builder().id("impId") - .banner(Banner.builder().build()).build())) - .build(); - - final HttpCall httpCall = givenHttpCall(response); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("impId").build(), BidType.banner, "EUR")); - } - - @Test - public void makeBidsShouldTakeBannerPrecedencyOverAllOtherMediaTypes() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(givenBidResponse(identity())); - final BidRequest bidRequest = BidRequest.builder().imp(singletonList(Imp.builder().id("impId") - .banner(Banner.builder().build()) - .video(Video.builder().build()) - .xNative(Native.builder().build()).build())) - .build(); - - final HttpCall httpCall = givenHttpCall(response); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("impId").build(), BidType.banner, "EUR")); - } - - @Test - public void makeBidsShouldTakeVideoPrecedencyOverNative() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(givenBidResponse(identity())); - final BidRequest bidRequest = BidRequest.builder().imp(singletonList(Imp.builder().id("impId") - .video(Video.builder().build()) - .xNative(Native.builder().build()).build())) - .build(); - - final HttpCall httpCall = givenHttpCall(response); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("impId").build(), BidType.video, "EUR")); - } - - @Test - public void makeBidsShouldReturnBidsWithNativeTypeOnlyWhenAllOtherAreAbsent() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(givenBidResponse(identity())); - final BidRequest bidRequest = BidRequest.builder().imp(singletonList(Imp.builder().id("impId") - .xNative(Native.builder().build()).build())) - .build(); - - final HttpCall httpCall = givenHttpCall(response); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("impId").build(), BidType.xNative, "EUR")); - } - - @Test - public void makeBidsShouldReturnBidsWithMediaBidTypeIfMediaTypeWasNotDefinedInImp() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(givenBidResponse(identity())); - final BidRequest bidRequest = - BidRequest.builder().imp(singletonList(Imp.builder().id("impId").build())).build(); - - final HttpCall httpCall = givenHttpCall(response); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("impId").build(), BidType.banner, "EUR")); - } - - @Test - public void makeBidsShouldReturnBidWithMediaBidTypeIfCorrespondentImpWasNotFound() throws JsonProcessingException { - // given - final BidResponse response = givenBidResponse(identity()); - final BidRequest bidRequest = - BidRequest.builder().imp(singletonList(Imp.builder().id("impId2").build())).build(); - - final HttpCall httpCall = givenHttpCall(mapper.writeValueAsString(response)); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()) - .containsExactly(BidderBid.of(Bid.builder().impid("impId").build(), BidType.banner, "EUR")); - } - - @Test - public void makeBidsShouldReturnBidsFromDifferentSeatBidsInResponse() throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(BidResponse.builder() - .seatbid(asList( - SeatBid.builder() - .bid(singletonList(Bid.builder().id("bidId1").impid("impId1").build())) - .build(), - SeatBid.builder() - .bid(singletonList(Bid.builder().id("bidId2").impid("impId2").build())) - .build())) - .build()); - final BidRequest bidRequest = BidRequest.builder().imp(asList(Imp.builder().id("impId1").build(), - Imp.builder().id("impId2").build())).build(); - - final HttpCall httpCall = givenHttpCall(response); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, bidRequest); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).hasSize(2) - .extracting(BidderBid::getBid) - .extracting(Bid::getId) - .containsExactly("bidId1", "bidId2"); - } - - @Test - public void makeBidsShouldReturnEmptyBidderBidAndErrorListsIfSeatBidIsNotPresentInResponse() - throws JsonProcessingException { - // given - final String response = mapper.writeValueAsString(BidResponse.builder().build()); - final HttpCall httpCall = givenHttpCall(response); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, BidRequest.builder().build()); - - // then - assertThat(result.getErrors()).isEmpty(); - assertThat(result.getValue()).isEmpty(); - } - - @Test - public void makeBidsShouldReturnEmptyBidderWithErrorWhenResponseCantBeParsed() { - // given - final HttpCall httpCall = givenHttpCall("{"); - - // when - final Result> result = somoaudienceBidder.makeBids(httpCall, BidRequest.builder().build()); - - // then - assertThat(result.getErrors()).hasSize(1) - .allSatisfy(error -> { - assertThat(error.getMessage()).startsWith("Failed to decode: "); - assertThat(error.getType()).isEqualTo(BidderError.Type.bad_server_response); - }); - } - - private static BidRequest givenBidRequest( - Function bidRequestCustomizer, - Function impCustomizer) { - - return bidRequestCustomizer.apply(BidRequest.builder() - .user(User.builder().ext(ExtUser.builder().consent("consent").build()).build()) - .device(Device.builder().ua("User Agent").ip("ip").dnt(1).language("en").build()) - .regs(Regs.of(0, ExtRegs.of(1, null))) - .imp(singletonList(givenImp(impCustomizer)))) - .build(); - } - - private static BidRequest givenBidRequest(Function impCustomizer) { - return givenBidRequest(identity(), impCustomizer); - } - - private static Imp givenImp(Function impCustomizer) { - return impCustomizer.apply(Imp.builder() - .banner(Banner.builder().build()) - .ext(mapper.valueToTree(ExtPrebid.of( - null, ExtImpSomoaudience.of("placementId", BigDecimal.valueOf(1.39)))))) - .build(); - } - - private static BidResponse givenBidResponse(Function bidCustomizer) { - return BidResponse.builder() - .cur("EUR") - .seatbid(singletonList(SeatBid.builder() - .bid(singletonList(bidCustomizer.apply(Bid.builder()).impid("impId").build())) - .build())) - .build(); - } - - private static BidRequest expectedRequest(Function impCustomizer, Double bidFloor) { - return BidRequest.builder() - .ext(jacksonMapper.fillExtension(ExtRequest.empty(), SomoaudienceReqExt.of("hb_pbs_1.0.0"))) - .imp(singletonList(impCustomizer.apply(Imp.builder() - .bidfloor(bidFloor != null ? BigDecimal.valueOf(bidFloor) : null)) - .build())).build(); - } - - private static HttpCall givenHttpCall(String body) { - return HttpCall.success(null, HttpResponse.of(200, null, body), null); - } -} diff --git a/src/test/java/org/prebid/server/it/SomoaudienceTest.java b/src/test/java/org/prebid/server/it/SomoaudienceTest.java deleted file mode 100644 index 9293279afdb..00000000000 --- a/src/test/java/org/prebid/server/it/SomoaudienceTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.prebid.server.it; - -import io.restassured.response.Response; -import org.json.JSONException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.prebid.server.model.Endpoint; -import org.springframework.test.context.junit4.SpringRunner; - -import java.io.IOException; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static java.util.Collections.singletonList; - -@RunWith(SpringRunner.class) -public class SomoaudienceTest extends IntegrationTest { - - @Test - public void openrtb2AuctionShouldRespondWithBidsFromSomoaudience() throws IOException, JSONException { - // given - WIRE_MOCK_RULE.stubFor(post(urlPathEqualTo("/somoaudience-exchange")) - .withRequestBody(equalToJson(jsonFrom("openrtb2/somoaudience/test-somoaudience-bid-request.json"))) - .willReturn(aResponse().withBody(jsonFrom( - "openrtb2/somoaudience/test-somoaudience-bid-response.json")))); - - // when - final Response response = responseFor("openrtb2/somoaudience/test-auction-somoaudience-request.json", - Endpoint.openrtb2_auction); - - // then - assertJsonEquals("openrtb2/somoaudience/test-auction-somoaudience-response.json", response, - singletonList("somoaudience")); - } -} diff --git a/src/test/java/org/prebid/server/validation/BidderParamValidatorTest.java b/src/test/java/org/prebid/server/validation/BidderParamValidatorTest.java index 87164a7d8ec..fa72a67b6cf 100644 --- a/src/test/java/org/prebid/server/validation/BidderParamValidatorTest.java +++ b/src/test/java/org/prebid/server/validation/BidderParamValidatorTest.java @@ -18,7 +18,6 @@ import org.prebid.server.proto.openrtb.ext.request.facebook.ExtImpFacebook; import org.prebid.server.proto.openrtb.ext.request.openx.ExtImpOpenx; import org.prebid.server.proto.openrtb.ext.request.rubicon.ExtImpRubicon; -import org.prebid.server.proto.openrtb.ext.request.somoaudience.ExtImpSomoaudience; import org.prebid.server.proto.openrtb.ext.request.sovrn.ExtImpSovrn; import org.prebid.server.util.ResourceUtil; @@ -46,7 +45,6 @@ public class BidderParamValidatorTest extends VertxTest { private static final String FACEBOOK = "audienceNetwork"; private static final String OPENX = "openx"; private static final String EPLANNING = "eplanning"; - private static final String SOMOAUDIENCE = "somoaudience"; private static final String BEACHFRONT = "beachfront"; @Rule @@ -69,7 +67,6 @@ public void setUp() { FACEBOOK, OPENX, EPLANNING, - SOMOAUDIENCE, BEACHFRONT))); given(bidderCatalog.bidderInfoByName(anyString())).willReturn(givenBidderInfo()); given(bidderCatalog.bidderInfoByName(eq(APPNEXUS_ALIAS))).willReturn(givenBidderInfo(APPNEXUS)); @@ -344,32 +341,6 @@ public void validateShouldReturnValidationMessagesWhenEplanningExtNotValid() { assertThat(messages.size()).isEqualTo(1); } - @Test - public void validateShouldNotReturnValidationMessagesWhenSomoaudienceImpExtIsOk() { - // given - final ExtImpSomoaudience ext = ExtImpSomoaudience.of("placementId", BigDecimal.valueOf(1.11)); - final JsonNode node = mapper.convertValue(ext, JsonNode.class); - - // when - final Set messages = bidderParamValidator.validate(SOMOAUDIENCE, node); - - // then - assertThat(messages).isEmpty(); - } - - @Test - public void validateShouldReturnValidationMessagesWhenSomoaudienceExtNotValid() { - // given - final JsonNode node = mapper.createObjectNode(); - - // when - final Set messages = bidderParamValidator.validate(SOMOAUDIENCE, node); - - // then - assertThat(messages.size()).isEqualTo(1); - } - - @Test public void validateShouldNotReturnValidationMessagesWhenBeachfrontImpExtIsOk() { // given final ExtImpBeachfront ext = ExtImpBeachfront.of("appId", null, BigDecimal.ONE, "adm"); diff --git a/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-auction-somoaudience-request.json b/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-auction-somoaudience-request.json deleted file mode 100644 index 107aba6589a..00000000000 --- a/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-auction-somoaudience-request.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "request_id", - "imp": [ - { - "id": "imp_id", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "somoaudience": { - "placement_hash": "placementId01", - "bid_floor": 1.5 - } - } - } - ], - "tmax": 5000, - "regs": { - "ext": { - "gdpr": 0 - } - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-auction-somoaudience-response.json b/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-auction-somoaudience-response.json deleted file mode 100644 index 80fd006b653..00000000000 --- a/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-auction-somoaudience-response.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "id": "request_id", - "seatbid": [ - { - "bid": [ - { - "id": "bid_id", - "impid": "imp_id", - "price": 8.43, - "adm": "adm16", - "crid": "crid16", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner" - }, - "origbidcpm": 8.43 - } - } - ], - "seat": "somoaudience", - "group": 0 - } - ], - "cur": "USD", - "ext": { - "responsetimemillis": { - "somoaudience": "{{ somoaudience.response_time_ms }}" - }, - "prebid": { - "auctiontimestamp": 0 - }, - "tmaxrequest": 5000 - } -} diff --git a/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-somoaudience-bid-request.json b/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-somoaudience-bid-request.json deleted file mode 100644 index 621f6a97f67..00000000000 --- a/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-somoaudience-bid-request.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "id": "request_id", - "imp": [ - { - "id": "imp_id", - "banner": { - "w": 300, - "h": 250 - }, - "bidfloor": 1.5 - } - ], - "site": { - "domain": "www.example.com", - "page": "http://www.example.com", - "publisher": { - "domain": "example.com" - }, - "ext": { - "amp": 0 - } - }, - "device": { - "ua": "userAgent", - "ip": "193.168.244.1" - }, - "at": 1, - "tmax": 5000, - "cur": [ - "USD" - ], - "regs": { - "ext": { - "gdpr": 0 - } - }, - "ext": { - "prebid": "hb_pbs_1.0.0" - } -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-somoaudience-bid-response.json b/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-somoaudience-bid-response.json deleted file mode 100644 index 88aed6b5934..00000000000 --- a/src/test/resources/org/prebid/server/it/openrtb2/somoaudience/test-somoaudience-bid-response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "request_id", - "seatbid": [ - { - "bid": [ - { - "id": "bid_id", - "impid": "imp_id", - "price": 8.43, - "adm": "adm16", - "crid": "crid16", - "w": 300, - "h": 250 - } - ], - "seat": "seatId01" - } - ] -} \ No newline at end of file diff --git a/src/test/resources/org/prebid/server/it/test-application.properties b/src/test/resources/org/prebid/server/it/test-application.properties index e5527ce4174..51638546e23 100644 --- a/src/test/resources/org/prebid/server/it/test-application.properties +++ b/src/test/resources/org/prebid/server/it/test-application.properties @@ -219,8 +219,6 @@ adapters.smartyads.enabled=true adapters.smartyads.endpoint=http://localhost:8090/smartyads-exchange adapters.smilewanted.enabled=true adapters.smilewanted.endpoint=http://localhost:8090/smilewanted-exchange -adapters.somoaudience.enabled=true -adapters.somoaudience.endpoint=http://localhost:8090/somoaudience-exchange adapters.sonobi.enabled=true adapters.sonobi.endpoint=http://localhost:8090/sonobi-exchange adapters.sovrn.enabled=true