String schemeName = "issue5197-"+UtilMethods.dateToHTMLDate(new Date(), "MM-dd-yyyy-HHmmss");
String baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfSchemeAjax?cmd=save&schemeId=&schemeName="+schemeName;
URL testUrl = new URL(baseURL);
IOUtils.toString(testUrl.openStream(),"UTF-8");
WorkflowAPI wapi = APILocator.getWorkflowAPI();
WorkflowScheme ws = wapi.findSchemeByName(schemeName);
Assert.assertTrue(UtilMethods.isSet(ws));
/*
* Create scheme step1
*/
baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfStepAjax?cmd=add&stepName=Edit&schemeId=" + ws.getId();
testUrl = new URL(baseURL);
IOUtils.toString(testUrl.openStream(),"UTF-8");
List<WorkflowStep> steps = wapi.findSteps(ws);
Assert.assertTrue(steps.size()==1);
WorkflowStep step1 = steps.get(0);
/*
* Create scheme step2
*/
baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfStepAjax?cmd=add&stepName=Publish&schemeId=" + ws.getId();
testUrl = new URL(baseURL);
IOUtils.toString(testUrl.openStream(),"UTF-8");
steps = wapi.findSteps(ws);
Assert.assertTrue(steps.size()==2);
WorkflowStep step2 = steps.get(1);
/*
* Add action to scheme step1
*/
baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfActionAjax?cmd=save&stepId="+step1.getId()+"&schemeId="+UtilMethods.webifyString(ws.getId())+"&actionName=Edit&whoCanUse=";
baseURL+=role.getId()+",&actionIconSelect=workflowIcon&actionAssignable=true&actionCommentable=true&actionRequiresCheckout=false&actionRoleHierarchyForAssign=false";
baseURL+="&actionAssignToSelect="+role.getId()+"&actionNextStep="+step2.getId()+"&actionCondition=";
testUrl = new URL(baseURL);
IOUtils.toString(testUrl.openStream(),"UTF-8");
List<WorkflowAction> actions1= wapi.findActions(step1, systemUser);
Assert.assertTrue(actions1.size()==1);
WorkflowAction action1 = actions1.get(0);
/*
* Add action to scheme step2
*/
baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfActionAjax?cmd=save&stepId="+step2.getId()+"&schemeId="+UtilMethods.webifyString(ws.getId())+"&actionName=Publish&whoCanUse=";
baseURL+=role.getId()+",&actionIconSelect=workflowIcon&actionAssignable=true&actionCommentable=true&actionRequiresCheckout=false&actionRoleHierarchyForAssign=false";
baseURL+="&actionAssignToSelect="+role.getId()+"&actionNextStep="+step2.getId()+"&actionCondition=";
testUrl = new URL(baseURL);
IOUtils.toString(testUrl.openStream(),"UTF-8");