-
Notifications
You must be signed in to change notification settings - Fork 181
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
BeachfrontBidder: fix beachfront bid floor #1334
Conversation
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.
Pls add more unit tests
extImpBeachfrontBidfloor = extImpBeachfrontBidfloor == null ? ZERO : extImpBeachfrontBidfloor; | ||
impBidfloor = impBidfloor == null ? ZERO : impBidfloor; |
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.
Let's create separate variables, and not use method arguments assignments
private static BigDecimal getBidFloor(BigDecimal extImpBeachfrontBidfloor, BigDecimal impBidfloor) { | ||
extImpBeachfrontBidfloor = extImpBeachfrontBidfloor == null ? ZERO : extImpBeachfrontBidfloor; | ||
impBidfloor = impBidfloor == null ? ZERO : impBidfloor; | ||
final BigDecimal resultFloor; | ||
|
||
if (impBidfloor.compareTo(ZERO) > 0) { | ||
resultFloor = impBidfloor; | ||
} else if (extImpBeachfrontBidfloor.compareTo(ZERO) > 0) { | ||
resultFloor = extImpBeachfrontBidfloor; | ||
} else { | ||
resultFloor = MIN_BID_FLOOR; | ||
} | ||
|
||
return resultFloor.compareTo(MIN_BID_FLOOR) < 0 ? MIN_BID_FLOOR : resultFloor; |
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.
Can we refactor to something like this
private static BigDecimal getBidFloor(BigDecimal extImpBidfloor, BigDecimal impBidfloor) {
final BigDecimal impNonNullBidfloor = zeroIfNull(impBidfloor);
final BigDecimal extImpNonNullBidfloor = zeroIfNull(extImpBidfloor);
if (impNonNullBidfloor.compareTo(MIN_BID_FLOOR) > 0) {
return impNonNullBidfloor;
} else if (extImpNonNullBidfloor.compareTo(MIN_BID_FLOOR) > 0) {
return extImpNonNullBidfloor;
} else {
return ZERO;
}
}
public static BigDecimal zeroIfNull(BigDecimal bigDecimal) {
return bigDecimal == null ? BigDecimal.ZERO : bigDecimal;
}
final BigDecimal resultFloor; | ||
|
||
if (impBidfloor.compareTo(ZERO) > 0) { | ||
resultFloor = impBidfloor; |
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.
Let's add test for this case
@@ -64,6 +64,7 @@ | |||
private static final BigDecimal MIN_BID_FLOOR = BigDecimal.valueOf(0.01); | |||
private static final int DEFAULT_VIDEO_WIDTH = 300; | |||
private static final int DEFAULT_VIDEO_HEIGHT = 250; | |||
private static final BigDecimal ZERO = BigDecimal.ZERO; |
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.
Do we really need it?
No description provided.