Skip to content

Commit

Permalink
Liftoff: Rename to Vungle (#3383)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoxaAntoxic authored Aug 20, 2024
1 parent e034cae commit 796ee57
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 72 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.bidder.liftoff;
package org.prebid.server.bidder.vungle;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.iab.openrtb.request.App;
Expand All @@ -13,18 +13,18 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.prebid.server.bidder.Bidder;
import org.prebid.server.bidder.liftoff.model.LiftoffImpressionExt;
import org.prebid.server.bidder.model.BidderBid;
import org.prebid.server.bidder.model.BidderCall;
import org.prebid.server.bidder.model.BidderError;
import org.prebid.server.bidder.model.HttpRequest;
import org.prebid.server.bidder.model.Price;
import org.prebid.server.bidder.model.Result;
import org.prebid.server.bidder.vungle.model.VungleImpressionExt;
import org.prebid.server.currency.CurrencyConversionService;
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.request.liftoff.ExtImpLiftoff;
import org.prebid.server.proto.openrtb.ext.request.vungle.ExtImpVungle;
import org.prebid.server.proto.openrtb.ext.response.BidType;
import org.prebid.server.util.BidderUtil;
import org.prebid.server.util.HttpUtil;
Expand All @@ -37,7 +37,7 @@
import java.util.List;
import java.util.Objects;

public class LiftoffBidder implements Bidder<BidRequest> {
public class VungleBidder implements Bidder<BidRequest> {

private static final String BIDDER_CURRENCY = "USD";
private static final String X_OPENRTB_VERSION = "2.5";
Expand All @@ -46,9 +46,9 @@ public class LiftoffBidder implements Bidder<BidRequest> {
private final CurrencyConversionService currencyConversionService;
private final JacksonMapper mapper;

public LiftoffBidder(String endpointUrl,
CurrencyConversionService currencyConversionService,
JacksonMapper mapper) {
public VungleBidder(String endpointUrl,
CurrencyConversionService currencyConversionService,
JacksonMapper mapper) {

this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl));
this.currencyConversionService = Objects.requireNonNull(currencyConversionService);
Expand All @@ -63,8 +63,8 @@ public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest bidRequ
for (Imp imp : bidRequest.getImp()) {
try {
final Price price = resolveBidFloor(imp, bidRequest);
final LiftoffImpressionExt impExt = parseImpExt(imp);
final LiftoffImpressionExt modifiedImpExt = modifyImpExt(impExt, bidRequest);
final VungleImpressionExt impExt = parseImpExt(imp);
final VungleImpressionExt modifiedImpExt = modifyImpExt(impExt, bidRequest);
final Imp modifiedImp = modifyImp(imp, modifiedImpExt, price);
final BidRequest modifiedRequest = modifyBidRequest(
bidRequest,
Expand Down Expand Up @@ -92,22 +92,22 @@ private Price resolveBidFloor(Imp imp, BidRequest bidRequest) {
return Price.of(BIDDER_CURRENCY, bigDecimal);
}

private LiftoffImpressionExt parseImpExt(Imp imp) {
return mapper.mapper().convertValue(imp.getExt(), LiftoffImpressionExt.class);
private VungleImpressionExt parseImpExt(Imp imp) {
return mapper.mapper().convertValue(imp.getExt(), VungleImpressionExt.class);
}

private static LiftoffImpressionExt modifyImpExt(LiftoffImpressionExt impExt, BidRequest bidRequest) {
final ExtImpLiftoff bidder = impExt.getBidder();
private static VungleImpressionExt modifyImpExt(VungleImpressionExt impExt, BidRequest bidRequest) {
final ExtImpVungle bidder = impExt.getBidder();
final String buyerId = ObjectUtil.getIfNotNull(bidRequest.getUser(), User::getBuyeruid);
final ExtImpLiftoff vungle = ExtImpLiftoff.of(
final ExtImpVungle vungle = ExtImpVungle.of(
buyerId,
bidder.getAppStoreId(),
bidder.getPlacementReferenceId());

return impExt.toBuilder().vungle(vungle).build();
}

private Imp modifyImp(Imp imp, LiftoffImpressionExt modifiedImpExt, Price price) {
private Imp modifyImp(Imp imp, VungleImpressionExt modifiedImpExt, Price price) {
return imp.toBuilder()
.tagid(modifiedImpExt.getBidder().getPlacementReferenceId())
.ext(mapper.mapper().convertValue(modifiedImpExt, ObjectNode.class))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.prebid.server.bidder.vungle.model;

import lombok.Builder;
import lombok.Getter;
import org.prebid.server.proto.openrtb.ext.request.ExtImpPrebid;
import org.prebid.server.proto.openrtb.ext.request.vungle.ExtImpVungle;

@Builder(toBuilder = true)
@Getter
public class VungleImpressionExt {

ExtImpPrebid prebid;

ExtImpVungle bidder;

ExtImpVungle vungle;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.prebid.server.proto.openrtb.ext.request.liftoff;
package org.prebid.server.proto.openrtb.ext.request.vungle;

import lombok.Value;

@Value(staticConstructor = "of")
public class ExtImpLiftoff {
public class ExtImpVungle {

String bidToken;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.prebid.server.spring.config.bidder;

import org.prebid.server.bidder.BidderDeps;
import org.prebid.server.bidder.liftoff.LiftoffBidder;
import org.prebid.server.bidder.vungle.VungleBidder;
import org.prebid.server.currency.CurrencyConversionService;
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties;
Expand All @@ -17,27 +17,27 @@
import jakarta.validation.constraints.NotBlank;

@Configuration
@PropertySource(value = "classpath:/bidder-config/liftoff.yaml", factory = YamlPropertySourceFactory.class)
public class LiftoffConfiguration {
@PropertySource(value = "classpath:/bidder-config/vungle.yaml", factory = YamlPropertySourceFactory.class)
public class VungleConfiguration {

private static final String BIDDER_NAME = "liftoff";
private static final String BIDDER_NAME = "vungle";

@Bean("liftoffConfigurationProperties")
@ConfigurationProperties("adapters.liftoff")
@Bean("vungleConfigurationProperties")
@ConfigurationProperties("adapters.vungle")
BidderConfigurationProperties configurationProperties() {
return new BidderConfigurationProperties();
}

@Bean
BidderDeps liftoffBidderDeps(BidderConfigurationProperties liftoffConfigurationProperties,
@NotBlank @Value("${external-url}") String externalUrl,
CurrencyConversionService currencyConversionService,
JacksonMapper mapper) {
BidderDeps vungleBidderDeps(BidderConfigurationProperties vungleConfigurationProperties,
@NotBlank @Value("${external-url}") String externalUrl,
CurrencyConversionService currencyConversionService,
JacksonMapper mapper) {

return BidderDepsAssembler.forBidder(BIDDER_NAME)
.withConfig(liftoffConfigurationProperties)
.withConfig(vungleConfigurationProperties)
.usersyncerCreator(UsersyncerCreator.create(externalUrl))
.bidderCreator(config -> new LiftoffBidder(config.getEndpoint(), currencyConversionService, mapper))
.bidderCreator(config -> new VungleBidder(config.getEndpoint(), currencyConversionService, mapper))
.assemble();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
adapters:
liftoff:
vungle:
endpoint: https://rtb.ads.vungle.com/bid/t/c770f32
aliases:
liftoff:
enabled: false
modifying-vast-xml-allowed: true
endpoint-compression: gzip
meta-info:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Liftoff Adapter Params",
"description": "A schema which validates params accepted by the Liftoff adapter",
"title": "Vungle Adapter Params",
"description": "A schema which validates params accepted by the Vungle adapter",
"type": "object",
"properties": {
"app_store_id": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.bidder.liftoff;
package org.prebid.server.bidder.vungle;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand All @@ -18,17 +18,17 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.prebid.server.VertxTest;
import org.prebid.server.bidder.liftoff.model.LiftoffImpressionExt;
import org.prebid.server.bidder.model.BidderBid;
import org.prebid.server.bidder.model.BidderCall;
import org.prebid.server.bidder.model.BidderError;
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.vungle.model.VungleImpressionExt;
import org.prebid.server.currency.CurrencyConversionService;
import org.prebid.server.exception.PreBidException;
import org.prebid.server.proto.openrtb.ext.ExtPrebid;
import org.prebid.server.proto.openrtb.ext.request.liftoff.ExtImpLiftoff;
import org.prebid.server.proto.openrtb.ext.request.vungle.ExtImpVungle;

import java.math.BigDecimal;
import java.util.Arrays;
Expand All @@ -48,23 +48,23 @@
import static org.prebid.server.proto.openrtb.ext.response.BidType.video;

@ExtendWith(MockitoExtension.class)
public class LiftoffBidderTest extends VertxTest {
public class VungleBidderTest extends VertxTest {

private static final String ENDPOINT_URL = "https://test.endpoint.com";

@Mock(strictness = LENIENT)
private CurrencyConversionService currencyConversionService;

private LiftoffBidder target;
private VungleBidder target;

@BeforeEach
public void setUp() {
target = new LiftoffBidder(ENDPOINT_URL, currencyConversionService, jacksonMapper);
target = new VungleBidder(ENDPOINT_URL, currencyConversionService, jacksonMapper);
}

@Test
public void creationShouldFailOnInvalidEndpointUrl() {
assertThatIllegalArgumentException().isThrownBy(() -> new LiftoffBidder(
assertThatIllegalArgumentException().isThrownBy(() -> new VungleBidder(
"invalid_url",
currencyConversionService,
jacksonMapper));
Expand Down Expand Up @@ -176,7 +176,7 @@ public void makeHttpRequestsShouldThrowErrorWhenCurrencyConvertCannotConvertInAn
}

@Test
public void makeHttpRequestShouldUpdateExtImpLiftoffWhenUserBuyeruidPresent() {
public void makeHttpRequestShouldUpdateExtImpVungleWhenUserBuyeruidPresent() {
// given
final BidRequest bidRequest = givenBidRequest(
bidRequestBuilder -> bidRequestBuilder.user(User.builder().buyeruid("123").build()), identity());
Expand All @@ -190,20 +190,20 @@ public void makeHttpRequestShouldUpdateExtImpLiftoffWhenUserBuyeruidPresent() {
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getExt)
.containsExactly(mapper.convertValue(LiftoffImpressionExt.builder()
.bidder(ExtImpLiftoff.of(
.containsExactly(mapper.convertValue(VungleImpressionExt.builder()
.bidder(ExtImpVungle.of(
"any-bid-token",
"any-app-store-id",
"any-placement-reference-id"))
.vungle(ExtImpLiftoff.of(
.vungle(ExtImpVungle.of(
"123",
"any-app-store-id",
"any-placement-reference-id"))
.build(), ObjectNode.class));
}

@Test
public void makeHttpRequestShouldUpdateAppIdWhenExtImpLiftoffContainAppStoreId() {
public void makeHttpRequestShouldUpdateAppIdWhenExtImpVungleContainAppStoreId() {
// given
final App givenApp = App.builder().name("appName").build();
final BidRequest bidRequest = givenBidRequest(bidRequestBuilder -> bidRequestBuilder.app(givenApp), identity());
Expand All @@ -220,7 +220,7 @@ public void makeHttpRequestShouldUpdateAppIdWhenExtImpLiftoffContainAppStoreId()
}

@Test
public void makeHttpRequestShouldCreateAppWithIdWhenExtImpLiftoffContainAppStoreIdAndAppIsAbsentAndSiteIsPresent() {
public void makeHttpRequestShouldCreateAppWithIdWhenExtImpVungleContainAppStoreIdAndAppIsAbsentAndSiteIsPresent() {
// given
final BidRequest bidRequest = givenBidRequest(bidRequestBuilder -> bidRequestBuilder
.site(Site.builder().build())
Expand Down Expand Up @@ -258,7 +258,7 @@ public void makeHttpRequestShouldReturnErrorWhenAppAndSiteAreAbsent() {
}

@Test
public void makeHttpRequestShouldUpdateImpTagidWhenExtImpLiftoffContainPlacementReferenceId() {
public void makeHttpRequestShouldUpdateImpTagidWhenExtImpVungleContainPlacementReferenceId() {
// given
final BidRequest bidRequest = givenBidRequest(identity(), identity());

Expand All @@ -275,7 +275,7 @@ public void makeHttpRequestShouldUpdateImpTagidWhenExtImpLiftoffContainPlacement
}

@Test
public void makeHttpRequestShouldUpdateExtImpLiftoffBidTokenWhenInRequestPresentUserBuyeruid() {
public void makeHttpRequestShouldUpdateExtImpVungleBidTokenWhenInRequestPresentUserBuyeruid() {
// given
final BidRequest bidRequest = givenBidRequest(bidRequestBuilder ->
bidRequestBuilder.user(User.builder().buyeruid("Came-from-request").build()), identity());
Expand All @@ -289,11 +289,11 @@ public void makeHttpRequestShouldUpdateExtImpLiftoffBidTokenWhenInRequestPresent
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getExt)
.containsExactly(mapper.convertValue(LiftoffImpressionExt.builder()
.bidder(ExtImpLiftoff.of("any-bid-token",
.containsExactly(mapper.convertValue(VungleImpressionExt.builder()
.bidder(ExtImpVungle.of("any-bid-token",
"any-app-store-id",
"any-placement-reference-id"))
.vungle(ExtImpLiftoff.of(
.vungle(ExtImpVungle.of(
"Came-from-request",
"any-app-store-id",
"any-placement-reference-id"))
Expand Down Expand Up @@ -386,7 +386,7 @@ private static BidRequest givenBidRequest(

return bidRequestCustomizer.apply(BidRequest.builder()
.app(App.builder().build())
.imp(Arrays.stream(impCustomizer).map(LiftoffBidderTest::givenImp).toList()))
.imp(Arrays.stream(impCustomizer).map(VungleBidderTest::givenImp).toList()))
.build();
}

Expand All @@ -395,7 +395,7 @@ private static Imp givenImp(UnaryOperator<Imp.ImpBuilder> impCustomizer) {
.id("123")
.banner(Banner.builder().w(23).h(25).build())
.ext(mapper.valueToTree(ExtPrebid.of(null,
ExtImpLiftoff.of("any-bid-token",
ExtImpVungle.of("any-bid-token",
"any-app-store-id",
"any-placement-reference-id")))))
.build();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/prebid/server/it/LiftoffTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class LiftoffTest extends IntegrationTest {

@Test
public void openrtb2AuctionShouldRespondWithBidsFromliftoff() throws IOException, JSONException {
public void openrtb2AuctionShouldRespondWithBidsFromLiftoff() throws IOException, JSONException {
// given
WIRE_MOCK_RULE.stubFor(WireMock.post(WireMock.urlPathEqualTo("/liftoff-exchange"))
.withRequestBody(WireMock.equalToJson(
Expand Down
31 changes: 31 additions & 0 deletions src/test/java/org/prebid/server/it/VungleTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.prebid.server.it;

import com.github.tomakehurst.wiremock.client.WireMock;
import io.restassured.response.Response;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.prebid.server.model.Endpoint;

import java.io.IOException;

import static java.util.Collections.singletonList;

public class VungleTest extends IntegrationTest {

@Test
public void openrtb2AuctionShouldRespondWithBidsFromVungle() throws IOException, JSONException {
// given
WIRE_MOCK_RULE.stubFor(WireMock.post(WireMock.urlPathEqualTo("/vungle-exchange"))
.withRequestBody(WireMock.equalToJson(
jsonFrom("openrtb2/vungle/test-vungle-bid-request.json")))
.willReturn(WireMock.aResponse().withBody(
jsonFrom("openrtb2/vungle/test-vungle-bid-response.json"))));

// when
final Response response = responseFor("openrtb2/vungle/test-auction-vungle-request.json",
Endpoint.openrtb2_auction);

// then
assertJsonEquals("openrtb2/vungle/test-auction-vungle-response.json", response, singletonList("vungle"));
}
}
Loading

0 comments on commit 796ee57

Please sign in to comment.