use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class DMNDiagramHelperTest method testGetItemDefinitionsByDiagram.
@Test
public void testGetItemDefinitionsByDiagram() {
final Definitions definitions = mock(Definitions.class);
final List<ItemDefinition> expectedItemDefinitions = asList(mock(ItemDefinition.class), mock(ItemDefinition.class));
when(definitions.getItemDefinition()).thenReturn(expectedItemDefinitions);
when(dmnDiagramUtils.getDefinitions(diagram)).thenReturn(definitions);
final List<ItemDefinition> actualItemDefinitions = helper.getItemDefinitions(diagram);
assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionPropertyConverterTest method testSetItemComponent.
@Test
public void testSetItemComponent() {
final String id = "id";
final String name = "name";
final String typeLanguage = "typeLanguage";
final boolean isCollection = true;
final boolean isOnlyVisualChanges = false;
final String description = "description";
final ItemDefinition expectedWbChild = new ItemDefinition(new Id(id), new Description(description), new Name(name), null, null, null, typeLanguage, isCollection, isOnlyVisualChanges);
final ItemDefinition wb = new ItemDefinition();
final org.kie.dmn.model.api.ItemDefinition dmn = mock(org.kie.dmn.model.api.ItemDefinition.class);
final org.kie.dmn.model.api.ItemDefinition dmnChild = mock(org.kie.dmn.model.api.ItemDefinition.class);
when(dmnChild.getId()).thenReturn(id);
when(dmnChild.getName()).thenReturn(name);
when(dmnChild.getTypeLanguage()).thenReturn(typeLanguage);
when(dmnChild.isIsCollection()).thenReturn(isCollection);
when(dmnChild.getDescription()).thenReturn(description);
when(dmnChild.getTypeRef()).thenReturn(null);
when(dmn.getItemComponent()).thenReturn(singletonList(dmnChild));
setItemComponent(wb, dmn);
final List<ItemDefinition> expectedItemDefinitions = singletonList(expectedWbChild);
final List<ItemDefinition> actualItemDefinitions = wb.getItemComponent();
assertEquals(expectedItemDefinitions, actualItemDefinitions);
assertEquals(wb, actualItemDefinitions.get(0).getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionPropertyConverterTest method testWbChildFromDMNWhenWbChildIsNotNull.
@Test
public void testWbChildFromDMNWhenWbChildIsNotNull() {
final String id = "id";
final String name = "name";
final String typeLanguage = "typeLanguage";
final boolean isCollection = true;
final boolean isOnlyVisualChanges = false;
final String description = "description";
final ItemDefinition expectedWbParent = new ItemDefinition();
final ItemDefinition expectedWbChild = new ItemDefinition(new Id(id), new Description(description), new Name(name), null, null, null, typeLanguage, isCollection, isOnlyVisualChanges);
final org.kie.dmn.model.api.ItemDefinition dmnChild = mock(org.kie.dmn.model.api.ItemDefinition.class);
when(dmnChild.getId()).thenReturn(id);
when(dmnChild.getName()).thenReturn(name);
when(dmnChild.getTypeLanguage()).thenReturn(typeLanguage);
when(dmnChild.isIsCollection()).thenReturn(isCollection);
when(dmnChild.getDescription()).thenReturn(description);
when(dmnChild.getTypeRef()).thenReturn(null);
final ItemDefinition actualWbChild = wbChildFromDMN(expectedWbParent, dmnChild);
final ItemDefinition actualParent = (ItemDefinition) actualWbChild.getParent();
assertEquals(expectedWbChild, actualWbChild);
assertEquals(expectedWbParent, actualParent);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionPropertyConverterTest method testWbChildFromDMNWhenWbChildIsNull.
@Test
public void testWbChildFromDMNWhenWbChildIsNull() {
final ItemDefinition expectedWbParent = new ItemDefinition();
final org.kie.dmn.model.api.ItemDefinition dmnChild = null;
final ItemDefinition actualWbChild = wbChildFromDMN(expectedWbParent, dmnChild);
assertNull(actualWbChild);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionPropertyConverterTest method testSetUnaryTestsWhenUnaryTestsIsNotNull.
@Test
public void testSetUnaryTestsWhenUnaryTestsIsNotNull() {
final ItemDefinition wb = mock(ItemDefinition.class);
final ArgumentCaptor<UnaryTests> argument = ArgumentCaptor.forClass(UnaryTests.class);
final org.kie.dmn.model.api.ItemDefinition dmn = mock(org.kie.dmn.model.api.ItemDefinition.class);
final org.kie.dmn.model.api.UnaryTests dmnAllowedValues = mock(org.kie.dmn.model.api.UnaryTests.class);
when(dmn.getAllowedValues()).thenReturn(dmnAllowedValues);
setUnaryTests(wb, dmn);
verify(wb).setAllowedValues(argument.capture());
assertEquals(wb, argument.getValue().getParent());
}
Aggregations