Search in sources :

Example 41 with DataType

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

the class DataTypeSelectViewTest method testSetDataTypeWhenItsBuiltInType.

@Test
public void testSetDataTypeWhenItsBuiltInType() {
    final String expectedType = "string";
    final DataType dataType = makeDataType(expectedType);
    view.setDataType(dataType);
    final String actualType = view.getValue();
    final String actualTypeText = typeText.textContent;
    assertEquals(expectedType, actualType);
    assertEquals(expectedType, actualTypeText);
    verify(typeText).setAttribute(IS_BUILT_IN_TYPE_ATTR, true);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 42 with DataType

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

the class DataTypeSelectViewTest method testMakeOption.

@Test
public void testMakeOption() {
    final String value = "value";
    final DataType dataType = makeDataType(value);
    final HTMLOptionElement htmlOptionElement = mock(HTMLOptionElement.class);
    doReturn(htmlOptionElement).when(view).makeHTMLOptionElement();
    final HTMLOptionElement option = view.makeOption(dataType, DataType::getName);
    assertEquals(value, option.text);
    assertEquals(value, option.value);
}
Also used : HTMLOptionElement(elemental2.dom.HTMLOptionElement) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 43 with DataType

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

the class DataTypeSelectViewTest method makeDataType.

private DataType makeDataType(final String name) {
    final DataType dataType = spy(new DataType(null));
    doReturn("uuid").when(dataType).getUUID();
    doReturn("parentUUID").when(dataType).getParentUUID();
    doReturn(name).when(dataType).getName();
    doReturn(name).when(dataType).getType();
    return dataType;
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Example 44 with DataType

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

the class DataTypeSelectViewTest method testOnTypeTextClickWhenItsBuiltInType.

@Test
public void testOnTypeTextClickWhenItsBuiltInType() {
    final ClickEvent event = mock(ClickEvent.class);
    final String type = "string";
    final DataType dataType = makeDataType(type);
    final HTMLElement element = mock(HTMLElement.class);
    when(presenter.getDataType()).thenReturn(dataType);
    doReturn(element).when(view).getElement();
    view.onTypeTextClick(event);
    verify(structureTypesTooltip, never()).show(any(), anyString());
    verify(event).preventDefault();
    verify(event).stopPropagation();
}
Also used : HTMLElement(elemental2.dom.HTMLElement) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 45 with DataType

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

the class DataTypesPageTest method testMakeDataType.

@Test
public void testMakeDataType() {
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final DataType expectedDataType = mock(DataType.class);
    when(dataTypeManager.from(itemDefinition)).thenReturn(dataTypeManager);
    when(dataTypeManager.get()).thenReturn(expectedDataType);
    final DataType actualDataType = page.makeDataType(itemDefinition);
    assertEquals(expectedDataType, actualDataType);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) 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