use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript in project camunda-bpmn-model by camunda.
the class CamundaExtensionsTest method testCamundaScriptInputParameter.
@Test
public void testCamundaScriptInputParameter() {
CamundaInputParameter inputParameter = findInputParameterByName(serviceTask, "shouldBeScript");
assertThat(inputParameter.getCamundaName()).isEqualTo("shouldBeScript");
assertThat(inputParameter.getTextContent()).isNotEmpty();
assertThat(inputParameter.getUniqueChildElementByNameNs(CAMUNDA_NS, "script")).isNotNull();
assertThat(inputParameter.getUniqueChildElementByType(CamundaScript.class)).isNotNull();
CamundaScript script = inputParameter.getValue();
assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
assertThat(script.getCamundaResource()).isNull();
assertThat(script.getTextContent()).isEqualTo("1 + 1");
script = modelInstance.newInstance(CamundaScript.class);
script.setCamundaScriptFormat("python");
script.setCamundaResource("script.py");
inputParameter.setValue(script);
script = inputParameter.getValue();
assertThat(script.getCamundaScriptFormat()).isEqualTo("python");
assertThat(script.getCamundaResource()).isEqualTo("script.py");
assertThat(script.getTextContent()).isEmpty();
inputParameter.removeValue();
assertThat(inputParameter.getValue()).isNull();
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript in project camunda-bpmn-model by camunda.
the class CamundaScriptImpl method registerType.
public static void registerType(ModelBuilder modelBuilder) {
ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(CamundaScript.class, CAMUNDA_ELEMENT_SCRIPT).namespaceUri(CAMUNDA_NS).instanceProvider(new ModelTypeInstanceProvider<CamundaScript>() {
public CamundaScript newInstance(ModelTypeInstanceContext instanceContext) {
return new CamundaScriptImpl(instanceContext);
}
});
camundaScriptFormatAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_SCRIPT_FORMAT).required().build();
camundaResourceAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_RESOURCE).build();
typeBuilder.build();
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript in project camunda-bpmn-model by camunda.
the class CamundaExtensionsTest method testCamundaScriptExecutionListener.
@Test
public void testCamundaScriptExecutionListener() {
CamundaExecutionListener sequenceFlowListener = sequenceFlow.getExtensionElements().getElementsQuery().filterByType(CamundaExecutionListener.class).singleResult();
CamundaScript script = sequenceFlowListener.getCamundaScript();
assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
assertThat(script.getCamundaResource()).isNull();
assertThat(script.getTextContent()).isEqualTo("println 'Hello World'");
CamundaScript newScript = modelInstance.newInstance(CamundaScript.class);
newScript.setCamundaScriptFormat("groovy");
newScript.setCamundaResource("test.groovy");
sequenceFlowListener.setCamundaScript(newScript);
script = sequenceFlowListener.getCamundaScript();
assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
assertThat(script.getCamundaResource()).isEqualTo("test.groovy");
assertThat(script.getTextContent()).isEmpty();
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript in project camunda-bpmn-model by camunda.
the class CamundaExtensionsTest method testCamundaScriptTaskListener.
@Test
public void testCamundaScriptTaskListener() {
CamundaTaskListener taskListener = userTask.getExtensionElements().getElementsQuery().filterByType(CamundaTaskListener.class).list().get(1);
CamundaScript script = taskListener.getCamundaScript();
assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
assertThat(script.getCamundaResource()).isEqualTo("test.groovy");
assertThat(script.getTextContent()).isEmpty();
CamundaScript newScript = modelInstance.newInstance(CamundaScript.class);
newScript.setCamundaScriptFormat("groovy");
newScript.setTextContent("println 'Hello World'");
taskListener.setCamundaScript(newScript);
script = taskListener.getCamundaScript();
assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
assertThat(script.getCamundaResource()).isNull();
assertThat(script.getTextContent()).isEqualTo("println 'Hello World'");
}
Aggregations