Source:
<code>public void testDeleteStoppedWorkflowForcefully() throws Exception { String workflowName = TestHelper.getTestMethodName(); <START> Workflow.Builder builder = createCustomWorkflow(workflowName, "10000", "0"); <END> _driver.start(builder.build()); boolean isWorkflowCreated = TestHelper.verify(() -> { WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName); return (wCtx1 != null); }, 60 * 1000); Assert.assertTrue(isWorkflowCreated); _driver.stop(workflowName); boolean isWorkflowStopped = TestHelper.verify(() -> { WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName); return (wCtx1.getWorkflowState() == TaskState.STOPPED); }, 60 * 1000); Assert.assertTrue(isWorkflowStopped); Assert.assertNotNull(_driver.getWorkflowConfig(workflowName)); Assert.assertNotNull(_driver.getWorkflowContext(workflowName)); Assert.assertNotNull(_admin.getResourceIdealState(CLUSTER_NAME, workflowName)); _controller.syncStop(); _driver.delete(workflowName, true); boolean isWorkflowDeleted = TestHelper.verify(() -> { WorkflowConfig wfcfg = _driver.getWorkflowConfig(workflowName); WorkflowContext wfctx = _driver.getWorkflowContext(workflowName); IdealState is = _admin.getResourceIdealState(CLUSTER_NAME, workflowName); return (wfcfg == null && wfctx == null && is == null); }, 60 * 1000); Assert.assertTrue(isWorkflowDeleted); String controllerName = CONTROLLER_PREFIX + "_3"; _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName); _controller.syncStart(); }</code><technical_language>Magic constant explanation</technical_language>

Target:
public void testDeleteStoppedWorkflowForcefully() throws Exception { String controllerName = CONTROLLER_PREFIX + "_0"; _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName); _controller.syncStart(); String workflowName = TestHelper.getTestMethodName(); Workflow.Builder builder = createCustomWorkflow(workflowName, MEDIUM_EXECUTION_TIME, "0"); _driver.start(builder.build()); _driver.pollForWorkflowState(workflowName, TaskState.IN_PROGRESS); _driver.stop(workflowName); _driver.pollForWorkflowState(workflowName, TaskState.STOPPED); boolean areJobsStopped = TestHelper.verify(() -> { WorkflowContext wCtx1 = _driver.getWorkflowContext(workflowName); TaskState job0 = wCtx1.getJobState(TaskUtil.getNamespacedJobName(workflowName, "JOB0")); TaskState job1 = wCtx1.getJobState(TaskUtil.getNamespacedJobName(workflowName, "JOB1")); TaskState job2 = wCtx1.getJobState(TaskUtil.getNamespacedJobName(workflowName, "JOB2")); return ((job0 == null || job0 == TaskState.STOPPED) && (job1 == null || job1 == TaskState.STOPPED) && (job2 == null || job2 == TaskState.STOPPED)); }, 60 * 1000); Assert.assertTrue(areJobsStopped); Assert.assertNotNull(_driver.getWorkflowConfig(workflowName)); Assert.assertNotNull(_driver.getWorkflowContext(workflowName)); Assert.assertNotNull(_admin.getResourceIdealState(CLUSTER_NAME, workflowName)); _controller.syncStop(); _driver.delete(workflowName, true); boolean isWorkflowDeleted = TestHelper.verify(() -> { WorkflowConfig wfcfg = _driver.getWorkflowConfig(workflowName); WorkflowContext wfctx = _driver.getWorkflowContext(workflowName); IdealState is = _admin.getResourceIdealState(CLUSTER_NAME, workflowName); return (wfcfg == null && wfctx == null && is == null); }, 60 * 1000); Assert.assertTrue(isWorkflowDeleted); }