Search in sources :

Example 81 with DataType

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);
}
Also used : QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Test(org.junit.Test)

Example 82 with DataType

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);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) HTMLLIElement(elemental2.dom.HTMLLIElement) Test(org.junit.Test)

Example 83 with DataType

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);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 84 with DataType

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);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 85 with DataType

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);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Aggregations

DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)274 Test (org.junit.Test)245 HTMLElement (elemental2.dom.HTMLElement)44 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)39 Element (elemental2.dom.Element)30 ArrayList (java.util.ArrayList)26 DOMTokenList (elemental2.dom.DOMTokenList)24 DataTypeListItem (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)14 HTMLDivElement (elemental2.dom.HTMLDivElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 Command (org.uberfire.mvp.Command)12 FlashMessage (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage)9 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)9 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)8 DNDListComponent (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)6 HTMLInputElement (elemental2.dom.HTMLInputElement)6 DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)6