Class AdminTestHelper

java.lang.Object
org.broadleafcommerce.test.helper.AdminTestHelper

public class AdminTestHelper extends Object
Helper class for working with admin related integration tests. The main focus is for enabling direct persistence layer interaction with a running admin application. This could be used to validate data state during or after admin operations that are being performed as part of a MockMVC test.

In enterprise context, refer to EnterpriseAdminTestHelper for additional admin related helper methods for performing promotions and deployments in a MockMVC test.
Author:
Jeff Fischer
  • Field Details

    • DEFAULT_SB

      public static final String DEFAULT_SB
      See Also:
    • transUtil

      @Autowired @Qualifier("blStreamingTransactionCapableUtil") protected StreamingTransactionCapableUtil transUtil
    • siteService

      @Autowired protected org.broadleafcommerce.common.site.service.SiteService siteService
    • sandBoxService

      @Autowired protected org.broadleafcommerce.common.sandbox.service.SandBoxService sandBoxService
  • Constructor Details

    • AdminTestHelper

      public AdminTestHelper()
  • Method Details

    • pause

      public void pause(Long wait)
      Simple pause
      Parameters:
      wait -
    • tryWithPause

      public void tryWithPause(Integer retryCount, Long wait, Runnable runnable)
      Try a test assertion repeatedly encapsulated in a Runnable. This is useful for checking state of an async operation. In enterprise, this is useful for checking on the finish state of a admin promotion or deployment.
      Parameters:
      retryCount -
      wait -
      runnable -
    • startView

      public void startView()
      see startView(Long, String). Allows avoiding providing a site and sandbox.
    • startView

      public void startView(Long siteId)
      see startView(Long, String). Allows avoiding providing a sandbox.
      Parameters:
      siteId -
    • startView

      public void startView(Long siteId, String sandBoxName)
      Useful to start an EntityManager-In-View. This allows test operations that want to read directly from the database to work without lazy init exceptions, etc... This is not needed for MockMVC#perform operations, since those requests will include the OpenEntityManagerInView filter as part of their flow. At the completion of the test operation, the endView() method should be called to end the scope of the view.

      This view scope is also aware of nested views against the same persistence unit, so you don't need to worry about coding carefully to avoid nesting calls to startView.
      Parameters:
      siteId -
      sandBoxName -
    • endView

      public void endView()
      Complete the scope of the EntityManager-In-View operation. See startView(Long, String).
    • findSandBox

      public org.broadleafcommerce.common.sandbox.domain.SandBox findSandBox(Long siteId, String sandBoxName)
      Find the user sandbox based on the provided site and sandbox name.
      Parameters:
      siteId -
      sandBoxName -
      Returns: