Small Rollout create code improvements (#1754)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -34,8 +34,7 @@ public final class RolloutHelper {
|
||||
/**
|
||||
* Verifies that the required success condition and action are actually set.
|
||||
*
|
||||
* @param conditions
|
||||
* input conditions and actions
|
||||
* @param conditions input conditions and actions
|
||||
*/
|
||||
public static void verifyRolloutGroupConditions(final RolloutGroupConditions conditions) {
|
||||
if (conditions.getSuccessCondition() == null) {
|
||||
@@ -50,8 +49,7 @@ public final class RolloutHelper {
|
||||
* Verifies that the group has the required success condition and action and a
|
||||
* valid target percentage.
|
||||
*
|
||||
* @param group
|
||||
* the input group
|
||||
* @param group the input group
|
||||
* @return the verified group
|
||||
*/
|
||||
public static RolloutGroup verifyRolloutGroupHasConditions(final RolloutGroup group) {
|
||||
@@ -71,26 +69,20 @@ public final class RolloutHelper {
|
||||
/**
|
||||
* Verify if the supplied amount of groups is in range
|
||||
*
|
||||
* @param amountGroup
|
||||
* amount of groups
|
||||
* @param quotaManagement
|
||||
* to retrieve maximum number of groups allowed
|
||||
* @param amountGroup amount of groups
|
||||
* @param quotaManagement to retrieve maximum number of groups allowed
|
||||
*/
|
||||
public static void verifyRolloutGroupParameter(final int amountGroup, final QuotaManagement quotaManagement) {
|
||||
if (amountGroup <= 0) {
|
||||
throw new ValidationException("The amount of groups cannot be lower than or equal to zero for static rollouts");
|
||||
} else if (amountGroup > quotaManagement.getMaxRolloutGroupsPerRollout()) {
|
||||
public static void verifyRolloutGroupAmount(final int amountGroup, final QuotaManagement quotaManagement) {
|
||||
if (amountGroup > quotaManagement.getMaxRolloutGroupsPerRollout()) {
|
||||
throw new AssignmentQuotaExceededException(
|
||||
"The amount of groups cannot be greater than " + quotaManagement.getMaxRolloutGroupsPerRollout());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the supplied percentage is in range
|
||||
*
|
||||
* @param percentage
|
||||
* the percentage
|
||||
* @param percentage the percentage
|
||||
*/
|
||||
public static void verifyRolloutGroupTargetPercentage(final float percentage) {
|
||||
if (percentage <= 0) {
|
||||
@@ -104,8 +96,7 @@ public final class RolloutHelper {
|
||||
* Modifies the target filter query to only match targets that were created
|
||||
* after the Rollout.
|
||||
*
|
||||
* @param rollout
|
||||
* Rollout to derive the filter from
|
||||
* @param rollout Rollout to derive the filter from
|
||||
* @return resulting target filter query
|
||||
*/
|
||||
public static String getTargetFilterQuery(final Rollout rollout) {
|
||||
@@ -113,12 +104,9 @@ public final class RolloutHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetFilter
|
||||
* the target filter tp be extended
|
||||
* @param createdAt
|
||||
* timestamp
|
||||
* @return a target filter query that only matches targets that were created
|
||||
* after the provided timestamp.
|
||||
* @param targetFilter the target filter tp be extended
|
||||
* @param createdAt timestamp
|
||||
* @return a target filter query that only matches targets that were created after the provided timestamp.
|
||||
*/
|
||||
public static String getTargetFilterQuery(final String targetFilter, final Long createdAt) {
|
||||
if (createdAt != null) {
|
||||
@@ -130,10 +118,8 @@ public final class RolloutHelper {
|
||||
/**
|
||||
* Verifies that the Rollout is in the required status.
|
||||
*
|
||||
* @param rollout
|
||||
* the Rollout
|
||||
* @param status
|
||||
* the Status
|
||||
* @param rollout the Rollout
|
||||
* @param status the Status
|
||||
*/
|
||||
public static void verifyRolloutInStatus(final Rollout rollout, final Rollout.RolloutStatus status) {
|
||||
if (rollout.getStatus() != status) {
|
||||
@@ -145,10 +131,8 @@ public final class RolloutHelper {
|
||||
* Filters the groups of a Rollout to match a specific status and adds a group
|
||||
* to the result.
|
||||
*
|
||||
* @param status
|
||||
* the required status for the groups
|
||||
* @param group
|
||||
* the group to add
|
||||
* @param status the required status for the groups
|
||||
* @param group the group to add
|
||||
* @return list of groups
|
||||
*/
|
||||
public static List<Long> getGroupsByStatusIncludingGroup(final List<RolloutGroup> groups,
|
||||
@@ -161,10 +145,8 @@ public final class RolloutHelper {
|
||||
* Creates an RSQL expression that matches all targets in the provided groups.
|
||||
* Links all target filter queries with OR.
|
||||
*
|
||||
* @param groups
|
||||
* the rollout groups
|
||||
* @return RSQL string without base filter of the Rollout. Can be an empty
|
||||
* string.
|
||||
* @param groups the rollout groups
|
||||
* @return RSQL string without base filter of the Rollout. Can be an empty string.
|
||||
*/
|
||||
public static String getAllGroupsTargetFilter(final List<RolloutGroup> groups) {
|
||||
if (groups.stream().anyMatch(group -> StringUtils.isEmpty(group.getTargetFilterQuery()))) {
|
||||
@@ -179,14 +161,10 @@ public final class RolloutHelper {
|
||||
* Creates an RSQL Filter that matches all targets that are in the provided
|
||||
* group and in the provided groups.
|
||||
*
|
||||
* @param baseFilter
|
||||
* the base filter from the rollout
|
||||
* @param groups
|
||||
* the rollout groups
|
||||
* @param group
|
||||
* the target group
|
||||
* @return RSQL string without base filter of the Rollout. Can be an empty
|
||||
* string.
|
||||
* @param baseFilter the base filter from the rollout
|
||||
* @param groups the rollout groups
|
||||
* @param group the target group
|
||||
* @return RSQL string without base filter of the Rollout. Can be an empty string.
|
||||
*/
|
||||
public static String getOverlappingWithGroupsTargetFilter(final String baseFilter, final List<RolloutGroup> groups,
|
||||
final RolloutGroup group) {
|
||||
@@ -220,10 +198,8 @@ public final class RolloutHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param baseFilter
|
||||
* the base filter from the rollout
|
||||
* @param group
|
||||
* group for which the filter string should be created
|
||||
* @param baseFilter the base filter from the rollout
|
||||
* @param group group for which the filter string should be created
|
||||
* @return the final target filter query for a rollout group
|
||||
*/
|
||||
public static String getGroupTargetFilter(final String baseFilter, final RolloutGroup group) {
|
||||
@@ -236,8 +212,7 @@ public final class RolloutHelper {
|
||||
/**
|
||||
* Verifies that no targets are left
|
||||
*
|
||||
* @param targetCount
|
||||
* the count of left targets
|
||||
* @param targetCount the count of left targets
|
||||
*/
|
||||
public static void verifyRemainingTargets(final long targetCount) {
|
||||
if (targetCount > 0) {
|
||||
|
||||
Reference in New Issue
Block a user