-
Notifications
You must be signed in to change notification settings - Fork 224
Test: Rule Engine #4103
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
Test: Rule Engine #4103
Changes from 29 commits
02ab85c
c3a3fff
957262f
f15d769
8ec56a1
63767ef
ab17da1
015a7a4
f8ff419
12a450e
bb4acff
c2d39ae
6aae51a
b69aea7
5c0254d
4b72217
71348bc
59762ee
d35ce57
1062924
eb01920
2a771df
30b03da
46634fc
091792a
4ee6904
3d5be3b
536ca57
e3f35b1
569fb3b
6dc82e4
67252a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| class PbRulesEngine { | ||
|
|
||
| Boolean enabled | ||
| Boolean generateRulesFromBidderConfig | ||
| List<RuleSet> ruleSets | ||
|
|
||
| static PbRulesEngine createRulesEngineWithRule(Boolean enabled = true) { | ||
| new PbRulesEngine().tap { | ||
| it.enabled = enabled | ||
| it.generateRulesFromBidderConfig = false | ||
| it.ruleSets = [RuleSet.createRuleSets()] | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonValue | ||
|
|
||
| enum ResultFunction { | ||
|
|
||
| INCLUDE_BIDDERS("includeBidders"), | ||
| EXCLUDE_BIDDER("excludeBidders"), | ||
| LOG_A_TAG("logAtag") | ||
|
|
||
| String value | ||
|
|
||
| ResultFunction(String value) { | ||
| this.value = value | ||
| } | ||
|
|
||
| @Override | ||
| @JsonValue | ||
| String toString() { | ||
| return value | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import org.prebid.server.functional.model.bidder.BidderName | ||
|
|
||
| class RuleEngineArguments { | ||
|
|
||
| List<BidderName> bidders | ||
| Integer seatNonBid | ||
| Boolean ifSyncedId | ||
| String analyticsValue | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonValue | ||
|
|
||
| enum RuleEngineFunction { | ||
|
|
||
| DEVICE_COUNTRY("deviceCountry"), | ||
| DEVICE_COUNTRY_IN("deviceCountryIn"), | ||
| DATA_CENTER("dataCenter"), | ||
| DATA_CENTER_IN("dataCenterIn"), | ||
| CHANNEL("channel"), | ||
| EID_AVAILABLE("eidAvailable"), | ||
| EID_IN("eidIn"), | ||
| USER_FPD_AVAILABLE("userFpdAvailable"), | ||
| FPD_AVAILABLE("fpdAvailable"), | ||
| GPP_SID_AVAILABLE("gppSidAvailable"), | ||
| GPP_SID_IN("gppSidIn"), | ||
| TCF_IN_SCOPE("tcfInScope"), | ||
| PERCENT("percent"), | ||
| PREBID_KEY("prebidKey"), | ||
| DOMAIN("domain"), | ||
| DOMAIN_IN("domainIn"), | ||
| BUNDLE("bundle"), | ||
| BUNDLE_IN("bundleIn"), | ||
| MEDIA_TYPE_IN("mediaTypeIn"), | ||
| AD_UNIT_CODE("adUnitCode"), | ||
| AD_UNIT_CODE_IN("adUnitCodeIn"), | ||
| DEVICE_TYPE("deviceType"), | ||
| DEVICE_TYPE_IN("deviceTypeIn"), | ||
|
|
||
| private String value | ||
|
|
||
| RuleEngineFunction(String value) { | ||
| this.value = value | ||
| } | ||
|
|
||
| @JsonValue | ||
| @Override | ||
| String toString() { | ||
| return value | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty | ||
| import org.prebid.server.functional.util.PBSUtils | ||
|
|
||
| class RuleEngineFunctionArgs { | ||
|
|
||
| List<Object> countries | ||
| List<Object> datacenters | ||
| List<Object> sources | ||
| List<Object> sids | ||
| @JsonProperty("pct") | ||
| Object percent | ||
| Object key | ||
| List<Object> domains | ||
| List<Object> bundles | ||
| List<Object> codes | ||
| List<Object> types | ||
marki1an marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| String operator | ||
| BigDecimal value | ||
| Currency currency | ||
|
|
||
| static RuleEngineFunctionArgs getDefaultFunctionArgs() { | ||
| new RuleEngineFunctionArgs().tap { | ||
| countries = [PBSUtils.randomString] | ||
| datacenters = [PBSUtils.randomString] | ||
| sources = [PBSUtils.randomString] | ||
| sids = [PBSUtils.randomNumber] | ||
| percent = PBSUtils.getRandomNumber(1, 100) | ||
| key = PBSUtils.randomString | ||
| domains = [PBSUtils.randomString] | ||
| bundles = [PBSUtils.randomString] | ||
| codes = [PBSUtils.randomString] | ||
| types = [PBSUtils.randomString] | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| class RuleEngineModelDefault { | ||
|
|
||
| ResultFunction function | ||
| RuleEngineModelDefaultArgs args | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| class RuleEngineModelDefaultArgs { | ||
|
|
||
| String analyticsValue | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import static java.lang.Boolean.TRUE | ||
| import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult | ||
|
|
||
| class RuleEngineModelRule { | ||
|
|
||
| List<String> conditions | ||
| List<RuleEngineModelRuleResult> results | ||
|
|
||
| static RuleEngineModelRule createRuleEngineModelRule() { | ||
| new RuleEngineModelRule().tap { | ||
| it.conditions = [TRUE as String] | ||
| it.results = [createRuleEngineModelRuleWithExcludeResult()] | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import org.prebid.server.functional.model.bidder.BidderName | ||
|
|
||
| import static org.prebid.server.functional.model.bidder.BidderName.ACEEX | ||
| import static org.prebid.server.functional.model.bidder.BidderName.OPENX | ||
| import static org.prebid.server.functional.model.config.ResultFunction.EXCLUDE_BIDDER | ||
| import static org.prebid.server.functional.model.config.ResultFunction.INCLUDE_BIDDERS | ||
| import static org.prebid.server.functional.model.config.ResultFunction.LOG_A_TAG | ||
|
|
||
| class RuleEngineModelRuleResult { | ||
|
|
||
| ResultFunction function | ||
| RuleEngineModelRuleResultsArgs args | ||
|
|
||
| static RuleEngineModelRuleResult createRuleEngineModelRuleWithIncludeResult(BidderName bidderName = ACEEX) { | ||
| new RuleEngineModelRuleResult().tap { | ||
| it.function = INCLUDE_BIDDERS | ||
| it.args = RuleEngineModelRuleResultsArgs.createRuleEngineModelRuleResultsArgs(bidderName) | ||
| } | ||
| } | ||
|
|
||
| static RuleEngineModelRuleResult createRuleEngineModelRuleWithExcludeResult(BidderName bidderName = OPENX) { | ||
| new RuleEngineModelRuleResult().tap { | ||
| it.function = EXCLUDE_BIDDER | ||
| it.args = RuleEngineModelRuleResultsArgs.createRuleEngineModelRuleResultsArgs(bidderName) | ||
| } | ||
| } | ||
|
|
||
| static RuleEngineModelRuleResult createRuleEngineModelRuleWithLogATagResult() { | ||
| new RuleEngineModelRuleResult().tap { | ||
| it.function = LOG_A_TAG | ||
| it.args = RuleEngineModelRuleResultsArgs.createRuleEngineModelRuleResultsArgsOnlyATag() | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty | ||
| import org.prebid.server.functional.model.bidder.BidderName | ||
| import org.prebid.server.functional.model.response.auction.BidRejectionReason | ||
| import org.prebid.server.functional.util.PBSUtils | ||
|
|
||
| class RuleEngineModelRuleResultsArgs { | ||
|
|
||
| List<BidderName> bidders | ||
| @JsonProperty("seatnonbid") | ||
| BidRejectionReason seatNonBid | ||
| @JsonProperty("analyticsValue") | ||
| String analyticsValue | ||
| @JsonProperty("ifSyncedId") | ||
| Boolean ifSyncedId | ||
|
|
||
| static RuleEngineModelRuleResultsArgs createRuleEngineModelRuleResultsArgs(BidderName bidderName){ | ||
| new RuleEngineModelRuleResultsArgs().tap { | ||
| it.bidders = [bidderName] | ||
| it.analyticsValue = PBSUtils.randomString | ||
| } | ||
| } | ||
|
|
||
| static RuleEngineModelRuleResultsArgs createRuleEngineModelRuleResultsArgsOnlyATag(){ | ||
| new RuleEngineModelRuleResultsArgs().tap { | ||
| it.analyticsValue = PBSUtils.randomString | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import groovy.transform.ToString | ||
|
|
||
| import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_COUNTRY_IN | ||
| import static org.prebid.server.functional.model.pricefloors.Country.USA | ||
|
|
||
| @ToString(includeNames = true, ignoreNulls = true) | ||
| class RuleEngineModelSchema { | ||
|
|
||
| RuleEngineFunction function | ||
| RuleEngineFunctionArgs args | ||
osulzhenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static RuleEngineModelSchema createDeviceCountryInSchema(List<Object> argsCountries = [USA]) { | ||
| new RuleEngineModelSchema().tap { | ||
| it.function = DEVICE_COUNTRY_IN | ||
| it.args = new RuleEngineFunctionArgs(countries: argsCountries) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import static org.prebid.server.functional.model.config.Stage.PROCESSED_AUCTION_REQUEST | ||
| import static org.prebid.server.functional.util.PBSUtils.randomString | ||
|
|
||
| class RuleSet { | ||
|
|
||
| Boolean enabled | ||
| Stage stage | ||
| String name | ||
| String version | ||
| List<RulesEngineModelGroup> modelGroups | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. timestamp? |
||
|
|
||
| static RuleSet createRuleSets() { | ||
| new RuleSet().tap { | ||
| it.enabled = true | ||
| it.stage = PROCESSED_AUCTION_REQUEST | ||
| it.name = randomString | ||
| it.version = randomString | ||
| it.modelGroups = [RulesEngineModelGroup.createRulesModuleGroup()] | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package org.prebid.server.functional.model.config | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty | ||
| import org.prebid.server.functional.util.PBSUtils | ||
|
|
||
| import static org.prebid.server.functional.model.config.RuleEngineModelRule.createRuleEngineModelRule | ||
| import static org.prebid.server.functional.model.config.RuleEngineModelSchema.createDeviceCountryInSchema | ||
|
|
||
| class RulesEngineModelGroup { | ||
|
|
||
| Integer weight | ||
| String version | ||
| String analyticsKey | ||
| List<RuleEngineModelSchema> schema | ||
| @JsonProperty("default") | ||
| List<RuleEngineModelDefault> modelDefault | ||
| List<RuleEngineModelRule> rules | ||
|
|
||
| static RulesEngineModelGroup createRulesModuleGroup() { | ||
| new RulesEngineModelGroup().tap { | ||
| it.weight = PBSUtils.getRandomNumber(0, 100) | ||
|
||
| it.version = PBSUtils.randomString | ||
| it.analyticsKey = PBSUtils.randomString | ||
| it.schema = [createDeviceCountryInSchema()] | ||
| it.modelDefault = [] | ||
| it.rules = [createRuleEngineModelRule()] | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.prebid.server.functional.model.request.auction | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonValue | ||
|
|
||
| enum DeviceType { | ||
|
|
||
| MOBILE_TABLET_GENERAL(1), | ||
| PERSONAL_COMPUTER(2), | ||
| CONNECTED_TV(3), | ||
| PHONE(4), | ||
| TABLET(5), | ||
| CONNECTED_DEVICE(6), | ||
| SET_TOP_BOX(7), | ||
| OOH_DEVICE(8) | ||
|
|
||
| @JsonValue | ||
| final Integer value | ||
|
|
||
| DeviceType(Integer value) { | ||
| this.value = value | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about bidPrice?
Allows response rules to be set up to trigger on bid response prices. e.g. bidPrice["gt", 5.00, "EUR"] would return true if the bid response is greater than 5 EUR.
Left as an example of possible future functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BidPrice will be later, currently it's in low priority