Search in sources :

Example 66 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 testCreateNewDataTypeFromProperty.

@Test
public void testCreateNewDataTypeFromProperty() {
    final DataObjectProperty dataProperty = mock(DataObjectProperty.class);
    final String propertyName = "name";
    final String propertyType = "type";
    final DataType newType = mock(DataType.class);
    when(dataProperty.getProperty()).thenReturn(propertyName);
    when(dataProperty.getType()).thenReturn(propertyType);
    when(dataTypeManager.fromNew()).thenReturn(dataTypeManager);
    when(dataTypeManager.asList(anyBoolean())).thenReturn(dataTypeManager);
    when(dataTypeManager.withType(propertyType)).thenReturn(dataTypeManager);
    when(dataTypeManager.get()).thenReturn(newType);
    final DataType actual = dataTypeList.createNewDataType(dataProperty);
    assertEquals(newType, actual);
    verify(dataTypeManager).asList(false);
    verify(newType).setName(propertyName);
}
Also used : DataObjectProperty(org.kie.workbench.common.dmn.api.editors.types.DataObjectProperty) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 67 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 testImportDataObjects.

@Test
public void testImportDataObjects() {
    final DataObject present = mock(DataObject.class);
    final DataObject notPresent = mock(DataObject.class);
    final List<DataObject> selectedDataObjects = asList(present, notPresent);
    final DataType presentDataType = mock(DataType.class);
    final DataType notPresentDataType = mock(DataType.class);
    final String notPresentClass = "not.present";
    final String importedPresentClass = "org.something.MyClass";
    final DataType existingDataType = mock(DataType.class);
    doReturn(presentDataType).when(dataTypeList).createNewDataType(present);
    doReturn(notPresentDataType).when(dataTypeList).createNewDataType(notPresent);
    doReturn(Optional.of(existingDataType)).when(dataTypeList).findDataTypeByName(importedPresentClass);
    doReturn(Optional.empty()).when(dataTypeList).findDataTypeByName(notPresentClass);
    doNothing().when(dataTypeList).replace(existingDataType, presentDataType);
    doNothing().when(dataTypeList).insertProperties(present);
    doNothing().when(dataTypeList).insertProperties(notPresent);
    doNothing().when(dataTypeList).insert(notPresentDataType);
    doNothing().when(dataTypeList).removeFullQualifiedNames(selectedDataObjects);
    when(notPresent.getClassType()).thenReturn(notPresentClass);
    when(present.getClassType()).thenReturn(importedPresentClass);
    dataTypeList.importDataObjects(selectedDataObjects);
    verify(dataTypeList).findDataTypeByName(importedPresentClass);
    verify(dataTypeList).replace(existingDataType, presentDataType);
    verify(dataTypeList).insertProperties(present);
    verify(dataTypeList, never()).insert(presentDataType);
    verify(dataTypeList).insert(notPresentDataType);
    verify(dataTypeList).insertProperties(notPresent);
    verify(dataTypeList).removeFullQualifiedNames(selectedDataObjects);
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 68 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 testSetupSubDataTypesCSSClassWhenDataTypeHasSubDataTypes.

@Test
public void testSetupSubDataTypesCSSClassWhenDataTypeHasSubDataTypes() {
    final DataType dataType = mock(DataType.class);
    dragAndDropElement.classList = mock(DOMTokenList.class);
    when(dataType.hasSubDataTypes()).thenReturn(true);
    view.setupSubDataTypesCSSClass(dataType);
    verify(dragAndDropElement.classList).add("has-sub-data-types");
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 69 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 testSetupSubDataTypesCSSClassWhenDataTypeDoesNotHaveSubDataTypes.

@Test
public void testSetupSubDataTypesCSSClassWhenDataTypeDoesNotHaveSubDataTypes() {
    final DataType dataType = mock(DataType.class);
    dragAndDropElement.classList = mock(DOMTokenList.class);
    when(dataType.hasSubDataTypes()).thenReturn(false);
    view.setupSubDataTypesCSSClass(dataType);
    verify(dragAndDropElement.classList).remove("has-sub-data-types");
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 70 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 testIsOnFocusModeWhenItReturnsFalse.

@Test
public void testIsOnFocusModeWhenItReturnsFalse() {
    final DataType dataType = mock(DataType.class);
    final Element dataTypeRow = mock(Element.class);
    dataTypeRow.classList = mock(DOMTokenList.class);
    doReturn(dataType).when(view).getDataType();
    doReturn(dataTypeRow).when(view).getRowElement(dataType);
    when(dataTypeRow.classList.contains(FOCUSED_CSS_CLASS)).thenReturn(false);
    assertFalse(view.isOnFocusMode());
}
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)

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