Class AdminTestHelper
java.lang.Object
org.broadleafcommerce.test.helper.AdminTestHelper
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected org.broadleafcommerce.common.sandbox.service.SandBoxServiceprotected org.broadleafcommerce.common.site.service.SiteServiceprotected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidendView()Complete the scope of the EntityManager-In-View operation.org.broadleafcommerce.common.sandbox.domain.SandBoxfindSandBox(Long siteId, String sandBoxName) Find the user sandbox based on the provided site and sandbox name.voidSimple pausevoidvoidvoidUseful to start an EntityManager-In-View.voidtryWithPause(Integer retryCount, Long wait, Runnable runnable) Try a test assertion repeatedly encapsulated in a Runnable.
-
Field Details
-
DEFAULT_SB
- See Also:
-
transUtil
@Autowired @Qualifier("blStreamingTransactionCapableUtil") protected org.broadleafcommerce.common.util.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
Simple pause- Parameters:
wait-
-
tryWithPause
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()seestartView(Long, String). Allows avoiding providing a site and sandbox. -
startView
seestartView(Long, String). Allows avoiding providing a sandbox.- Parameters:
siteId-
-
startView
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, theendView()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. SeestartView(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:
-