Class StateValidationUtils
java.lang.Object
com.broadleafcommerce.sandbox.messaging.completion.StateValidationUtils
Utility class to help validate states of sandbox entities during completion and error flows.
- Author:
- Chad Harchar (charchar)
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
jitterNearCompletionCheckValue
(List<String> vals, int range) Given a list of String values, find a candidate value near the end of the list that is randomly selected within a range of positions defined by the range parameter.static String
validateAndGetChangeGroupId
(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Validates that theWorkflowRequestCompletion.getTransferTypeIdMap()
contains a value forTransferType.SUMMARY_GROUP
.static String
validateAndGetChangeSummaryId
(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Validates that theWorkflowRequestCompletion.getTransferTypeIdMap()
contains a value forTransferType.SUMMARY
.static void
validateUpdate
(boolean updated, String itemId) Validates that the item with the specified ID was successfully updated.
-
Method Details
-
jitterNearCompletionCheckValue
Given a list of String values, find a candidate value near the end of the list that is randomly selected within a range of positions defined by the range parameter. This algorithm can be helpful when checking "near" completion of a list of items based on the final value, but the processing of items is async and ordering is not guaranteed. Jittering the final check value can give more room to avoid ponderous repetition of false positives.- Parameters:
vals
- The complete list of valuesrange
- The range of value positions to jitter- Returns:
- The jittered value near the final list value
- Throws:
IllegalArgumentException
- if vals is empty
-
validateUpdate
Validates that the item with the specified ID was successfully updated. If not, then this will throw aQualifiedStateException
recording the ID of the item that failed.- Parameters:
updated
- the response of updateVals methoditemId
- the id of the item to have been updated- Throws:
QualifiedStateException
- Thrown if an item was not successfully updated during the completion of its rejection.
-
validateAndGetChangeSummaryId
public static String validateAndGetChangeSummaryId(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Validates that theWorkflowRequestCompletion.getTransferTypeIdMap()
contains a value forTransferType.SUMMARY
. If not, then throws anIllegalStateException
.- Parameters:
completion
- TheWorkflowRequestCompletion
with information about aChangeSummary
that is being promoted.- Throws:
IllegalStateException
- Thrown if theWorkflowRequestCompletion.getTransferTypeIdMap()
does not contain the id of theChangeSummary
that is undergoing a promotion.
-
validateAndGetChangeGroupId
public static String validateAndGetChangeGroupId(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Validates that theWorkflowRequestCompletion.getTransferTypeIdMap()
contains a value forTransferType.SUMMARY_GROUP
. If not, then throws anIllegalStateException
.- Parameters:
completion
- TheWorkflowRequestCompletion
with information about aChangeSummaryGroup
that is being deployed.- Throws:
IllegalStateException
- Thrown if theWorkflowRequestCompletion.getTransferTypeIdMap()
does not contain the id of theChangeSummaryGroup
that is undergoing a deployment.
-