public virtual void testJpaVariableHappyPath() { IDictionary <string, object> variables = new Dictionary <string, object>(); variables["customerName"] = "John Doe"; variables["amount"] = 15000L; ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("LoanRequestProcess", variables); // Variable should be present containing the loanRequest created by the spring bean object value = runtimeService.getVariable(processInstance.Id, "loanRequest"); assertNotNull(value); assertTrue(value is LoanRequest); LoanRequest request = (LoanRequest)value; assertEquals("John Doe", request.CustomerName); assertEquals(15000L, request.Amount.Value); assertFalse(request.Approved); // We will approve the request, which will update the entity variables = new Dictionary <string, object>(); variables["approvedByManager"] = true; Task task = taskService.createTaskQuery().processInstanceId(processInstance.Id).singleResult(); assertNotNull(task); taskService.complete(task.Id, variables); // If approved, the processsInstance should be finished, gateway based on loanRequest.approved value assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.Id).count()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Transactional public LoanRequest newLoanRequest(String customerName, System.Nullable<long> amount) public virtual LoanRequest newLoanRequest(string customerName, long?amount) { LoanRequest lr = new LoanRequest(); lr.CustomerName = customerName; lr.Amount = amount; lr.Approved = false; entityManager.persist(lr); return(lr); }
public virtual void testJpaVariableDisapprovalPath() { IDictionary <string, object> variables = new Dictionary <string, object>(); variables["customerName"] = "Jane Doe"; variables["amount"] = 50000; ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("LoanRequestProcess", variables); // Variable should be present containing the loanRequest created by the spring bean object value = runtimeService.getVariable(processInstance.Id, "loanRequest"); assertNotNull(value); assertTrue(value is LoanRequest); LoanRequest request = (LoanRequest)value; assertEquals("Jane Doe", request.CustomerName); assertEquals(50000L, request.Amount.Value); assertFalse(request.Approved); // We will disapprove the request, which will update the entity variables = new Dictionary <string, object>(); variables["approvedByManager"] = false; Task task = taskService.createTaskQuery().processInstanceId(processInstance.Id).singleResult(); assertNotNull(task); taskService.complete(task.Id, variables); runtimeService.getVariable(processInstance.Id, "loanRequest"); request = (LoanRequest)value; assertFalse(request.Approved); // If disapproved, an extra task will be available instead of the process ending task = taskService.createTaskQuery().processInstanceId(processInstance.Id).singleResult(); assertNotNull(task); assertEquals("Send rejection letter", task.Name); }