Skip to content
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

GPP4.5: Functional tests for custom logic functionality #2494

Merged
merged 19 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8c541da
Add GPP4.5: Functional tests for custom logic functionality
osulzhenko Jul 10, 2023
9aea823
Update normalizing for age restriction
osulzhenko Sep 11, 2023
639cb04
Update jsonLogic formatting
osulzhenko Sep 18, 2023
fb05a2c
Merge branch 'add-custom-logic-privacy-module' into tests-gpp-custom-…
osulzhenko Sep 18, 2023
1e4dceb
Refactor custom logic and remove `shouldBeEqual` property
osulzhenko Sep 18, 2023
c9f6e45
Update after review
osulzhenko Sep 18, 2023
8300b16
Merge branch 'add-custom-logic-privacy-module' into tests-gpp-custom-…
osulzhenko Sep 18, 2023
2c84835
Update warning tests and activity config default
osulzhenko Sep 19, 2023
9cc916a
Merge branch 'add-custom-logic-privacy-module' into tests-gpp-custom-…
osulzhenko Sep 19, 2023
a9b10d8
Merge branch 'add-custom-logic-privacy-module' into tests-gpp-custom-…
osulzhenko Sep 19, 2023
9c8d691
Rework normalize and update test cases
osulzhenko Sep 19, 2023
d292aa5
Merge branch 'add-custom-logic-privacy-module' into tests-gpp-custom-…
osulzhenko Sep 19, 2023
cd3c578
Merge branch 'add-custom-logic-privacy-module' into tests-gpp-custom-…
osulzhenko Sep 20, 2023
493f1a9
Fix test issue
osulzhenko Sep 20, 2023
ea76303
Update due to provided comments
osulzhenko Sep 20, 2023
4ed6efd
Update due to provided comments
osulzhenko Sep 20, 2023
945a856
Merge branch 'add-custom-logic-privacy-module' into tests-gpp-custom-…
osulzhenko Sep 20, 2023
ced08cf
Update error message for JsonLogic exception
osulzhenko Sep 20, 2023
e135591
Minnor fix
osulzhenko Sep 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'add-custom-logic-privacy-module' into tests-gpp-custom-…
…logic
  • Loading branch information
osulzhenko committed Sep 19, 2023
commit 9cc916a524fc7c32137a0bae355655a22dc8f50b
8 changes: 4 additions & 4 deletions extra/bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
<relativePath>../../extra/pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -74,17 +74,17 @@
<dependency>
<groupId>org.prebid</groupId>
<artifactId>prebid-server</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>confiant-ad-quality</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>ortb2-blocking</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion extra/modules/confiant-ad-quality/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
</parent>

<artifactId>confiant-ad-quality</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extra/modules/ortb2-blocking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
</parent>

<artifactId>ortb2-blocking</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions extra/modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
<relativePath>../../extra/pom.xml</relativePath>
</parent>

Expand All @@ -28,7 +28,7 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>

<prebid-server.version>1.129.0-SNAPSHOT</prebid-server.version>
<prebid-server.version>1.130.0-SNAPSHOT</prebid-server.version>

<lombok.version>1.18.22</lombok.version>

Expand Down
2 changes: 1 addition & 1 deletion extra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
<packaging>pom</packaging>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>1.129.0-SNAPSHOT</version>
<version>1.130.0-SNAPSHOT</version>
<relativePath>extra/pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static java.util.function.Function.identity;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.tuple;
import static org.prebid.server.proto.openrtb.ext.response.BidType.audio;
import static org.prebid.server.proto.openrtb.ext.response.BidType.banner;
import static org.prebid.server.proto.openrtb.ext.response.BidType.video;
Expand Down
106 changes: 59 additions & 47 deletions src/test/java/org/prebid/server/bidder/ix/IxBidderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.iab.openrtb.response.EventTracker;
import com.iab.openrtb.response.Response;
import com.iab.openrtb.response.SeatBid;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
Expand Down Expand Up @@ -60,7 +62,19 @@ public class IxBidderTest extends VertxTest {
private static final String ENDPOINT_URL = "http://exchange.org/";
private static final String SITE_ID = "site id";

private final IxBidder target = new IxBidder(ENDPOINT_URL, jacksonMapper);
@Rule
public final MockitoRule mockitoRule = MockitoJUnit.rule();

@Mock
private PrebidVersionProvider prebidVersionProvider;

private IxBidder target;

@Before
public void setUp() {
target = new IxBidder(ENDPOINT_URL, prebidVersionProvider, jacksonMapper);
given(prebidVersionProvider.getNameVersionRecord()).willReturn(null);
}

@Test
public void creationShouldFailOnInvalidEndpointUrl() {
Expand Down Expand Up @@ -95,45 +109,8 @@ public void makeHttpRequestsShouldModifyImpExtWithSid() {

// then
assertThat(result.getErrors()).isEmpty();
}

@Test
public void makeHttpRequestsShouldSetSitePublisherIdFromImpExtWhenSitePresent() {
// given
final Banner banner = Banner.builder().w(100).h(200).build();
final BidRequest bidRequest = givenBidRequest(
builder -> builder.site(Site.builder().build()),
impBuilder -> impBuilder.banner(banner));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1)
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
.extracting(BidRequest::getSite)
.extracting(Site::getPublisher)
.extracting(Publisher::getId)
.containsOnly(SITE_ID);
}

@Test
public void makeHttpRequestsShouldCreateBannerFormatIfOnlyBannerHeightAndWidthArePresent() {
// given
final BidRequest bidRequest = givenBidRequest(
impBuilder -> impBuilder.banner(Banner.builder()
.w(300)
.h(200)
.build()));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(1)
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getExt)
.hasSize(1)
Expand All @@ -159,13 +136,8 @@ public void makeHttpRequestsShouldSetImpBannerFormatsToFormatWithWidthAndHeightI
.format(singletonList(Format.builder().w(1).h(2).build()))
.build();

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue()).hasSize(2)
.extracting(httpRequest -> mapper.readValue(httpRequest.getBody(), BidRequest.class))
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.flatExtracting(BidRequest::getImp)
.extracting(Imp::getBanner)
.containsExactly(expectedBanner);
Expand Down Expand Up @@ -246,6 +218,46 @@ public void makeHttpRequestsShouldReturnIxDiagWithMultipleSiteIdsWhenMultipleImp
// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.extracting(BidRequest::getExt)
.extracting(ext -> ext.getProperty("ixdiag"))
.extracting(diagNode -> mapper.treeToValue(diagNode, IxDiag.class))
.containsExactly(IxDiag.of(null, null, "site1, site2"));
}

@Test
public void makeHttpRequestsShouldModifyRequestSiteWithPublisherAndSetIdWhenImpExtSiteIdPresent() {
// given
final BidRequest bidRequest = givenBidRequest(
bidRequestBuilder -> bidRequestBuilder.site(Site.builder().build()),
singletonList(impBuilder -> impBuilder.ext(givenImpExt("site1", null))));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
final Site exptectedSite = Site.builder()
.publisher(Publisher.builder().id("site1").build())
.build();
assertThat(result.getValue())
.extracting(HttpRequest::getPayload)
.extracting(BidRequest::getSite)
.containsExactly(exptectedSite);
}

@Test
public void makeHttpRequestsShouldNotCreateRequestSiteWhenImpExtSiteIdPresentAndSiteIsAbsent() {
// given
final BidRequest bidRequest = givenBidRequest(
impBuilder -> impBuilder.ext(givenImpExt("site1", null)));

// when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

// then
assertThat(result.getErrors()).isEmpty();
assertThat(result.getValue())
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.