use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.
the class ProcessExtensionsJsonVarsTest method processInstanceFailsIfVariableTypeIncorrect.
@Test
public void processInstanceFailsIfVariableTypeIncorrect() {
securityUtil.logInAs("user");
ProcessRuntimeConfiguration configuration = processRuntime.configuration();
assertThat(configuration).isNotNull();
// by default jackson won't ser empty bean so it can't be handled as json
assertThat(objectMapper.canSerialize(EmptyBean.class)).isFalse();
assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> {
processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(JSON_VARS_PROCESS).withVariable("var2", new EmptyBean()).withVariable("var5", "this one is ok as doesn't have to be json").build());
}).withMessage("Variables fail type validation: var2");
// we don't test for bad json in the extension file because the context doesn't load for that scenario as failure is during parsing
}
use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.
the class ProcessExtensionsJsonVarsTest method processInstanceFailsIfVariableCannotBeSerializedAsJson.
@Test
public void processInstanceFailsIfVariableCannotBeSerializedAsJson() {
securityUtil.logInAs("user");
ProcessRuntimeConfiguration configuration = processRuntime.configuration();
assertThat(configuration).isNotNull();
// var5 doesn't ave any defined type as not in the file
// but it still needs to be serlializable as json because serializePOJOsInVariablesToJson is true, meaning java ser is not available
// by default jackson won't ser empty bean so it can't be handled as json
assertThat(objectMapper.canSerialize(EmptyBean.class)).isFalse();
assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> {
processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(JSON_VARS_PROCESS).withVariable("var2", new ObjectMapper().readValue("{ \"testvar2element\":\"testvar2element\"}", JsonNode.class)).withVariable("var5", new EmptyBean()).build());
}).withMessageStartingWith("couldn't find a variable type that is able to serialize");
}
use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.
the class ProcessRuntimeSecurityPoliciesIT method getRestrictedProcessDefs.
@Test
public void getRestrictedProcessDefs() {
securityUtil.logInAs("user");
// @TODO: I should get the security policies defined here.
ProcessRuntimeConfiguration configuration = processRuntime.configuration();
assertThat(configuration).isNotNull();
Page<ProcessDefinition> processDefinitionPage = processRuntime.processDefinitions(Pageable.of(0, 50));
assertThat(processDefinitionPage.getContent()).isNotNull();
assertThat(processDefinitionPage.getContent()).hasSize(2);
}
use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.
the class ProcessExtensionsIT method processInstanceFailsWithoutRequiredVariables.
@Test
public void processInstanceFailsWithoutRequiredVariables() {
ProcessRuntimeConfiguration configuration = processRuntime.configuration();
assertThat(configuration).isNotNull();
assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> {
processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(INITIAL_VARS_PROCESS).withVariable("extraVar", true).build());
}).withMessage("Can't start process '" + INITIAL_VARS_PROCESS + "' without required variables - age");
}
use of org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration in project Activiti by Activiti.
the class ProcessExtensionsIT method processInstanceHasInitialVariables.
@Test
public void processInstanceHasInitialVariables() {
ProcessRuntimeConfiguration configuration = processRuntime.configuration();
assertThat(configuration).isNotNull();
// start a process with vars then check default and specified vars exist
ProcessInstance initialVarsProcess = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(INITIAL_VARS_PROCESS).withVariable("extraVar", true).withVariable("age", 10).withBusinessKey("my business key").build());
assertThat(initialVarsProcess).isNotNull();
assertThat(initialVarsProcess.getStatus()).isEqualTo(ProcessInstance.ProcessInstanceStatus.RUNNING);
List<VariableInstance> variableInstances = processRuntime.variables(ProcessPayloadBuilder.variables().withProcessInstance(initialVarsProcess).build());
assertThat(variableInstances).isNotNull();
assertThat(variableInstances).hasSize(4);
assertThat(variableInstances).extracting("name").contains("extraVar", "name", "age", "birth").doesNotContain("subscribe");
// cleanup
processRuntime.delete(ProcessPayloadBuilder.delete(initialVarsProcess));
}
Aggregations