Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.prebid.server.functional.model.config

import com.fasterxml.jackson.annotation.JsonValue
import org.prebid.server.functional.model.privacy.gpp.GppDataActivity

enum DataActivity {

Expand All @@ -9,7 +10,23 @@ enum DataActivity {
NOTICE_NOT_PROVIDED(2),
NO_CONSENT(1),
CONSENT(2),
INVALID(-1),
INVALID(-1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reorder your number without duplication.


static DataActivity fromGppDataActivity(GppDataActivity gppActivity) {
if (gppActivity == null) {
return INVALID;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need semicolon here.

}
switch (gppActivity) {
case GppDataActivity.NOT_APPLICABLE:
return NOT_APPLICABLE
case GppDataActivity.NO_CONSENT:
return NO_CONSENT
case GppDataActivity.CONSENT:
return CONSENT
default:
return INVALID
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, looks weird. Please consider removing the current enum.


@JsonValue
final int dataActivityBits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import groovy.transform.ToString
import org.prebid.server.functional.model.privacy.gpp.GppDataActivity

@ToString(includeNames = true, ignoreNulls = true)
@JsonDeserialize(using = EqualityValueRuleDeserialize.class)
Expand All @@ -16,6 +17,10 @@ class EqualityValueRule extends ValueRestrictedRule {
super(privacySection, value)
}

EqualityValueRule(UsNationalPrivacySection privacySection, GppDataActivity value) {
super(privacySection, DataActivity.fromGppDataActivity(value))
}

static class EqualityValueRuleDeserialize extends JsonDeserializer<EqualityValueRule> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import com.fasterxml.jackson.annotation.JsonProperty
import groovy.transform.ToString
import org.prebid.server.functional.model.request.GppSectionId

import static org.prebid.server.functional.model.config.GppModuleConfig.ConfigCase.CAMEL_CASE
import static org.prebid.server.functional.model.config.GppModuleConfig.ConfigCase.KEBAB_CASE

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

Expand Down Expand Up @@ -31,31 +34,25 @@ class GppModuleConfig {

static GppModuleConfig getDefaultModuleConfig(ActivityConfig activityConfig = ActivityConfig.configWithDefaultRestrictRules,
List<GppSectionId> sids = [GppSectionId.US_NAT_V1],
Boolean normalizeFlags = true) {
new GppModuleConfig().tap {
it.activityConfig = [activityConfig]
it.sids = sids
it.normalizeFlags = normalizeFlags
}
}
Boolean normalizeFlags = true,
ConfigCase configCase = CAMEL_CASE) {

static GppModuleConfig getDefaultModuleConfigSnakeCase(ActivityConfig activityConfig = ActivityConfig.configWithDefaultRestrictRules,
List<GppSectionId> sids = [GppSectionId.US_NAT_V1],
Boolean normalizeFlags = true) {
new GppModuleConfig().tap {
it.activityConfigSnakeCase = [activityConfig]
it.sids = sids
it.normalizeFlagsSnakeCase = normalizeFlags
if (configCase == CAMEL_CASE) {
it.activityConfig = [activityConfig]
it.normalizeFlags = normalizeFlags
} else if (configCase = KEBAB_CASE) {
it.activityConfigKebabCase = [activityConfig]
it.normalizeFlagsKebabCase = normalizeFlags
} else {
it.activityConfigSnakeCase = [activityConfig]
it.normalizeFlagsSnakeCase = normalizeFlags
}
}
}

static GppModuleConfig getDefaultModuleConfigKebabCase(ActivityConfig activityConfig = ActivityConfig.configWithDefaultRestrictRules,
List<GppSectionId> sids = [GppSectionId.US_NAT_V1],
Boolean normalizeFlags = true) {
new GppModuleConfig().tap {
it.activityConfigKebabCase = [activityConfig]
it.sids = sids
it.normalizeFlagsKebabCase = normalizeFlags
}
enum ConfigCase {
CAMEL_CASE, KEBAB_CASE, SNAKE_CASE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to move into the core model. In future, we can also reuse this functionality.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import org.prebid.server.functional.util.PBSUtils

class UsCaliforniaV1ChildSensitiveData {

GppDataActivity childUnder13
GppDataActivity childFrom13to16
GppDataActivity toSellUnder16
GppDataActivity toShareUnder16

static UsCaliforniaV1ChildSensitiveData getDefault(GppDataActivity childUnder13 = GppDataActivity.NOT_APPLICABLE,
GppDataActivity childFrom13to16 = GppDataActivity.NOT_APPLICABLE) {

new UsCaliforniaV1ChildSensitiveData().tap {
it.childUnder13 = childUnder13
it.childFrom13to16 = childFrom13to16
it.toSellUnder16 = childUnder13
it.toShareUnder16 = childFrom13to16
}
}

static UsCaliforniaV1ChildSensitiveData getRandom(List<GppDataActivity> excludedActivities) {
new UsCaliforniaV1ChildSensitiveData().tap {
it.childUnder13 = PBSUtils.getRandomEnum(GppDataActivity, excludedActivities)
it.childFrom13to16 = PBSUtils.getRandomEnum(GppDataActivity, excludedActivities)
it.toSellUnder16 = PBSUtils.getRandomEnum(GppDataActivity, excludedActivities)
it.toShareUnder16 = PBSUtils.getRandomEnum(GppDataActivity, excludedActivities)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused method


List<Integer> getContentList() {
[childFrom13to16, childUnder13]*.value.collect { it ?: 0 }
[toShareUnder16, toSellUnder16]*.value.collect { it ?: 0 }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class UsConnecticutV1ChildSensitiveData {

GppDataActivity childUnder13
GppDataActivity childFrom13to16
GppDataActivity childFrom16to18
GppDataActivity childFrom13to16Targeted

static UsConnecticutV1ChildSensitiveData getDefault(GppDataActivity childUnder13 = GppDataActivity.NOT_APPLICABLE,
GppDataActivity childFrom13to16 = GppDataActivity.NOT_APPLICABLE,
Expand All @@ -15,19 +15,19 @@ class UsConnecticutV1ChildSensitiveData {
new UsConnecticutV1ChildSensitiveData().tap {
it.childUnder13 = childUnder13
it.childFrom13to16 = childFrom13to16
it.childFrom16to18 = childFrom16to18
it.childFrom13to16Targeted = childFrom16to18
}
}

static UsConnecticutV1ChildSensitiveData getRandom(List<GppDataActivity> excludedActivities = []) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here!

new UsConnecticutV1ChildSensitiveData().tap {
it.childUnder13 = PBSUtils.getRandomEnum(GppDataActivity, excludedActivities)
it.childFrom13to16 = PBSUtils.getRandomEnum(GppDataActivity, excludedActivities)
it.childFrom16to18 = PBSUtils.getRandomEnum(GppDataActivity, excludedActivities)
it.childFrom13to16Targeted = PBSUtils.getRandomEnum(GppDataActivity, excludedActivities)
}
}

List<Integer> getContentList() {
[childFrom13to16, childUnder13, childFrom16to18]*.value.collect { it ?: 0 }
[childUnder13, childFrom13to16, childFrom13to16Targeted]*.value.collect { it ?: 0 }
}
}
Loading
Loading