Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Net-burst authored and Oleksandr Zhevedenko committed Feb 9, 2022
1 parent 054c4d9 commit c39af80
Show file tree
Hide file tree
Showing 35 changed files with 71 additions and 58 deletions.
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
Expand Up @@ -8,7 +8,7 @@ import org.prebid.server.functional.util.PBSUtils
import java.time.ZoneId
import java.time.ZonedDateTime

import static Status.ACTIVE
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
Expand Down Expand Up @@ -43,7 +43,7 @@ class LineItem {
@JsonFormat(pattern = TIME_PATTERN)
ZonedDateTime updatedTimeStamp

Status status
LineItemStatus status

List<FrequencyCap> frequencyCaps

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.prebid.server.functional.model.deals.lineitem

import com.fasterxml.jackson.annotation.JsonValue

enum Status {
enum LineItemStatus {

ACTIVE("active"),
DELETED("deleted"),
Expand All @@ -11,7 +11,7 @@ enum Status {
@JsonValue
final String value

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import groovy.transform.ToString

import java.time.ZonedDateTime

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

ZonedDateTime lastUpdate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.prebid.server.functional.model.deals.userdata
import groovy.transform.ToString
import org.prebid.server.functional.model.ResponseModel

@ToString(includeNames = true)
@ToString(includeNames = true, ignoreNulls = true)
class UserDetailsResponse implements ResponseModel {

User user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies
import com.fasterxml.jackson.databind.annotation.JsonNaming
import groovy.transform.ToString
import org.prebid.server.functional.util.PBSUtils
import org.prebid.server.functional.util.privacy.ConsentString

@ToString(includeNames = true, ignoreNulls = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.prebid.server.functional.model.request.auction

import groovy.transform.ToString

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

AppExtData data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.prebid.server.functional.model.request.auction

import groovy.transform.ToString

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

String language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import groovy.transform.ToString
@ToString(includeNames = true)
class DealExt {

DealLine line
DealLineItem line
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import groovy.transform.ToString

@ToString(includeNames = true, ignoreNulls = true)
@JsonNaming(PropertyNamingStrategies.LowerCaseStrategy)
class DealLine {
class DealLineItem {

String lineItemId
String extLineItemId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.prebid.server.functional.model.request.auction

import groovy.transform.ToString

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

ImpExtContextData data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.prebid.server.functional.model.request.auction

import groovy.transform.ToString

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

String language
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.prebid.server.functional.model.request.auction

import groovy.transform.ToString

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

String language
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.prebid.server.functional.model.request.auction

import groovy.transform.ToString

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

String language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsU
import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest.Action.SEND_REPORT
import static org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest.Action.UPDATE_LINE_ITEMS

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.prebid.server.functional.testcontainers.container.PrebidServerContain
import org.prebid.server.functional.util.ObjectMapperWrapper
import org.prebid.server.functional.util.PBSUtils

// TODO make container instance into a POGO and add the ability for any given container to live through stopContainers()
class PbsServiceFactory {

private static final Map<Map<String, String>, PrebidServerContainer> containers = [:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class GeneralPlanner extends NetworkScaffolding {
setResponse(statusCode)
}

void initPlansResponse(PlansResponse plansResponse, HttpStatusCode statusCode = OK_200, Times times = Times.exactly(1)) {
void initPlansResponse(PlansResponse plansResponse,
HttpStatusCode statusCode = OK_200,
Times times = Times.exactly(1)) {
resetPlansEndpoint()
setPlansResponse(plansResponse, statusCode, times)
}
Expand Down Expand Up @@ -63,7 +65,9 @@ class GeneralPlanner extends NetworkScaffolding {
getLastRecordedRequestHeaders(plansRequest)
}

private void setPlansResponse(PlansResponse plansResponse, HttpStatusCode statusCode, Times times = Times.exactly(1)) {
private void setPlansResponse(PlansResponse plansResponse,
HttpStatusCode statusCode,
Times times = Times.exactly(1)) {
setResponse(plansRequest, plansResponse, statusCode, times)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.prebid.server.functional.util.PBSUtils
import org.prebid.server.functional.util.privacy.CcpaConsent

import static org.prebid.server.functional.model.bidder.BidderName.APPNEXUS
import static org.prebid.server.functional.model.response.auction.ErrorType.PREBID
import static org.prebid.server.functional.util.privacy.CcpaConsent.Signal.ENFORCED

@PBSTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.prebid.server.functional.tests

import org.prebid.server.functional.model.UidsCookie
import org.prebid.server.functional.model.db.StoredRequest
import org.prebid.server.functional.model.mock.services.httpsettings.HttpAccountsResponse
import org.prebid.server.functional.model.request.amp.AmpRequest
import org.prebid.server.functional.model.request.auction.BidRequest
import org.prebid.server.functional.model.request.event.EventRequest
import org.prebid.server.functional.model.request.setuid.SetuidRequest
import org.prebid.server.functional.model.UidsCookie
import org.prebid.server.functional.model.request.vtrack.VtrackRequest
import org.prebid.server.functional.model.request.vtrack.xml.Vast
import org.prebid.server.functional.service.PrebidServerException
Expand Down Expand Up @@ -120,7 +120,8 @@ class HttpSettingsSpec extends BaseSpec {
assert response.uidsCookie.bday
assert !response.uidsCookie.tempUIDs
assert !response.uidsCookie.uids
assert response.responseBody == ResourceUtil.readByteArrayFromClassPath("org/prebid/server/functional/tracking-pixel.png")
assert response.responseBody ==
ResourceUtil.readByteArrayFromClassPath("org/prebid/server/functional/tracking-pixel.png")

and: "There should be only one account request"
assert httpSettings.getRequestCount(request.account) == 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.prebid.server.functional.tests

import org.prebid.server.functional.model.UidsCookie
import org.prebid.server.functional.model.db.Account
import org.prebid.server.functional.model.db.StoredRequest
import org.prebid.server.functional.model.request.amp.AmpRequest
Expand All @@ -8,7 +9,6 @@ import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest
import org.prebid.server.functional.model.request.event.EventRequest
import org.prebid.server.functional.model.request.logging.httpinteraction.HttpInteractionRequest
import org.prebid.server.functional.model.request.setuid.SetuidRequest
import org.prebid.server.functional.model.UidsCookie
import org.prebid.server.functional.model.request.vtrack.VtrackRequest
import org.prebid.server.functional.model.request.vtrack.xml.Vast
import org.prebid.server.functional.model.response.cookiesync.CookieSyncResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.functional.pg
package org.prebid.server.functional.tests.pg

import org.mockserver.matchers.Times
import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse
Expand Down Expand Up @@ -180,7 +180,6 @@ class AlertSpec extends BasePgSpec {
alertRequest.source.hostId == pgPbsProperties.hostId
}
cleanup: "Return initial Planner response status code"
generalPlanner.initRegisterResponse()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.prebid.server.functional.pg
package org.prebid.server.functional.tests.pg

import org.prebid.server.functional.model.deals.userdata.UserDetailsResponse
import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest
import org.prebid.server.functional.service.PrebidServerService
import org.prebid.server.functional.testcontainers.Dependencies
import org.prebid.server.functional.testcontainers.PBSTest
import org.prebid.server.functional.testcontainers.PbsContainerProperties
import org.prebid.server.functional.testcontainers.PbsPgConfig
import org.prebid.server.functional.testcontainers.PbsServiceFactory
import org.prebid.server.functional.testcontainers.scaffolding.Bidder
Expand All @@ -15,27 +15,23 @@ import org.prebid.server.functional.testcontainers.scaffolding.pg.UserData
import org.prebid.server.functional.util.ObjectMapperWrapper
import spock.lang.Specification

import static org.prebid.server.functional.testcontainers.Dependencies.networkServiceContainer
import static org.prebid.server.functional.testcontainers.Dependencies.objectMapperWrapper

@PBSTest
// TODO migrate this to extend BaseSpec
abstract class BasePgSpec extends Specification {

protected static final ObjectMapperWrapper mapper = objectMapperWrapper
protected static final PbsServiceFactory pbsServiceFactory = new PbsServiceFactory(networkServiceContainer, mapper)
protected static final ObjectMapperWrapper mapper = Dependencies.objectMapperWrapper
protected static final PbsServiceFactory pbsServiceFactory = new PbsServiceFactory(Dependencies.networkServiceContainer, mapper)

protected static final GeneralPlanner generalPlanner = new GeneralPlanner(networkServiceContainer, mapper).tap {
setResponse()
}
protected static final DeliveryStatistics deliveryStatistics = new DeliveryStatistics(networkServiceContainer, mapper)
protected static final Alert alert = new Alert(networkServiceContainer, mapper)
protected static final UserData userData = new UserData(networkServiceContainer, mapper)
protected static final GeneralPlanner generalPlanner = new GeneralPlanner(Dependencies.networkServiceContainer, mapper)
protected static final DeliveryStatistics deliveryStatistics = new DeliveryStatistics(Dependencies.networkServiceContainer, mapper)
protected static final Alert alert = new Alert(Dependencies.networkServiceContainer, mapper)
protected static final UserData userData = new UserData(Dependencies.networkServiceContainer, mapper)

private static final Map<String, String> pgPbsConfig = pbsServiceFactory.generalSettings() +
PbsPgConfig.getPgConfig(networkServiceContainer)
PbsPgConfig.getPgConfig(Dependencies.networkServiceContainer)
protected static final PrebidServerService pgPbsService = pbsServiceFactory.getService(pgPbsConfig)
protected static final PbsContainerProperties pgPbsProperties = new PbsContainerProperties(pbsServiceFactory.getContainer(pgPbsConfig))
protected static final Bidder bidder = new Bidder(networkServiceContainer, mapper)
protected static final PgProperties pgPbsProperties = new PgProperties(pbsServiceFactory.getContainer(pgPbsConfig))
protected static final Bidder bidder = new Bidder(Dependencies.networkServiceContainer, mapper)

def setupSpec() {
generalPlanner.setResponse()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.functional.pg
package org.prebid.server.functional.tests.pg

import org.prebid.server.functional.model.deals.lineitem.LineItem
import org.prebid.server.functional.model.deals.lineitem.Price
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.functional.pg
package org.prebid.server.functional.tests.pg

import org.prebid.server.functional.model.UidsCookie
import org.prebid.server.functional.model.bidder.Generic
Expand All @@ -25,13 +25,13 @@ import java.time.ZonedDateTime

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.LineItemStatus.DELETED
import static org.prebid.server.functional.model.deals.lineitem.LineItemStatus.PAUSED
import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.HIGH
import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.LOW
import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.MEDIUM
import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.VERY_HIGH
import static org.prebid.server.functional.model.deals.lineitem.RelativePriority.VERY_LOW
import static org.prebid.server.functional.model.deals.lineitem.Status.DELETED
import static org.prebid.server.functional.model.deals.lineitem.Status.PAUSED
import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.IN
import static org.prebid.server.functional.model.deals.lineitem.targeting.MatchingFunction.INTERSECTS
import static org.prebid.server.functional.model.deals.lineitem.targeting.TargetingType.AD_UNIT_MEDIA_TYPE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.functional.pg
package org.prebid.server.functional.tests.pg

import org.prebid.server.functional.model.deals.lineitem.LineItemSize
import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.functional.pg
package org.prebid.server.functional.tests.pg

import org.prebid.server.functional.model.UidsCookie
import org.prebid.server.functional.model.bidder.Generic
Expand Down Expand Up @@ -122,7 +122,7 @@ class PgBidderRequestSpec extends BasePgSpec {
pgPbsService.sendForceDealsUpdateRequest(ForceDealsUpdateRequest.updateLineItemsRequest)

when: "Sending auction request to PBS"
def auctionResponse = pgPbsService.sendAuctionRequest(bidRequest)
pgPbsService.sendAuctionRequest(bidRequest)

then: "PBS sent a request to the bidder with two impressions"
def bidderRequest = bidder.getBidderRequest(bidRequest.id)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.prebid.server.functional.testcontainers
package org.prebid.server.functional.tests.pg

import org.prebid.server.functional.testcontainers.container.PrebidServerContainer

import static org.prebid.server.functional.testcontainers.container.PrebidServerContainer.normalizeProperty

class PbsContainerProperties {
class PgProperties {

String env
String dataCenter
Expand All @@ -18,7 +18,7 @@ class PbsContainerProperties {
int maxDealsPerBidder
int lineItemsPerReport

PbsContainerProperties(PrebidServerContainer prebidServerContainer) {
PgProperties(PrebidServerContainer prebidServerContainer) {
Map<String, String> properties = prebidServerContainer.envMap

env = getStringProperty(properties, "profile")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package org.prebid.server.functional.pg

package org.prebid.server.functional.tests.pg

import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse
import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.prebid.server.functional.pg
package org.prebid.server.functional.tests.pg

import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse
import org.prebid.server.functional.model.request.auction.BidRequest
Expand Down
Loading

0 comments on commit c39af80

Please sign in to comment.