Skip to content

Commit

Permalink
Minor refactoring 1st part
Browse files Browse the repository at this point in the history
  • Loading branch information
Net-burst committed Feb 8, 2022
1 parent 054c4d9 commit b044b51
Show file tree
Hide file tree
Showing 25 changed files with 50 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<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>
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 @@ -180,7 +180,6 @@ class AlertSpec extends BasePgSpec {
alertRequest.source.hostId == pgPbsProperties.hostId
}
cleanup: "Return initial Planner response status code"
generalPlanner.initRegisterResponse()
Expand Down
22 changes: 9 additions & 13 deletions src/test/groovy/org/prebid/server/functional/pg/BasePgSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.prebid.server.functional.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
Expand All @@ -15,27 +16,22 @@ 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
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 Bidder bidder = new Bidder(Dependencies.networkServiceContainer, mapper)

def setupSpec() {
generalPlanner.setResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
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,6 +1,5 @@
package org.prebid.server.functional.pg


import org.prebid.server.functional.model.mock.services.generalplanner.PlansResponse
import org.prebid.server.functional.model.request.dealsupdate.ForceDealsUpdateRequest
import org.prebid.server.functional.util.HttpUtil
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

0 comments on commit b044b51

Please sign in to comment.