use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionDestroyHandlerTest method makeItemDefinition.
private ItemDefinition makeItemDefinition(final ItemDefinition... itemDefinitions) {
final ItemDefinition itemDefinition = spy(new ItemDefinition());
itemDefinition.getItemComponent().addAll(asList(itemDefinitions));
return itemDefinition;
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionDestroyHandlerTest method testFindItemDefinitionParentWhenItCouldNotBeFound.
@Test
public void testFindItemDefinitionParentWhenItCouldNotBeFound() {
final DataType dataType = mock(DataType.class);
final ItemDefinition parent = makeItemDefinition();
final String parentUUID = "parentUUID";
final String type = "type";
final String nameValue = "name";
final QName parentQName = mock(QName.class);
final ItemDefinition itemDefinition = makeItemDefinition();
final Name name = mock(Name.class);
final List<ItemDefinition> itemDefinitions = singletonList(itemDefinition);
when(name.getValue()).thenReturn(nameValue);
when(itemDefinition.getName()).thenReturn(name);
when(parentQName.getLocalPart()).thenReturn(type);
when(parent.getTypeRef()).thenReturn(parentQName);
when(dataType.getParentUUID()).thenReturn(parentUUID);
when(itemDefinitionStore.get(parentUUID)).thenReturn(parent);
doReturn(itemDefinitions).when(handler).itemDefinitions();
final Optional<ItemDefinition> expectedParent = Optional.empty();
final Optional<ItemDefinition> actualParent = handler.findItemDefinitionParent(dataType);
assertEquals(expectedParent, actualParent);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionRecordEngineTest method testCreate.
@Test
public void testCreate() {
final DataType dataType = mock(DataType.class);
final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
when(itemDefinitionCreateHandler.appendItemDefinition()).thenReturn(itemDefinition);
when(dataTypeCreateHandler.append(dataType, itemDefinition)).thenReturn(expectedAffectedDataTypes);
final List<DataType> actualAffectedDataTypes = recordEngine.create(dataType);
assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionRecordEngineTest method testDoUpdate.
@Test
public void testDoUpdate() {
final DataType dataType = mock(DataType.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
recordEngine.doUpdate(dataType, itemDefinition);
verify(dataTypeUpdateHandler).update(dataType);
verify(itemDefinitionUpdateHandler).update(dataType, itemDefinition);
}
use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.
the class ItemDefinitionRecordEngineTest method testUpdate.
@Test
public void testUpdate() {
final String uuid = "uuid";
final String nameValue = "nameValue";
final DataType dataType = mock(DataType.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final Name name = mock(Name.class);
final List<DataType> expectedDependentDataTypes = asList(mock(DataType.class), mock(DataType.class));
when(dataType.isValid()).thenReturn(true);
when(dataType.getUUID()).thenReturn(uuid);
when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
when(itemDefinition.getName()).thenReturn(name);
when(name.getValue()).thenReturn(nameValue);
when(dataTypeUpdateHandler.refreshDependentDataTypes(dataType, nameValue)).thenReturn(expectedDependentDataTypes);
final List<DataType> actualDependentDataTypes = recordEngine.update(dataType);
verify(recordEngine).doUpdate(dataType, itemDefinition);
assertEquals(expectedDependentDataTypes, actualDependentDataTypes);
}
Aggregations