//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testCreateEventListenerByClass() public virtual void testCreateEventListenerByClass() { caseService.withCaseDefinitionByKey("case").create(); CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult(); assertNotNull(taskExecution); // when i create a variable on the human task caseService.withCaseExecution(taskExecution.Id).setVariableLocal("aTaskVariable", "aTaskValue").execute(); // then the listener is invoked assertEquals(1, LogVariableListener.Invocations.Count); DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.CREATE).name("aTaskVariable").value("aTaskValue").matches(LogVariableListener.Invocations[0]); LogVariableListener.reset(); // when i update the variable on the human task caseService.withCaseExecution(taskExecution.Id).setVariable("aTaskVariable", "aNewTaskValue").execute(); // then the listener is not invoked assertTrue(LogVariableListener.Invocations.Count == 0); // when i remove the variable from the human task caseService.withCaseExecution(taskExecution.Id).removeVariable("aTaskVariable").execute(); // then the listener is not invoked assertTrue(LogVariableListener.Invocations.Count == 0); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testListenerInvocationFinishesBeforeSubsequentInvocations() public virtual void testListenerInvocationFinishesBeforeSubsequentInvocations() { caseService.withCaseDefinitionByKey("case").create(); CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult(); assertNotNull(taskExecution); // when i set a variable and the listener itself sets another variable caseService.withCaseExecution(taskExecution.Id).setVariableLocal("variable", "value1").execute(); // then all listeners for the first variable update are invoked first // and then the listeners for the second update are invoked IList <DelegateCaseVariableInstance> invocations = LogAndUpdateVariableListener.Invocations; assertEquals(6, invocations.Count); // the first invocations should regard the first value DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.CREATE).name("variable").value("value1").matches(LogAndUpdateVariableListener.Invocations[0]); DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.CREATE).name("variable").value("value1").matches(LogAndUpdateVariableListener.Invocations[1]); // the second invocations should regard the updated value // there are four invocations since both listeners have set "value2" and both were again executed, i.e. 2*2 = 4 for (int i = 2; i < 6; i++) { DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.UPDATE).name("variable").value("value2").matches(LogAndUpdateVariableListener.Invocations[i]); } LogAndUpdateVariableListener.reset(); }
public virtual void testVariableListenerWithProcessTask() { CaseInstance caseInstance = caseService.createCaseInstanceByKey("case"); CaseExecution processTask = caseService.createCaseExecutionQuery().activityId("PI_ProcessTask_1").singleResult(); string processTaskId = processTask.Id; caseService.withCaseExecution(processTaskId).manualStart(); // then the listener is invoked assertEquals(1, LogVariableListener.Invocations.Count); DelegateVariableInstanceSpec.fromCaseExecution(caseInstance).sourceExecution(processTask).@event([email protected]_Fields.CREATE).name("aVariable").value("aValue").matches(LogVariableListener.Invocations[0]); LogVariableListener.reset(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testListenerOnParentScope() public virtual void testListenerOnParentScope() { caseService.withCaseDefinitionByKey("case").create(); CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult(); assertNotNull(taskExecution); // when i set a variable on a deeper scope caseService.withCaseExecution(taskExecution.Id).setVariableLocal("aTaskVariable", "aTaskValue").execute(); // then the listener is invoked assertEquals(1, LogVariableListener.Invocations.Count); DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.CREATE).name("aTaskVariable").value("aTaskValue").matches(LogVariableListener.Invocations[0]); LogVariableListener.reset(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testAnyEventListenerByClass() public virtual void testAnyEventListenerByClass() { CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create(); CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult(); assertNotNull(taskExecution); // when i set a variable on a higher scope caseService.withCaseExecution(caseInstance.Id).setVariable("anInstanceVariable", "anInstanceValue").execute(); // then the listener is not invoked assertTrue(LogVariableListener.Invocations.Count == 0); // when i set a variable on the human task (ie the source execution matters although the variable ends up in the same place) caseService.withCaseExecution(taskExecution.Id).setVariableLocal("aTaskVariable", "aTaskValue").execute(); // then the listener is invoked assertEquals(1, LogVariableListener.Invocations.Count); DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.CREATE).name("aTaskVariable").value("aTaskValue").matches(LogVariableListener.Invocations[0]); LogVariableListener.reset(); // when i update the variable on the human task caseService.withCaseExecution(taskExecution.Id).setVariable("aTaskVariable", "aNewTaskValue").execute(); // then the listener is invoked assertEquals(1, LogVariableListener.Invocations.Count); DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.UPDATE).name("aTaskVariable").value("aNewTaskValue").activityInstanceId(taskExecution.Id).matches(LogVariableListener.Invocations[0]); LogVariableListener.reset(); // when i remove the variable from the human task caseService.withCaseExecution(taskExecution.Id).removeVariable("aTaskVariable").execute(); // then the listener is invoked assertEquals(1, LogVariableListener.Invocations.Count); DelegateVariableInstanceSpec.fromCaseExecution(taskExecution).@event([email protected]_Fields.DELETE).name("aTaskVariable").value(null).activityInstanceId(taskExecution.Id).matches(LogVariableListener.Invocations[0]); LogVariableListener.reset(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testVariableListenerInvokedFromSourceScope() public virtual void testVariableListenerInvokedFromSourceScope() { CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create(); CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult(); assertNotNull(taskExecution); // when i create a variable on the case instance caseService.withCaseExecution(caseInstance.Id).setVariable("aTaskVariable", "aTaskValue").execute(); // then the listener is not invoked assertEquals(0, LogVariableListener.Invocations.Count); // when i update the variable from the task execution caseService.withCaseExecution(taskExecution.Id).setVariable("aTaskVariable", "aTaskValue").execute(); // then the listener is invoked assertEquals(1, LogVariableListener.Invocations.Count); DelegateVariableInstanceSpec.fromCaseExecution(caseInstance).sourceExecution(taskExecution).@event([email protected]_Fields.UPDATE).name("aTaskVariable").value("aTaskValue").activityInstanceId(caseInstance.Id).matches(LogVariableListener.Invocations[0]); LogVariableListener.reset(); }