use of org.camunda.bpm.model.dmn.instance.Definitions in project camunda-bpm-platform by camunda.
the class DecisionDefinitionDeployerTest method createDmnModelInstanceNegativeHistoryTimeToLive.
protected static DmnModelInstance createDmnModelInstanceNegativeHistoryTimeToLive() {
DmnModelInstance modelInstance = Dmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
definitions.setNamespace(DmnModelConstants.CAMUNDA_NS);
modelInstance.setDefinitions(definitions);
Decision decision = modelInstance.newInstance(Decision.class);
decision.setId("Decision-1");
decision.setName("foo");
decision.setCamundaHistoryTimeToLive(-5);
modelInstance.getDefinitions().addChildElement(decision);
return modelInstance;
}
use of org.camunda.bpm.model.dmn.instance.Definitions in project camunda-bpm-platform by camunda.
the class DecisionDefinitionDeployerTest method createDmnModelInstance.
protected static DmnModelInstance createDmnModelInstance() {
DmnModelInstance modelInstance = Dmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
definitions.setNamespace(DmnModelConstants.CAMUNDA_NS);
modelInstance.setDefinitions(definitions);
Decision decision = modelInstance.newInstance(Decision.class);
decision.setId("Decision-1");
decision.setName("foo");
decision.setCamundaHistoryTimeToLive(5);
modelInstance.getDefinitions().addChildElement(decision);
DecisionTable decisionTable = modelInstance.newInstance(DecisionTable.class);
decisionTable.setId(DmnModelConstants.DMN_ELEMENT_DECISION_TABLE);
decisionTable.setHitPolicy(HitPolicy.FIRST);
decision.addChildElement(decisionTable);
Input input = modelInstance.newInstance(Input.class);
input.setId("Input-1");
input.setLabel("Input");
decisionTable.addChildElement(input);
InputExpression inputExpression = modelInstance.newInstance(InputExpression.class);
inputExpression.setId("InputExpression-1");
Text inputExpressionText = modelInstance.newInstance(Text.class);
inputExpressionText.setTextContent("input");
inputExpression.setText(inputExpressionText);
inputExpression.setTypeRef("string");
input.setInputExpression(inputExpression);
Output output = modelInstance.newInstance(Output.class);
output.setName("output");
output.setLabel("Output");
output.setTypeRef("string");
decisionTable.addChildElement(output);
return modelInstance;
}
use of org.camunda.bpm.model.dmn.instance.Definitions in project camunda-bpm-platform by camunda.
the class DecisionDefinitionDeployerTest method testDeployEmptyDecisionDefinition.
@Test
public void testDeployEmptyDecisionDefinition() throws Exception {
// given empty decision model
DmnModelInstance modelInstance = Dmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS);
definitions.setNamespace(DmnModelConstants.CAMUNDA_NS);
modelInstance.setDefinitions(definitions);
// when decision model is deployed
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", modelInstance);
DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder);
// then deployment contains no definitions
assertNull(deployment.getDeployedDecisionDefinitions());
assertNull(deployment.getDeployedDecisionRequirementsDefinitions());
// and there are no persisted definitions
assertNull(repositoryService.createDecisionDefinitionQuery().decisionDefinitionResourceName("foo.dmn").singleResult());
}
use of org.camunda.bpm.model.dmn.instance.Definitions in project camunda-dmn-model by camunda.
the class DmnModelInstanceTest method testClone.
@Test
public void testClone() throws Exception {
DmnModelInstance modelInstance = Dmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
definitions.setId("TestId");
modelInstance.setDefinitions(definitions);
DmnModelInstance cloneInstance = modelInstance.clone();
cloneInstance.getDefinitions().setId("TestId2");
assertThat(modelInstance.getDefinitions().getId(), is(equalTo("TestId")));
assertThat(cloneInstance.getDefinitions().getId(), is(equalTo("TestId2")));
}
use of org.camunda.bpm.model.dmn.instance.Definitions in project camunda-dmn-model by camunda.
the class ExampleTestCompatibility method shouldWriteElements.
@Test
public void shouldWriteElements() throws Exception {
modelInstance = Dmn.createEmptyModel();
// Definitions
Definitions definitions = generateNamedElement(Definitions.class, "definitions");
definitions.setNamespace(TEST_NAMESPACE);
modelInstance.setDocumentElement(definitions);
// Decision
Decision decision = generateNamedElement(Decision.class, "Check Order");
definitions.addChildElement(decision);
// Decision table
DecisionTable decisionTable = generateElement(DecisionTable.class);
decision.addChildElement(decisionTable);
// 1. Input clause
Input input = generateElement(Input.class, 1);
input.setLabel("Customer Status");
InputExpression inputExpression = generateElement(InputExpression.class, 1);
inputExpression.setTypeRef("string");
Text text = generateElement(Text.class);
text.setTextContent("status");
inputExpression.setText(text);
input.setInputExpression(inputExpression);
InputValues inputValues = generateElement(InputValues.class);
text = generateElement(Text.class);
text.setTextContent("\"bronze\",\"silver\",\"gold\"");
inputValues.setText(text);
input.setInputValues(inputValues);
decisionTable.getInputs().add(input);
// 2. Input clause
input = generateElement(Input.class, 2);
input.setLabel("Order Sum");
inputExpression = generateElement(InputExpression.class, 2);
inputExpression.setTypeRef("double");
text = generateElement(Text.class);
text.setTextContent("sum");
inputExpression.setText(text);
input.setInputExpression(inputExpression);
decisionTable.getInputs().add(input);
// 1. Output clause
Output output = generateElement(Output.class, 1);
output.setLabel("Check Result");
output.setName("result");
output.setTypeRef("string");
OutputValues outputValues = generateElement(OutputValues.class);
text = generateElement(Text.class);
text.setTextContent("\"ok\",\"notok\"");
outputValues.setText(text);
output.setOutputValues(outputValues);
decisionTable.getOutputs().add(output);
// 2. Output clause
output = generateElement(Output.class, 2);
output.setLabel("Reason");
output.setName("reason");
output.setTypeRef("string");
decisionTable.getOutputs().add(output);
// 1. Rule
Rule rule = generateElement(Rule.class, 1);
InputEntry inputEntry = generateElement(InputEntry.class, 1);
text = generateElement(Text.class);
text.setTextContent("\"bronze\"");
inputEntry.setText(text);
rule.getInputEntries().add(inputEntry);
inputEntry = generateElement(InputEntry.class, 2);
text = generateElement(Text.class);
text.setTextContent("");
inputEntry.setText(text);
rule.getInputEntries().add(inputEntry);
OutputEntry outputEntry = generateElement(OutputEntry.class, 1);
text = generateElement(Text.class);
text.setTextContent("\"notok\"");
outputEntry.setText(text);
rule.getOutputEntries().add(outputEntry);
outputEntry = generateElement(OutputEntry.class, 2);
text = generateElement(Text.class);
text.getDomElement().addCDataSection("\"work on your status first, as bronze you're not going to get anything\"");
outputEntry.setText(text);
rule.getOutputEntries().add(outputEntry);
decisionTable.getRules().add(rule);
// 2. Rule
rule = generateElement(Rule.class, 2);
inputEntry = generateElement(InputEntry.class, 3);
text = generateElement(Text.class);
text.setTextContent("\"silver\"");
rule.getInputEntries().add(inputEntry);
inputEntry.setText(text);
inputEntry = generateElement(InputEntry.class, 4);
text = generateElement(Text.class);
text.getDomElement().addCDataSection("< 1000");
inputEntry.setText(text);
rule.getInputEntries().add(inputEntry);
outputEntry = generateElement(OutputEntry.class, 3);
text = generateElement(Text.class);
text.setTextContent("\"ok\"");
outputEntry.setText(text);
rule.getOutputEntries().add(outputEntry);
outputEntry = generateElement(OutputEntry.class, 4);
text = generateElement(Text.class);
text.setTextContent("\"you little fish will get what you want\"");
outputEntry.setText(text);
rule.getOutputEntries().add(outputEntry);
decisionTable.getRules().add(rule);
// 3. Rule
rule = generateElement(Rule.class, 3);
inputEntry = generateElement(InputEntry.class, 5);
text = generateElement(Text.class);
text.setTextContent("\"silver\"");
inputEntry.setText(text);
rule.getInputEntries().add(inputEntry);
inputEntry = generateElement(InputEntry.class, 6);
text = generateElement(Text.class);
text.getDomElement().addCDataSection(">= 1000");
inputEntry.setText(text);
rule.getInputEntries().add(inputEntry);
outputEntry = generateElement(OutputEntry.class, 5);
text = generateElement(Text.class);
text.setTextContent("\"notok\"");
outputEntry.setText(text);
rule.getOutputEntries().add(outputEntry);
outputEntry = generateElement(OutputEntry.class, 6);
text = generateElement(Text.class);
text.setTextContent("\"you took too much man, you took too much!\"");
outputEntry.setText(text);
rule.getOutputEntries().add(outputEntry);
decisionTable.getRules().add(rule);
// 4. Rule
rule = generateElement(Rule.class, 4);
inputEntry = generateElement(InputEntry.class, 7);
text = generateElement(Text.class);
text.setTextContent("\"gold\"");
inputEntry.setText(text);
rule.getInputEntries().add(inputEntry);
inputEntry = generateElement(InputEntry.class, 8);
text = generateElement(Text.class);
text.setTextContent("");
inputEntry.setText(text);
rule.getInputEntries().add(inputEntry);
outputEntry = generateElement(OutputEntry.class, 7);
text = generateElement(Text.class);
text.setTextContent("\"ok\"");
outputEntry.setText(text);
rule.getOutputEntries().add(outputEntry);
outputEntry = generateElement(OutputEntry.class, 8);
text = generateElement(Text.class);
text.setTextContent("\"you get anything you want\"");
outputEntry.setText(text);
rule.getOutputEntries().add(outputEntry);
decisionTable.getRules().add(rule);
assertModelEqualsFile(EXAMPLE_DMN);
}
Aggregations