Skip to content

Commit

Permalink
#20840 refactoring the unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Jul 19, 2022
1 parent 87975f0 commit cafe624
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.junit.Assert.fail;

import com.dotcms.IntegrationTestBase;
import com.dotcms.business.WrapInTransaction;
import com.dotcms.content.elasticsearch.business.event.ContentletCheckinEvent;
import com.dotcms.contenttype.business.ContentTypeAPIImpl;
import com.dotcms.contenttype.business.FieldAPI;
Expand Down Expand Up @@ -1459,18 +1460,27 @@ public void findAvailableActions() throws Exception {
final Contentlet testContentleti = testContentlet;
runNoLicense(()-> {

CacheLocator.getWorkFlowCache().clearCache();
List<WorkflowAction> foundActions_ = APILocator.getWorkflowAPI()
.findAvailableActions(testContentleti, joeContributor);
Assert.assertFalse(foundActions_.isEmpty());
Assert.assertEquals(WorkflowAPI.SYSTEM_WORKFLOW_ID, foundActions_.get(0).getSchemeId());
final List<WorkflowStep> steps = getSteps(testContentleti);

Assert.assertFalse(steps.isEmpty());
Assert.assertEquals(WorkflowAPI.SYSTEM_WORKFLOW_ID, steps.get(0).getSchemeId());
});
} finally {
contentletAPI.destroy(testContentlet, user, false);
}

}

@WrapInTransaction
private List<WorkflowStep> getSteps (final Contentlet testContentleti) throws DotDataException {

final WorkFlowFactory workFlowFactory = FactoryLocator.getWorkFlowFactory();
final List<WorkflowScheme> schemes = Arrays.asList(workFlowFactory.findSystemWorkflow()) ;
CacheLocator.getWorkFlowCache().clearCache();
List<WorkflowStep> steps = FactoryLocator.getWorkFlowFactory().findStepsByContentlet(testContentleti, schemes);
return steps;
}

/**
* Test the find findAvailableActions methods
*/
Expand Down

0 comments on commit cafe624

Please sign in to comment.