/// /// <summary> /// +-----------------+ /// | Case1 \ /// +-------------------+-----------------+ /// | | /// | +------------------------+ | /// | / X \ | /// | + +-------+ +-------+ + | /// | | | A | | B | | | /// | + +-------+ +-------+ + | /// | \ / | /// | +------------------------+ | /// | | /// +-------------------------------------+ /// /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCloseStage() public virtual void testCloseStage() { CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector(); // given // a case definition CmmnCaseDefinition caseDefinition = (new CaseDefinitionBuilder("Case1")).listener("close", stateTransitionCollector).createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).endActivity().createActivity("B").behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition(); // an active case instance CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance(); caseInstance.create(); CmmnActivityExecution stageX = caseInstance.findCaseExecution("X"); try { // when stageX.close(); fail("It should not be possible to close a stage."); } catch (CaseIllegalStateTransitionException) { } // then assertTrue(stateTransitionCollector.stateTransitions.Count == 0); assertTrue(caseInstance.Active); assertNotNull(caseInstance.findCaseExecution("X")); }
/// /// <summary> /// +-----------------+ /// | Case1 \ /// +-------------------+---+ /// | | /// | +-------+ | /// | | A | | /// | +-------+ | /// | | /// +-----------------------+ /// /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCloseSuspendedCaseInstance() public virtual void testCloseSuspendedCaseInstance() { CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector(); // given // a case definition CmmnCaseDefinition caseDefinition = (new CaseDefinitionBuilder("Case1")).listener("close", stateTransitionCollector).createActivity("A").behavior(new TaskWaitState()).endActivity().buildCaseDefinition(); // an active case instance CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance(); caseInstance.create(); caseInstance.suspend(); assertTrue(caseInstance.Suspended); // when // close case caseInstance.close(); // then IList <string> expectedStateTransitions = new List <string>(); // expected state transition: // suspended --close(Case1)--> closed expectedStateTransitions.Add("suspended --close(Case1)--> closed"); assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions); assertTrue(caseInstance.Closed); assertNull(caseInstance.findCaseExecution("A")); }
/// /// <summary> /// +-----------------+ /// | Case1 \ /// +-------------------+---+ /// | | /// | +-------+ | /// | | A | | /// | +-------+ | /// | | /// +-----------------------+ /// /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCloseCompletedCaseInstance() public virtual void testCloseCompletedCaseInstance() { CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector(); // given // a case definition CmmnCaseDefinition caseDefinition = (new CaseDefinitionBuilder("Case1")).listener("close", stateTransitionCollector).createActivity("A").behavior(new TaskWaitState()).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).endActivity().buildCaseDefinition(); // an active case instance CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance(); caseInstance.create(); // task A as a child of the case instance CmmnActivityExecution taskA = caseInstance.findCaseExecution("A"); // disable task A -> completes case instance taskA.disable(); assertTrue(caseInstance.Completed); // when // close case caseInstance.close(); // then IList <string> expectedStateTransitions = new List <string>(); // expected state transition: // completed --close(Case1)--> closed expectedStateTransitions.Add("completed --close(Case1)--> closed"); assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions); assertTrue(caseInstance.Closed); }