Exemple #1
0
        ///
        /// <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 testCloseActiveCaseInstance()
        public virtual void testCloseActiveCaseInstance()
        {
            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();

            assertTrue(caseInstance.Active);

            try
            {
                // when
                caseInstance.close();
            }
            catch (CaseIllegalStateTransitionException)
            {
            }

            // then
            assertTrue(stateTransitionCollector.stateTransitions.Count == 0);

            assertTrue(caseInstance.Active);

            assertNotNull(caseInstance.findCaseExecution("A"));
        }
Exemple #2
0
        ///
        /// <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"));
        }
Exemple #3
0
        ///
        /// <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);
        }