use of org.kie.workbench.common.dmn.client.editors.types.common.DataType 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.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class StructureTypesTooltipViewTest method testMakeFieldElement.
@Test
public void testMakeFieldElement() {
final DataType field = mock(DataType.class);
final String typeName = "tPerson";
final HTMLLIElement expectedHtmlLiElement = mock(HTMLLIElement.class);
final HTMLLIElement htmlTypeElement = mock(HTMLLIElement.class);
doReturn(expectedHtmlLiElement).when(view).makeHTMLLIElement();
doReturn(htmlTypeElement).when(view).makeTypeElement(field);
when(field.getName()).thenReturn(typeName);
final HTMLLIElement actualHtmlLiElement = view.makeFieldElement(field);
assertSame(expectedHtmlLiElement, actualHtmlLiElement);
assertEquals(typeName, expectedHtmlLiElement.textContent);
verify(expectedHtmlLiElement).appendChild(htmlTypeElement);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeActiveRecordTest method testCreate.
@Test
public void testCreate() {
final DataTypeRecordEngine engine = makeRecordEngine();
final DataType record = spy(new DataType(engine));
final DataType reference = mock(DataType.class);
final List<DataType> expectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
final CreationType creationType = mock(CreationType.class);
doReturn(expectedDataTypes).when(engine).create(record, reference, creationType);
final List<DataType> actualDataTypes = record.create(reference, creationType);
assertEquals(expectedDataTypes, actualDataTypes);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeActiveRecordTest method testDestroyWithoutDependentTypes.
@Test
public void testDestroyWithoutDependentTypes() {
final DataTypeRecordEngine engine = makeRecordEngine();
final DataType record = spy(new DataType(engine));
final List<DataType> expectedDataTypes = singletonList(mock(DataType.class));
doReturn(expectedDataTypes).when(engine).destroyWithoutDependentTypes(record);
final List<DataType> actualDataTypes = record.destroyWithoutDependentTypes();
assertEquals(expectedDataTypes, actualDataTypes);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class ItemDefinitionRecordEngineTest method testDestroy.
@Test
public void testDestroy() {
final DataType dataType = mock(DataType.class);
final List<DataType> expectedDependentDataTypes = asList(mock(DataType.class), mock(DataType.class));
when(dataTypeDestroyHandler.refreshDependentDataTypes(dataType)).thenReturn(expectedDependentDataTypes);
final List<DataType> actualDependentDataTypes = recordEngine.destroy(dataType);
verify(recordEngine).doDestroy(dataType);
assertEquals(expectedDependentDataTypes, actualDependentDataTypes);
}
Aggregations