use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class ContextEntryDefaultValueUtilitiesTest method testGetNewContextEntryNameWithDeletion.
@Test
public void testGetNewContextEntryNameWithDeletion() {
final ContextEntry contextEntry1 = new ContextEntry() {
{
setVariable(new InformationItem());
}
};
context.getContextEntry().add(contextEntry1);
contextEntry1.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
assertThat(contextEntry1.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "1");
final ContextEntry contextEntry2 = new ContextEntry() {
{
setVariable(new InformationItem());
}
};
context.getContextEntry().add(contextEntry2);
contextEntry2.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
assertThat(contextEntry2.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "2");
context.getContextEntry().remove(contextEntry1);
final ContextEntry contextEntry3 = new ContextEntry() {
{
setVariable(new InformationItem());
}
};
context.getContextEntry().add(contextEntry3);
contextEntry3.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
assertThat(contextEntry3.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "3");
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class ContextEntryDefaultValueUtilitiesTest method testGetNewContextEntryName.
@Test
public void testGetNewContextEntryName() {
final ContextEntry contextEntry1 = new ContextEntry() {
{
setVariable(new InformationItem());
}
};
context.getContextEntry().add(contextEntry1);
contextEntry1.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
assertThat(contextEntry1.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "1");
final ContextEntry contextEntry2 = new ContextEntry() {
{
setVariable(new InformationItem());
}
};
context.getContextEntry().add(contextEntry2);
contextEntry2.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
assertThat(contextEntry2.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "2");
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class ContextEntryDefaultValueUtilitiesTest method testGetNewContextEntryNameWithExistingContextEntries.
@Test
public void testGetNewContextEntryNameWithExistingContextEntries() {
final ContextEntry contextEntry1 = new ContextEntry() {
{
setVariable(new InformationItem());
}
};
context.getContextEntry().add(contextEntry1);
contextEntry1.getVariable().getName().setValue("entry");
final ContextEntry contextEntry2 = new ContextEntry() {
{
setVariable(new InformationItem());
}
};
context.getContextEntry().add(contextEntry2);
contextEntry2.getVariable().getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
assertThat(contextEntry2.getVariable().getName().getValue()).isEqualTo(ContextEntryDefaultValueUtilities.PREFIX + "1");
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class DMNMarshallerStandaloneTest method checkDecisionWithContextWithDefaultResult.
private void checkDecisionWithContextWithDefaultResult(Graph<?, Node<?, ?>> g) {
Node<?, ?> decisionNode = g.getNode("_30810b88-8416-4c02-8ed1-8c19b7606243");
assertNodeContentDefinitionIs(decisionNode, Decision.class);
Context context = (Context) ((Decision) ((View<?>) decisionNode.getContent()).getDefinition()).getExpression();
InformationItem defaultResultVariable = context.getContextEntry().get(1).getVariable();
assertNull("Default result variable", defaultResultVariable);
Expression defaultResultExpression = context.getContextEntry().get(1).getExpression();
assertNotNull("Default result expression", defaultResultExpression);
assertEquals("defaultResultExpression's parent-parent is contextNode", "_0f38d114-5d6e-40dd-aa9c-9f031f9b0571", ((DMNElement) (defaultResultExpression).getParent().getParent()).getId().getValue());
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class RelationPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.Relation dmnFromWB(final Relation wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
final org.kie.dmn.model.api.Relation result = new org.kie.dmn.model.v1_2.TRelation();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (InformationItem iitem : wb.getColumn()) {
final org.kie.dmn.model.api.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem);
if (iitemConverted != null) {
iitemConverted.setParent(result);
}
result.getColumn().add(iitemConverted);
}
for (org.kie.workbench.common.dmn.api.definition.model.List list : wb.getRow()) {
final org.kie.dmn.model.api.List listConverted = ListPropertyConverter.dmnFromWB(list, componentWidthsConsumer);
if (listConverted != null) {
listConverted.setParent(result);
}
result.getRow().add(listConverted);
}
return result;
}
Aggregations