Search in sources :

Example 76 with DataType

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

the class DataTypeUpdateHandlerTest method testHandleNestedDataTypeFieldUpdateWhenDataTypeIsStructure.

@Test
public void testHandleNestedDataTypeFieldUpdateWhenDataTypeIsStructure() {
    final DataType dataType = mock(DataType.class);
    final DataType topLevelDataType = mock(DataType.class);
    final DataType dataType0 = mock(DataType.class);
    final DataType dataType1 = mock(DataType.class);
    final DataType dataType2 = mock(DataType.class);
    final List<DataType> dependentDataTypes = asList(dataType0, dataType1, dataType2);
    final String name = "name";
    when(topLevelDataType.getName()).thenReturn(name);
    doReturn(Optional.of(topLevelDataType)).when(handler).getClosestTopLevelDataType(dataType);
    doReturn(dependentDataTypes).when(handler).handleTopLevelDataTypeUpdate(topLevelDataType, name);
    doReturn(true).when(handler).isStructure(dataType);
    final List<DataType> expectedDataTypes = asList(dataType0, dataType1, dataType2, topLevelDataType);
    final List<DataType> actualDataTypes = handler.handleNestedDataTypeFieldUpdate(dataType);
    assertEquals(expectedDataTypes, actualDataTypes);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 77 with DataType

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

the class DataTypeUpdateHandlerTest method testRefreshDependentDataTypes.

@Test
public void testRefreshDependentDataTypes() {
    final DataType dataType = mock(DataType.class);
    final String oldItemDefinitionName = "oldItemDefinitionName";
    final DataType dataType0 = mock(DataType.class);
    final DataType dataType1 = mock(DataType.class);
    final DataType dataType2 = mock(DataType.class);
    final DataType dataType3 = mock(DataType.class);
    doReturn(asList(dataType0, dataType1)).when(handler).handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName);
    doReturn(asList(dataType2, dataType3)).when(handler).handleNestedDataTypeFieldUpdate(dataType);
    final List<DataType> expectedDataTypes = asList(dataType0, dataType1, dataType2, dataType3);
    final List<DataType> actualDataTypes = handler.refreshDependentDataTypes(dataType, oldItemDefinitionName);
    assertEquals(expectedDataTypes, actualDataTypes);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 78 with DataType

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

the class DataTypeUpdateHandlerTest method testUpdateAllChildrenWithTheNewTypeNameWhenDataTypeIsNotTopLevel.

@Test
public void testUpdateAllChildrenWithTheNewTypeNameWhenDataTypeIsNotTopLevel() {
    final DataType topLevelDataType = mock(DataType.class);
    final String oldItemDefinitionName = "oldItemDefinitionName";
    when(topLevelDataType.isTopLevel()).thenReturn(false);
    final List<DataType> expectedDependentDataTypes = emptyList();
    final List<DataType> actualDependentDataTypes = handler.updateAllChildrenWithTheNewTypeName(topLevelDataType, oldItemDefinitionName);
    verify(handler, never()).refreshSubDataType(any(), Mockito.<String>any());
    assertEquals(expectedDependentDataTypes, actualDependentDataTypes);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 79 with DataType

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

the class DataTypeUpdateHandlerTest method testHandleTopLevelDataTypeUpdate.

@Test
public void testHandleTopLevelDataTypeUpdate() {
    final DataType dataType = mock(DataType.class);
    final DataType dataType0 = mock(DataType.class);
    final DataType dataType1 = mock(DataType.class);
    final List<DataType> expectedDataTypes = asList(dataType0, dataType1);
    final String oldItemDefinitionName = "oldItemDefinitionName";
    doReturn(expectedDataTypes).when(handler).updateAllChildrenWithTheNewTypeName(dataType, oldItemDefinitionName);
    final List<DataType> actualDataTypes = handler.handleTopLevelDataTypeUpdate(dataType, oldItemDefinitionName);
    assertEquals(expectedDataTypes, actualDataTypes);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 80 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 testDestroy.

@Test
public void testDestroy() {
    final String uuid = "uuid";
    final String oldItemDefinitionName = "oldItemDefinitionName";
    final DataType dataType = mock(DataType.class);
    final Name name = mock(Name.class);
    final ItemDefinition itemDefinition = makeItemDefinition();
    final ItemDefinition itemDefinitionParent = makeItemDefinition(itemDefinition);
    final List<ItemDefinition> itemDefinitions = new ArrayList<ItemDefinition>() {

        {
            add(itemDefinition);
        }
    };
    when(name.getValue()).thenReturn(oldItemDefinitionName);
    when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
    when(dataType.getUUID()).thenReturn(uuid);
    doReturn(Optional.of(itemDefinitionParent)).when(handler).findItemDefinitionParent(dataType);
    doReturn(name).when(itemDefinition).getName();
    doReturn(itemDefinitions).when(handler).itemDefinitions();
    doNothing().when(handler).notifyPropertiesPanel(Mockito.<String>any());
    handler.destroy(dataType, true);
    assertEquals(emptyList(), itemDefinitionParent.getItemComponent());
    assertEquals(emptyList(), itemDefinitions);
    verify(handler).notifyPropertiesPanel(oldItemDefinitionName);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) ArrayList(java.util.ArrayList) 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)

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