Skip to content

Commit

Permalink
Add PG tests infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
mhupalo committed Nov 16, 2021
1 parent 6bda093 commit cdc197d
Show file tree
Hide file tree
Showing 65 changed files with 1,486 additions and 22 deletions.
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 Status.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

Status 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,20 @@
package org.prebid.server.functional.model.deals.lineitem

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

import static com.fasterxml.jackson.annotation.JsonInclude.Include.ALWAYS

@ToString(includeNames = true)
@JsonInclude(content = ALWAYS)
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,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,22 @@
package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonValue

enum Status {

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

@JsonValue
final String value

private Status(String 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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.prebid.server.functional.model.deals.lineitem.targeting

import com.fasterxml.jackson.annotation.JsonValue
import groovy.transform.PackageScope

@PackageScope
class MatchingFunctionNode {

Map<MatchingFunction, List<?>> matchingFunctionMultipleValuesNode

Map<MatchingFunction, ?> matchingFunctionSingleValueNode

@JsonValue
def getMatchingFunctionNode() {
matchingFunctionMultipleValuesNode ?: matchingFunctionSingleValueNode
}
}
Loading

0 comments on commit cdc197d

Please sign in to comment.