Class StateValidationUtils

java.lang.Object
com.broadleafcommerce.sandbox.messaging.completion.StateValidationUtils

public final class StateValidationUtils extends Object
Utility class to help validate states of sandbox entities during completion and error flows.
Author:
Chad Harchar (charchar)
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    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 the WorkflowRequestCompletion.getTransferTypeIdMap() contains a value for TransferType.SUMMARY_GROUP.
    static String
    validateAndGetChangeSummaryId(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion)
    Validates that the WorkflowRequestCompletion.getTransferTypeIdMap() contains a value for TransferType.SUMMARY.
    static void
    validateUpdate(boolean updated, String itemId)
    Validates that the item with the specified ID was successfully updated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • jitterNearCompletionCheckValue

      @NonNull public static String jitterNearCompletionCheckValue(@NonNull 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. 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
    • validateUpdate

      public static void validateUpdate(boolean updated, String itemId)
      Validates that the item with the specified ID was successfully updated. If not, then this will throw a QualifiedStateException recording 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.
    • validateAndGetChangeSummaryId

      public static String validateAndGetChangeSummaryId(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion)
      Validates that the WorkflowRequestCompletion.getTransferTypeIdMap() contains a value for TransferType.SUMMARY. If not, then throws an IllegalStateException.
      Parameters:
      completion - The WorkflowRequestCompletion with information about a ChangeSummary that is being promoted.
      Throws:
      IllegalStateException - Thrown if the WorkflowRequestCompletion.getTransferTypeIdMap() does not contain the id of the ChangeSummary that is undergoing a promotion.
    • validateAndGetChangeGroupId

      public static String validateAndGetChangeGroupId(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion)
      Validates that the WorkflowRequestCompletion.getTransferTypeIdMap() contains a value for TransferType.SUMMARY_GROUP. If not, then throws an IllegalStateException.
      Parameters:
      completion - The WorkflowRequestCompletion with information about a ChangeSummaryGroup that is being deployed.
      Throws:
      IllegalStateException - Thrown if the WorkflowRequestCompletion.getTransferTypeIdMap() does not contain the id of the ChangeSummaryGroup that is undergoing a deployment.