Search in sources :

Example 51 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeListItemViewTest method testSetupReadOnlyCSSClassWhenDataTypeHasSubDataTypes.

@Test
public void testSetupReadOnlyCSSClassWhenDataTypeHasSubDataTypes() {
    final DataType dataType = mock(DataType.class);
    dragAndDropElement.classList = mock(DOMTokenList.class);
    when(dataType.isReadOnly()).thenReturn(true);
    view.setupReadOnlyCSSClass(dataType);
    verify(dragAndDropElement.classList).add("read-only");
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 52 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeListItemViewTest method testEnableFocusMode.

@Test
public void testEnableFocusMode() {
    final DataType parentDataType = mock(DataType.class);
    final String parentDataTypeUUID = "parentDataTypeUUID";
    final Element parentElement = mock(Element.class);
    final Element child1 = makeChildElement("child1UUID");
    final Element child2 = makeChildElement("child2UUID");
    final NodeList<Element> children = spy(new NodeList<>());
    when(parentDataType.getUUID()).thenReturn(parentDataTypeUUID);
    when(parentElement.getAttribute("data-row-uuid")).thenReturn(parentDataTypeUUID);
    doReturn(parentDataType).when(view).getDataType();
    doReturn(child1).when(children).getAt(0);
    doReturn(child2).when(children).getAt(1);
    doReturn(nameInput).when(view).getNameInput();
    mockDOMElementByUUID(parentDataTypeUUID, parentElement);
    mockDOMElementsByParentUUID(parentDataTypeUUID, children);
    children.length = 2;
    parentElement.classList = mock(DOMTokenList.class);
    view.enableFocusMode();
    verify(parentElement.classList).add(FOCUSED_CSS_CLASS);
    verify(child1.classList).add(FOCUSED_CSS_CLASS);
    verify(child2.classList).add(FOCUSED_CSS_CLASS);
    verify(nameInput).select();
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 53 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeListViewTest method testRemoveItem.

@Test
public void testRemoveItem() {
    final String uuid = "uuid";
    final DataType dataType = mock(DataType.class);
    final Node parentNode = mock(Node.class);
    final Element dataTypeElement = makeElement(uuid);
    when(dataType.getUUID()).thenReturn(uuid);
    doReturn(dataTypeElement).when(view).getDataTypeRow(dataType);
    doNothing().when(view).cleanSubTypes(Mockito.<String>any());
    dataTypeElement.parentNode = parentNode;
    view.removeItem(dataType);
    verify(presenter).removeItem(uuid);
    verify(view).cleanSubTypes(uuid);
    verify(parentNode).removeChild(dataTypeElement);
    verify(view).showOrHideNoCustomItemsMessage();
}
Also used : Node(elemental2.dom.Node) Element(elemental2.dom.Element) HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 54 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeSelectTest method testGetCustomDataTypes.

@Test
public void testGetCustomDataTypes() {
    final DataType dataType1 = mock(DataType.class);
    final DataType dataType2 = mock(DataType.class);
    final DataType dataType3 = mock(DataType.class);
    final List<DataType> customDataTypes = asList(dataType1, dataType2, dataType3);
    when(dataType1.getName()).thenReturn("tUUID");
    when(dataType2.getName()).thenReturn("tPerson");
    when(dataType3.getName()).thenReturn("tCity");
    when(dataTypeUtils.customDataTypes()).thenReturn(customDataTypes);
    doReturn(dataType2).when(dataTypeSelect).getDataType();
    final List<DataType> actualDataTypes = dataTypeSelect.getCustomDataTypes();
    final List<DataType> expectedDataTypes = asList(dataType1, dataType3);
    assertEquals(expectedDataTypes, actualDataTypes);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 55 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeNameIsInvalidErrorMessageTest method testGetStrongMessage.

@Test
public void testGetStrongMessage() {
    final DataType dataType = mock(DataType.class);
    final String expectedErrorMessage = "*Expected strong message.*";
    final DataTypeNameIsInvalidErrorMessage errorMessage = new DataTypeNameIsInvalidErrorMessage(translationService);
    when(translationService.format(DataTypeNameIsInvalidErrorMessage_StrongMessage)).thenReturn(expectedErrorMessage);
    final String actualErrorMessage = errorMessage.getStrongMessage(dataType);
    assertEquals(expectedErrorMessage, actualErrorMessage);
}
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