Search in sources :

Example 26 with DataType

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

the class DataTypeListTest method testMakeTreeListItems.

@Test
public void testMakeTreeListItems() {
    final DataType item1 = makeDataType("item1", "iITem1");
    final DataType item2 = makeDataType("item2", "iITem2");
    final DataType item3 = makeDataType("item", "iITem", item1, item2);
    final List<DataTypeListItem> listItems = dataTypeList.makeTreeListItems(item3, 1);
    verify(dataTypeList).makeTreeListItems(item3, 1);
    verify(dataTypeList).makeTreeListItems(item1, 2);
    verify(dataTypeList).makeTreeListItems(item2, 2);
    assertEquals(3, listItems.size());
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 27 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 testDisableEditMode.

@Test
public void testDisableEditMode() {
    final String expectedTypeText = "type";
    final DataType dataType = makeDataType(expectedTypeText);
    doNothing().when(view).hideSelectPicker();
    when(presenter.getDataType()).thenReturn(dataType);
    typeText.classList = mock(DOMTokenList.class);
    view.disableEditMode();
    assertEquals(expectedTypeText, typeText.textContent);
    verify(typeText.classList).remove(HIDDEN_CSS_CLASS);
    verify(view).hideSelectPicker();
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 28 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 testOnTypeTextClickWhenItsNotBuiltInType.

@Test
public void testOnTypeTextClickWhenItsNotBuiltInType() {
    final ClickEvent event = mock(ClickEvent.class);
    final String type = "tPerson";
    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).show(element, type);
    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 29 with DataType

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

the class DataTypeConfirmationTest method testIfIsNotReferencedDataTypeWhenCallbackIsNotExecuted.

@Test
public void testIfIsNotReferencedDataTypeWhenCallbackIsNotExecuted() {
    final DataType dataType = mock(DataType.class);
    final DataType dataType1 = mock(DataType.class);
    final DataType dataType2 = mock(DataType.class);
    final List<DataType> allDataTypes = asList(dataType1, dataType2);
    final FlashMessage warningMessage = mock(FlashMessage.class);
    final Command onSuccess = mock(Command.class);
    final String tCity = "tCity";
    final String tPerson = "tPerson";
    when(dataType.getName()).thenReturn(tCity);
    when(dataType1.getType()).thenReturn(tCity);
    when(dataType2.getType()).thenReturn(tPerson);
    when(referencedDataTypeWarningMessage.getFlashMessage(eq(dataType), eq(onSuccess), any())).thenReturn(warningMessage);
    when(dataTypeStore.all()).thenReturn(allDataTypes);
    confirmation.ifIsNotReferencedDataType(dataType, onSuccess);
    verify(onSuccess, never()).execute();
    verify(flashMessageEvent).fire(warningMessage);
}
Also used : Command(org.uberfire.mvp.Command) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) Test(org.junit.Test)

Example 30 with DataType

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

the class DataTypeConfirmationTest method testIfIsNotReferencedDataTypeWhenCallbackIsExecuted.

@Test
public void testIfIsNotReferencedDataTypeWhenCallbackIsExecuted() {
    final DataType dataType = mock(DataType.class);
    final DataType dataType1 = mock(DataType.class);
    final DataType dataType2 = mock(DataType.class);
    final List<DataType> allDataTypes = asList(dataType1, dataType2);
    final Command callback = mock(Command.class);
    final String tCity = "tCity";
    final String tPerson = "tPerson";
    final String tDocument = "tDocument";
    when(dataType.getName()).thenReturn(tCity);
    when(dataType1.getType()).thenReturn(tDocument);
    when(dataType2.getType()).thenReturn(tPerson);
    when(dataTypeStore.all()).thenReturn(allDataTypes);
    confirmation.ifIsNotReferencedDataType(dataType, callback);
    verify(callback).execute();
}
Also used : Command(org.uberfire.mvp.Command) 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