Exemplo n.º 1
0
        public virtual void testQueryByVariableTypeInWithCapitalLetter()
        {
            // given
            IDictionary <string, object> variables1 = new Dictionary <string, object>();

            variables1["stringVar"] = "test";
            variables1["boolVar"]   = true;
            runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);

            // when
            HistoricDetailQuery query = historyService.createHistoricDetailQuery().variableTypeIn("Boolean");

            // then
            assertEquals(1, query.list().size());
            assertEquals(1, query.count());
            HistoricDetail historicDetail = query.list().get(0);

            if (historicDetail is HistoricVariableUpdate)
            {
                HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate)historicDetail;
                assertEquals(variableUpdate.VariableName, "boolVar");
                assertEquals(variableUpdate.TypeName, "boolean");
            }
            else
            {
                fail("Historic detail should be a variable update!");
            }
        }
Exemplo n.º 2
0
        public static HistoricVariableUpdateDto fromHistoricVariableUpdate(HistoricVariableUpdate historicVariableUpdate)
        {
            HistoricVariableUpdateDto dto = new HistoricVariableUpdateDto();

            fromHistoricVariableUpdate(dto, historicVariableUpdate);
            return(dto);
        }
Exemplo n.º 3
0
 private void assertThatUpdateHasAllImportantInformation(HistoricVariableUpdate variableUpdate)
 {
     assertThat(variableUpdate, notNullValue());
     assertThat(variableUpdate.Id, notNullValue());
     assertThat(variableUpdate.ProcessDefinitionKey, @is("process"));
     assertThat(variableUpdate.ProcessDefinitionId, notNullValue());
     assertThat(variableUpdate.VariableName, @is("stringVar"));
     assertThat(variableUpdate.Value.ToString(), @is("foo"));
     assertThat(variableUpdate.TypeName, @is("string"));
     assertThat(variableUpdate.Time, notNullValue());
 }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpRuntimeData()
        public virtual void setUpRuntimeData()
        {
            historicUpdateBuilder = MockProvider.mockHistoricVariableUpdate();
            historicUpdateMock    = historicUpdateBuilder.build();

            mockedOptimizeService = mock(typeof(OptimizeService));
            ProcessEngineConfigurationImpl mockedConfig = mock(typeof(ProcessEngineConfigurationImpl));

            when(mockedOptimizeService.getHistoricVariableUpdates(any(typeof(DateTime)), any(typeof(DateTime)), anyInt())).thenReturn(Arrays.asList(historicUpdateMock));

            namedProcessEngine = getProcessEngine(MockProvider.EXAMPLE_PROCESS_ENGINE_NAME);
            when(namedProcessEngine.ProcessEngineConfiguration).thenReturn(mockedConfig);
            when(mockedConfig.OptimizeService).thenReturn(mockedOptimizeService);
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void execute(org.camunda.bpm.engine.delegate.DelegateExecution execution) throws Exception
        public virtual void execute(DelegateExecution execution)
        {
            HistoryService historyService = execution.ProcessEngineServices.HistoryService;

            HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().variableName("listVar").singleResult();

            HistoricVariableUpdate initialUpdate = (HistoricVariableUpdate)historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variableInstance.Id).orderPartiallyByOccurrence().asc().list().get(0);

            IList <string> list = (IList <string>)initialUpdate.Value;

            // implicit update of the list, should not trigger an update
            // of the value since we deal with historic variables
            list.Add(NEW_ELEMENT);
        }
Exemplo n.º 6
0
        public static HistoricDetailDto fromHistoricDetail(HistoricDetail historicDetail)
        {
            HistoricDetailDto dto = null;

            if (historicDetail is HistoricFormField)
            {
                HistoricFormField historicFormField = (HistoricFormField)historicDetail;
                dto = HistoricFormFieldDto.fromHistoricFormField(historicFormField);
            }
            else if (historicDetail is HistoricVariableUpdate)
            {
                HistoricVariableUpdate historicVariableUpdate = (HistoricVariableUpdate)historicDetail;
                dto = HistoricVariableUpdateDto.fromHistoricVariableUpdate(historicVariableUpdate);
            }

            fromHistoricDetail(historicDetail, dto);
            return(dto);
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ignore @Test public void testHistoryServiceEngineAccess_HistoricDetailBinaryFile()
        public virtual void testHistoryServiceEngineAccess_HistoricDetailBinaryFile()
        {
            HistoricDetailQuery    query    = mock(typeof(HistoricDetailQuery));
            HistoricVariableUpdate instance = mock(typeof(HistoricVariableUpdate));
            string filename = "test.txt";

            sbyte[]   byteContent   = "test".GetBytes();
            string    encoding      = "UTF-8";
            FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.ToString()).encoding(encoding).create();

            when(instance.TypedValue).thenReturn(variableValue);
            when(query.singleResult()).thenReturn(instance);
            when(mockHistoryService.createHistoricDetailQuery()).thenReturn(query);

            given().pathParam("name", EXAMPLE_ENGINE_NAME).then().expect().statusCode(Status.OK.StatusCode).body(@is(equalTo(StringHelper.NewString(byteContent)))).and().header("Content-Disposition", "attachment; filename=" + filename).contentType(CoreMatchers.either <string>(equalTo(ContentType.TEXT.ToString() + ";charset=UTF-8")).or(equalTo(ContentType.TEXT.ToString() + " ;charset=UTF-8"))).when().get(HISTORY_BINARY_DETAIL_URL);

            verify(mockHistoryService).createHistoricDetailQuery();
            verifyZeroInteractions(processEngine);
        }
Exemplo n.º 8
0
        protected internal virtual VariableMap collectInitialVariables(CommandContext commandContext, HistoricProcessInstance processInstance)
        {
            HistoryService historyService = commandContext.ProcessEngineConfiguration.HistoryService;

            HistoricActivityInstance startActivityInstance = resolveStartActivityInstance(processInstance);

            HistoricDetailQueryImpl query = (HistoricDetailQueryImpl)historyService.createHistoricDetailQuery().variableUpdates().executionId(processInstance.Id).activityInstanceId(startActivityInstance.Id);

            IList <HistoricDetail> historicDetails = query.sequenceCounter(1).list();

            VariableMap variables = new VariableMapImpl();

            foreach (HistoricDetail detail in historicDetails)
            {
                HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate)detail;
                variables.putValueTyped(variableUpdate.VariableName, variableUpdate.TypedValue);
            }

            return(variables);
        }
Exemplo n.º 9
0
        public virtual void testQueryByVariableTypeInWithSeveralTypes()
        {
            // given
            IDictionary <string, object> variables1 = new Dictionary <string, object>();

            variables1["stringVar"] = "test";
            variables1["boolVar"]   = true;
            variables1["intVar"]    = 5;
            variables1["nullVar"]   = null;
            variables1["pojoVar"]   = new TestPojo("str", .0);
            runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);

            // when
            HistoricDetailQuery query = historyService.createHistoricDetailQuery().variableTypeIn("boolean", "integer", "Serializable");

            // then
            assertEquals(3, query.list().size());
            assertEquals(3, query.count());
            ISet <string> allowedVariableTypes = new HashSet <string>();

            allowedVariableTypes.Add("boolean");
            allowedVariableTypes.Add("integer");
            allowedVariableTypes.Add("object");
            foreach (HistoricDetail detail in query.list())
            {
                if (detail is HistoricVariableUpdate)
                {
                    HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate)detail;
                    assertTrue(allowedVariableTypes.Contains(variableUpdate.TypeName));
                }
                else
                {
                    fail("Historic detail should be a variable update!");
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// TODO: add when history for case execution variables is implemented
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void FAILING_testListenerDoesNotInterfereWithHistory()
        public virtual void FAILING_testListenerDoesNotInterfereWithHistory()
        {
            CaseInstance caseInstance = caseService.withCaseDefinitionByKey("case").create();

            // when i set a variable that causes the listener to be notified
            // and that listener sets the same variable to another value (here "value2")
            caseService.withCaseExecution(caseInstance.Id).setVariableLocal("variable", "value1").execute();

            // then there should be two historic variable updates for both values
            if (processEngineConfiguration.HistoryLevel.Id >= org.camunda.bpm.engine.impl.history.HistoryLevel_Fields.HISTORY_LEVEL_FULL.Id)
            {
                IList <HistoricDetail> variableUpdates = historyService.createHistoricDetailQuery().variableUpdates().list();

                assertEquals(2, variableUpdates.Count);

                foreach (HistoricDetail detail in variableUpdates)
                {
                    HistoricVariableUpdate update = (HistoricVariableUpdate)detail;
                    bool update1Processed         = false;
                    bool update2Processed         = false;

                    if (!update1Processed && update.Value.Equals("value1"))
                    {
                        update1Processed = true;
                    }
                    else if (!update2Processed && update.Value.Equals("value2"))
                    {
                        update2Processed = true;
                    }
                    else
                    {
                        fail("unexpected variable update");
                    }
                }
            }
        }
Exemplo n.º 11
0
        protected internal static void fromHistoricVariableUpdate(HistoricVariableUpdateDto dto, HistoricVariableUpdate historicVariableUpdate)
        {
            dto.revision           = historicVariableUpdate.Revision;
            dto.variableName       = historicVariableUpdate.VariableName;
            dto.variableInstanceId = historicVariableUpdate.VariableInstanceId;

            if (string.ReferenceEquals(historicVariableUpdate.ErrorMessage, null))
            {
                try
                {
                    VariableValueDto variableValueDto = VariableValueDto.fromTypedValue(historicVariableUpdate.TypedValue);
                    dto.value        = variableValueDto.Value;
                    dto.variableType = variableValueDto.Type;
                    dto.valueInfo    = variableValueDto.ValueInfo;
                }
                catch (Exception e)
                {
                    dto.errorMessage = e.Message;
                    dto.variableType = VariableValueDto.toRestApiTypeName(historicVariableUpdate.TypeName);
                }
            }
            else
            {
                dto.errorMessage = historicVariableUpdate.ErrorMessage;
                dto.variableType = VariableValueDto.toRestApiTypeName(historicVariableUpdate.TypeName);
            }
        }