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 SummaryModifier and TypeMethodDescriptionstatic StringjitterNearCompletionCheckValue(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 StringvalidateAndGetChangeGroupId(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Validates that theWorkflowRequestCompletion.getTransferTypeIdMap()contains a value forTransferType.SUMMARY_GROUP.static StringvalidateAndGetChangeSummaryId(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Validates that theWorkflowRequestCompletion.getTransferTypeIdMap()contains a value forTransferType.SUMMARY.static voidvalidateUpdate(boolean updated, String itemId) Validates that the item with the specified ID was successfully updated.
- 
Method Details- 
jitterNearCompletionCheckValueGiven 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 values
- range- The range of value positions to jitter
- Returns:
- The jittered value near the final list value
- Throws:
- IllegalArgumentException- if vals is empty
 
- 
validateUpdateValidates that the item with the specified ID was successfully updated. If not, then this will throw aQualifiedStateExceptionrecording the ID of the item that failed.- Parameters:
- updated- the response of updateVals method
- itemId- 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.
 
- 
validateAndGetChangeSummaryIdpublic 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- The- WorkflowRequestCompletionwith information about a- ChangeSummarythat is being promoted.
- Throws:
- IllegalStateException- Thrown if the- WorkflowRequestCompletion.getTransferTypeIdMap()does not contain the id of the- ChangeSummarythat is undergoing a promotion.
 
- 
validateAndGetChangeGroupIdpublic 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- The- WorkflowRequestCompletionwith information about a- ChangeSummaryGroupthat is being deployed.
- Throws:
- IllegalStateException- Thrown if the- WorkflowRequestCompletion.getTransferTypeIdMap()does not contain the id of the- ChangeSummaryGroupthat is undergoing a deployment.
 
 
-