Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docusaurus/docs/bpmn/ch04-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Instead of using Java serialization:

The behavior of the *serializable* variable type can be configured through the `serializableVariableTypeMode` property of the engine configuration:

- `DISABLED` (default): serializable variables can neither be written nor read. Existing serializable variables can still be deleted, but reading their value fails.
- `DISABLED` (default): serializable variables can neither be written nor read. Existing serializable variables can still be deleted or overwritten with a value of another type, but reading their value fails.

- `READ_ONLY`: existing serializable variables can be read (and overwritten with a value of another type), but no new serializable values can be stored. Use this mode to migrate existing data away from Java serialization.

Expand Down
2 changes: 2 additions & 0 deletions docs/docusaurus/docs/bpmn/ch14-REST.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ It’s possible to support additional variable-types with a custom JSON represen

Variables of type *serializable* (Java serialized objects) are disabled by default. Uploading a serialized object (`application/x-java-serialized-object`) or downloading the data of a *serializable* variable returns a `415` response. To allow it, set the `rest.variables.allow.serializable` property to `true`. The `serializableVariableTypeMode` of the engine needs to allow it as well, see [Serializable variables](bpmn/ch04-API.md#serializable-variables). Only enable this when the REST API is used by fully trusted clients, since deserializing Java objects from a request is a security risk.

A variable with a JSON object or array as value needs to have the `json` type. Without a type such a value could only be stored using Java serialization, therefore the request is rejected with a `400` response. This does not apply to transient variables.

## Deployment

**When using Tomcat, please read [Usage in Tomcat](#usage-In-tomcat).**
Expand Down
2 changes: 2 additions & 0 deletions docs/docusaurus/docs/cmmn/ch08-REST.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ It’s possible to support additional variable-types with a custom JSON represen

Variables of type *serializable* (Java serialized objects) are disabled by default. Uploading a serialized object (`application/x-java-serialized-object`) or downloading the data of a *serializable* variable returns a `415` response. To allow it, set the `rest.variables.allow.serializable` property to `true`. The `serializableVariableTypeMode` of the engine needs to allow it as well, see [Serializable variables](bpmn/ch04-API.md#serializable-variables). Only enable this when the REST API is used by fully trusted clients, since deserializing Java objects from a request is a security risk.

A variable with a JSON object or array as value needs to have the `json` type. Without a type such a value could only be stored using Java serialization, therefore the request is rejected with a `400` response. This does not apply to transient variables.

## Deployment

**When using Tomcat, please read [Usage in Tomcat](#usage-in-tomcat).**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
import org.flowable.variable.service.impl.types.DateType;
import org.flowable.variable.service.impl.types.DefaultVariableTypes;
import org.flowable.variable.service.impl.types.DoubleType;
import org.flowable.variable.service.impl.types.FloatType;
import org.flowable.variable.service.impl.types.EmptyCollectionType;
import org.flowable.variable.service.impl.types.FloatType;
import org.flowable.variable.service.impl.types.InstantType;
import org.flowable.variable.service.impl.types.IntegerType;
import org.flowable.variable.service.impl.types.JodaDateTimeType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@
import org.flowable.variable.service.impl.types.DateType;
import org.flowable.variable.service.impl.types.DefaultVariableTypes;
import org.flowable.variable.service.impl.types.DoubleType;
import org.flowable.variable.service.impl.types.FloatType;
import org.flowable.variable.service.impl.types.EmptyCollectionType;
import org.flowable.variable.service.impl.types.FloatType;
import org.flowable.variable.service.impl.types.InstantType;
import org.flowable.variable.service.impl.types.IntegerType;
import org.flowable.variable.service.impl.types.JodaDateTimeType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.flowable.cmmn.test.runtime;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;

import org.flowable.cmmn.api.runtime.CaseInstance;
import org.flowable.cmmn.engine.test.CmmnDeployment;
import org.flowable.cmmn.test.FlowableCmmnTestCase;
import org.flowable.variable.api.history.HistoricVariableInstance;
import org.flowable.variable.api.persistence.entity.VariableInstance;
import org.flowable.variable.service.impl.types.FloatType;
import org.junit.jupiter.api.Test;

/**
* @author Filip Hrisafov
*/
class FloatVariableTest extends FlowableCmmnTestCase {

@Test
@CmmnDeployment(resources = "org/flowable/cmmn/test/one-human-task-model.cmmn")
void testFloatVariable() {
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder()
.caseDefinitionKey("oneTaskCase")
.variable("floatVar", 1.1f)
.variable("maxFloatVar", Float.MAX_VALUE)
.start();

VariableInstance variableInstance = cmmnRuntimeService.getVariableInstance(caseInstance.getId(), "floatVar");
assertThat(variableInstance.getTypeName()).isEqualTo(FloatType.TYPE_NAME);
assertThat(variableInstance.getValue()).isEqualTo(1.1f);

assertThat(cmmnRuntimeService.getVariables(caseInstance.getId()))
.containsOnly(
entry("floatVar", 1.1f),
entry("maxFloatVar", Float.MAX_VALUE)
);

assertThat(cmmnRuntimeService.createCaseInstanceQuery().variableValueEquals("floatVar", 1.1f).list())
.extracting(CaseInstance::getId)
.containsExactly(caseInstance.getId());
assertThat(cmmnRuntimeService.createCaseInstanceQuery().variableValueGreaterThan("floatVar", 1.0f).count()).isEqualTo(1);
assertThat(cmmnRuntimeService.createCaseInstanceQuery().variableValueEquals("floatVar", 1.2f).count()).isZero();

cmmnRuntimeService.setVariable(caseInstance.getId(), "floatVar", 2.5f);
assertThat(cmmnRuntimeService.getVariable(caseInstance.getId(), "floatVar")).isEqualTo(2.5f);

HistoricVariableInstance historicVariableInstance = cmmnHistoryService.createHistoricVariableInstanceQuery()
.caseInstanceId(caseInstance.getId())
.variableName("floatVar")
.singleResult();
assertThat(historicVariableInstance.getVariableTypeName()).isEqualTo(FloatType.TYPE_NAME);
assertThat(historicVariableInstance.getValue()).isEqualTo(2.5f);
}
}
Loading
Loading