-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Price Granularity: Defaults Fix (#3511)
- Loading branch information
1 parent
af321ad
commit 98e8065
Showing
13 changed files
with
406 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/test/groovy/org/prebid/server/functional/model/config/PriceGranularityType.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.prebid.server.functional.model.config | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue | ||
import org.prebid.server.functional.model.request.auction.Range | ||
|
||
enum PriceGranularityType { | ||
|
||
LOW(2, [Range.getDefault(5, 0.5)]), | ||
MEDIUM(2, [Range.getDefault(20, 0.1)]), | ||
MED(2, [Range.getDefault(20, 0.1)]), | ||
HIGH(2, [Range.getDefault(20, 0.01)]), | ||
AUTO(2, [Range.getDefault(5, 0.05), Range.getDefault(10, 0.1), Range.getDefault(20, 0.5)]), | ||
DENSE(2, [Range.getDefault(3, 0.01), Range.getDefault(8, 0.05), Range.getDefault(20, 0.5)]), | ||
UNKNOWN(null, []) | ||
|
||
final Integer precision | ||
final List<Range> ranges | ||
|
||
PriceGranularityType(Integer precision, List<Range> ranges) { | ||
this.precision = precision | ||
this.ranges = ranges | ||
} | ||
|
||
@JsonValue | ||
String toLowerCase() { | ||
return name().toLowerCase() | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/groovy/org/prebid/server/functional/model/request/auction/PriceGranularity.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
package org.prebid.server.functional.model.request.auction | ||
|
||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
import org.prebid.server.functional.model.config.PriceGranularityType | ||
|
||
@ToString(includeNames = true, ignoreNulls = true) | ||
@EqualsAndHashCode | ||
class PriceGranularity { | ||
|
||
Integer precision | ||
List<Range> ranges | ||
|
||
static PriceGranularity getDefault(PriceGranularityType granularity) { | ||
new PriceGranularity(precision: granularity.precision, ranges: granularity.ranges) | ||
} | ||
|
||
static PriceGranularity getDefault() { | ||
getDefault(PriceGranularityType.MED) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/test/groovy/org/prebid/server/functional/model/request/auction/Range.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
package org.prebid.server.functional.model.request.auction | ||
|
||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
|
||
@ToString(includeNames = true, ignoreNulls = true) | ||
@EqualsAndHashCode | ||
class Range { | ||
|
||
BigDecimal max | ||
BigDecimal increment | ||
|
||
static Range getDefault(Integer max, BigDecimal increment) { | ||
new Range(max: max, increment: increment) | ||
} | ||
} |
Oops, something went wrong.