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

Add PG tests infrastructure #1581

Merged
merged 11 commits into from
Feb 10, 2022
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
<mockito-junit-jupiter.version>4.0.0</mockito-junit-jupiter.version>
<assertj.version>3.21.0</assertj.version>
<wiremock.version>2.31.0</wiremock.version>
<awaitility.version>4.1.0</awaitility.version>
<awaitility.version>4.1.1</awaitility.version>
<jetty.version>9.4.44.v20210927</jetty.version>
<restassured.version>4.4.0</restassured.version>
<h2.version>2.1.210</h2.version>
<spock.version>2.0-groovy-3.0</spock.version>
<testcontainers.version>1.16.2</testcontainers.version>
<testcontainers.version>1.16.3</testcontainers.version>
<mockserver-client.version>5.11.2</mockserver-client.version>
<allure.version>2.16.1</allure.version>
<allure.version>2.17.2</allure.version>
<aspectj.version>1.9.7</aspectj.version>
<h2.version>1.4.200</h2.version>
<bytebuddy.version>1.11.19</bytebuddy.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.prebid.server.functional.model.deals.alert

enum Action {

RAISE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.prebid.server.functional.model.deals.alert

import com.fasterxml.jackson.databind.PropertyNamingStrategies
import com.fasterxml.jackson.databind.annotation.JsonNaming
import groovy.transform.ToString

import java.time.ZonedDateTime

@ToString(includeNames = true, ignoreNulls = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy)
class AlertEvent {

String id
Action action
AlertPriority priority
ZonedDateTime updatedAt
String name
String details
AlertSource source
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.prebid.server.functional.model.deals.alert

enum AlertPriority {

HIGH, MEDIUM, LOW
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.prebid.server.functional.model.deals.alert

import com.fasterxml.jackson.databind.PropertyNamingStrategies
import com.fasterxml.jackson.databind.annotation.JsonNaming
import groovy.transform.ToString

@ToString(includeNames = true, ignoreNulls = true)
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy)
class AlertSource {

String env
String dataCenter
String region
String system
String subSystem
String hostId
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonFormat
import groovy.transform.ToString
import org.prebid.server.functional.util.PBSUtils

import java.time.ZoneId
import java.time.ZonedDateTime

import static java.time.ZoneOffset.UTC
import static org.prebid.server.functional.model.deals.lineitem.LineItem.TIME_PATTERN

@ToString(includeNames = true, ignoreNulls = true)
class DeliverySchedule {

String planId

@JsonFormat(pattern = TIME_PATTERN)
ZonedDateTime startTimeStamp

@JsonFormat(pattern = TIME_PATTERN)
ZonedDateTime endTimeStamp

@JsonFormat(pattern = TIME_PATTERN)
ZonedDateTime updatedTimeStamp

Set<Token> tokens

static getDefaultDeliverySchedule() {
new DeliverySchedule(planId: PBSUtils.randomString,
startTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)),
endTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)).plusDays(1),
updatedTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)),
tokens: [Token.defaultToken]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.prebid.server.functional.model.deals.lineitem

import groovy.transform.ToString
import org.prebid.server.functional.util.PBSUtils

import static PeriodType.DAY

@ToString(includeNames = true, ignoreNulls = true)
class FrequencyCap {

String fcapId
Integer count
Integer periods
String periodType

static getDefaultFrequencyCap() {
new FrequencyCap(count: 1,
fcapId: PBSUtils.randomString,
periods: 1,
periodType: DAY
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonFormat
import groovy.transform.ToString
import org.prebid.server.functional.model.deals.lineitem.targeting.Targeting
import org.prebid.server.functional.util.PBSUtils

import java.time.ZoneId
import java.time.ZonedDateTime

import static LineItemStatus.ACTIVE
import static java.time.ZoneOffset.UTC
import static org.prebid.server.functional.model.bidder.BidderName.GENERIC
import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.VERY_HIGH

@ToString(includeNames = true, ignoreNulls = true)
class LineItem {

public static final String TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"

String lineItemId

String extLineItemId

String dealId

List<LineItemSize> sizes

String accountId

String source

Price price

RelativePriority relativePriority

@JsonFormat(pattern = TIME_PATTERN)
ZonedDateTime startTimeStamp

@JsonFormat(pattern = TIME_PATTERN)
ZonedDateTime endTimeStamp

@JsonFormat(pattern = TIME_PATTERN)
ZonedDateTime updatedTimeStamp

LineItemStatus status

List<FrequencyCap> frequencyCaps

List<DeliverySchedule> deliverySchedules

Targeting targeting

static LineItem getDefaultLineItem(String accountId) {
int plannerAdapterLineItemId = PBSUtils.randomNumber
String plannerAdapterName = PBSUtils.randomString
new LineItem(lineItemId: "${plannerAdapterName}-$plannerAdapterLineItemId",
extLineItemId: plannerAdapterLineItemId,
dealId: PBSUtils.randomString,
sizes: [LineItemSize.defaultLineItemSize],
accountId: accountId,
source: GENERIC.name().toLowerCase(),
price: Price.defaultPrice,
relativePriority: VERY_HIGH,
startTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)),
endTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)).plusMonths(1),
updatedTimeStamp: ZonedDateTime.now(ZoneId.from(UTC)),
status: ACTIVE,
frequencyCaps: [],
deliverySchedules: [DeliverySchedule.defaultDeliverySchedule],
targeting: Targeting.defaultTargeting
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.prebid.server.functional.model.deals.lineitem

import groovy.transform.ToString

@ToString(includeNames = true)
class LineItemSize {

Integer w
Integer h

static getDefaultLineItemSize() {
new LineItemSize(w: 300,
h: 250
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonValue

enum LineItemStatus {

ACTIVE("active"),
DELETED("deleted"),
PAUSED("paused")

@JsonValue
final String value

private LineItemStatus(String value) {
this.value = value
}

@Override
String toString() {
value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonValue

enum MediaType {

BANNER("banner")

@JsonValue
final String value

private MediaType(String value) {
this.value = value
}

@Override
String toString() {
value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonValue

enum PeriodType {

HOUR("hour"),
DAY("day"),
WEEK("week"),
MONTH("month"),
CAMPAIGN("campaign")

@JsonValue
final String value

private PeriodType(String value) {
this.value = value
}

@Override
String toString() {
value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.prebid.server.functional.model.deals.lineitem

import groovy.transform.ToString

@ToString(includeNames = true, ignoreNulls = true)
class Price {

BigDecimal cpm
String currency

static getDefaultPrice() {
new Price(cpm: 0.01,
currency: "USD"
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonValue

enum RelativePriority {

VERY_HIGH(1),
HIGH(2),
MEDIUM(3),
LOW(4),
VERY_LOW(5)

@JsonValue
final Integer value

private RelativePriority(Integer value) {
this.value = value
}

@Override
String toString() {
value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonProperty
import groovy.transform.ToString

@ToString(includeNames = true, ignoreNulls = true)
class Token {

@JsonProperty("class")
Integer priorityClass

Integer total

static getDefaultToken() {
new Token(priorityClass: 1,
total: 1000
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.prebid.server.functional.model.deals.lineitem.targeting

import com.fasterxml.jackson.annotation.JsonValue

enum BooleanOperator {

AND('$and'),
OR('$or'),
NOT('$not'),

INVALID('$invalid'),
UPPERCASE_AND('$AND')

@JsonValue
final String value

private BooleanOperator(String value) {
this.value = value
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.prebid.server.functional.model.deals.lineitem.targeting

import com.fasterxml.jackson.annotation.JsonValue

enum MatchingFunction {

MATCHES('$matches'),
IN('$in'),
INTERSECTS('$intersects'),
WITHIN('$within')

@JsonValue
final String value

private MatchingFunction(String value) {
this.value = value
}
}
Loading