use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionUtilsTest method testFindByName.
@Test
public void testFindByName() {
final String name = "item1";
final ItemDefinition item1 = makeItem("item1");
final ItemDefinition item2 = makeItem("item2");
final Definitions definitions = mock(Definitions.class);
final List<ItemDefinition> itemDefinitions = asList(item1, item2);
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(definitions.getItemDefinition()).thenReturn(itemDefinitions);
final Optional<ItemDefinition> actual = utils.findByName(name);
final Optional<ItemDefinition> expected = Optional.of(item1);
assertEquals(expected, actual);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionUtilsTest method testGetConstraintTextWhenItemDefinitionHasAllowedValues.
@Test
public void testGetConstraintTextWhenItemDefinitionHasAllowedValues() {
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final UnaryTests allowedValues = mock(UnaryTests.class);
final String expectedText = "(1..10)";
when(allowedValues.getText()).thenReturn(new Text(expectedText));
when(itemDefinition.getAllowedValues()).thenReturn(allowedValues);
final String actualText = utils.getConstraintText(itemDefinition);
assertEquals(expectedText, actualText);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionStoreTest method testIndex.
@Test
public void testIndex() {
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final String uuid = "789";
store.index(uuid, itemDefinition);
assertEquals(itemDefinition, store.get(uuid));
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class DataTypeUpdateHandlerTest method testRefreshSubDataType.
@Test
public void testRefreshSubDataType() {
final DataType dataType = mock(DataType.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final String newType = "newType";
final String type = "type";
final String uuid = "uuid";
when(dataType.getType()).thenReturn(type);
when(dataType.getUUID()).thenReturn(uuid);
when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
when(dataTypeManager.from(dataType)).thenReturn(dataTypeManager);
when(dataTypeManager.withType(newType)).thenReturn(dataTypeManager);
handler.refreshSubDataType(dataType, newType);
final InOrder inOrder = Mockito.inOrder(dataTypeManager, dataTypeManager, recordEngine, handler);
inOrder.verify(dataTypeManager).from(dataType);
inOrder.verify(dataTypeManager).withType(newType);
inOrder.verify(recordEngine).doUpdate(dataType, itemDefinition);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionDestroyHandlerTest method testDestroy.
@Test
public void testDestroy() {
final String uuid = "uuid";
final String oldItemDefinitionName = "oldItemDefinitionName";
final DataType dataType = mock(DataType.class);
final Name name = mock(Name.class);
final ItemDefinition itemDefinition = makeItemDefinition();
final ItemDefinition itemDefinitionParent = makeItemDefinition(itemDefinition);
final List<ItemDefinition> itemDefinitions = new ArrayList<ItemDefinition>() {
{
add(itemDefinition);
}
};
when(name.getValue()).thenReturn(oldItemDefinitionName);
when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
when(dataType.getUUID()).thenReturn(uuid);
doReturn(Optional.of(itemDefinitionParent)).when(handler).findItemDefinitionParent(dataType);
doReturn(name).when(itemDefinition).getName();
doReturn(itemDefinitions).when(handler).itemDefinitions();
doNothing().when(handler).notifyPropertiesPanel(Mockito.<String>any());
handler.destroy(dataType, true);
assertEquals(emptyList(), itemDefinitionParent.getItemComponent());
assertEquals(emptyList(), itemDefinitions);
verify(handler).notifyPropertiesPanel(oldItemDefinitionName);
}
Aggregations