Search in sources :

Example 91 with DataType

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

the class ItemDefinitionRecordEngineTest method testCreate.

@Test
public void testCreate() {
    final DataType dataType = mock(DataType.class);
    final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    when(itemDefinitionCreateHandler.appendItemDefinition()).thenReturn(itemDefinition);
    when(dataTypeCreateHandler.append(dataType, itemDefinition)).thenReturn(expectedAffectedDataTypes);
    final List<DataType> actualAffectedDataTypes = recordEngine.create(dataType);
    assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes);
}
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)

Example 92 with DataType

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

the class ItemDefinitionRecordEngineTest method testDoUpdate.

@Test
public void testDoUpdate() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    recordEngine.doUpdate(dataType, itemDefinition);
    verify(dataTypeUpdateHandler).update(dataType);
    verify(itemDefinitionUpdateHandler).update(dataType, itemDefinition);
}
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)

Example 93 with DataType

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

the class ItemDefinitionRecordEngineTest method testUpdate.

@Test
public void testUpdate() {
    final String uuid = "uuid";
    final String nameValue = "nameValue";
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final Name name = mock(Name.class);
    final List<DataType> expectedDependentDataTypes = asList(mock(DataType.class), mock(DataType.class));
    when(dataType.isValid()).thenReturn(true);
    when(dataType.getUUID()).thenReturn(uuid);
    when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
    when(itemDefinition.getName()).thenReturn(name);
    when(name.getValue()).thenReturn(nameValue);
    when(dataTypeUpdateHandler.refreshDependentDataTypes(dataType, nameValue)).thenReturn(expectedDependentDataTypes);
    final List<DataType> actualDependentDataTypes = recordEngine.update(dataType);
    verify(recordEngine).doUpdate(dataType, itemDefinition);
    assertEquals(expectedDependentDataTypes, actualDependentDataTypes);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 94 with DataType

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

the class DataTypeCreateHandlerTest method testAppendWhenNameIsSet.

@Test
public void testAppendWhenNameIsSet() {
    final DataType dataType = mock(DataType.class);
    final DataType updatedDataType = mock(DataType.class);
    final DataTypeManager withDataType = mock(DataTypeManager.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final List<DataType> expectedAffectedDataTypes = asList(mock(DataType.class), mock(DataType.class));
    final String existingName = "existing name";
    when(dataType.getName()).thenReturn(existingName);
    when(dataTypeManager.withDataType(dataType)).thenReturn(withDataType);
    when(recordEngine.update(updatedDataType)).thenReturn(expectedAffectedDataTypes);
    doReturn(updatedDataType).when(handler).updateDataTypeProperties(dataType, TOP_LEVEL_PARENT_UUID, itemDefinition);
    final List<DataType> actualAffectedDataTypes = handler.append(dataType, itemDefinition);
    assertEquals(expectedAffectedDataTypes, actualAffectedDataTypes);
}
Also used : DataTypeManager(org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager) 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)

Example 95 with DataType

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

the class DataTypeCreateHandlerTest method testUpdateDataType.

@Test
public void testUpdateDataType() {
    final String parentUUID = "parentUUID";
    final DataType dataType = mock(DataType.class);
    final DataType expectedUpdateDataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final DataTypeManager dataTypeManagerWithDataType = mock(DataTypeManager.class);
    final DataTypeManager dataTypeManagerWithParentUUID = mock(DataTypeManager.class);
    final DataTypeManager dataTypeManagerWithItemDefinition = mock(DataTypeManager.class);
    final DataTypeManager dataTypeManagerWithIndexedItemDefinition = mock(DataTypeManager.class);
    final DataTypeManager dataTypeManagerWithItemDefinitionSubDataTypes = mock(DataTypeManager.class);
    final DataTypeManager dataTypeManagerWithUniqueName = mock(DataTypeManager.class);
    when(dataTypeManager.withDataType(dataType)).thenReturn(dataTypeManagerWithDataType);
    when(dataTypeManagerWithDataType.withParentUUID(parentUUID)).thenReturn(dataTypeManagerWithParentUUID);
    when(dataTypeManagerWithParentUUID.withItemDefinition(itemDefinition)).thenReturn(dataTypeManagerWithItemDefinition);
    when(dataTypeManagerWithItemDefinition.withIndexedItemDefinition()).thenReturn(dataTypeManagerWithIndexedItemDefinition);
    when(dataTypeManagerWithIndexedItemDefinition.withItemDefinitionSubDataTypes()).thenReturn(dataTypeManagerWithItemDefinitionSubDataTypes);
    when(dataTypeManagerWithItemDefinitionSubDataTypes.withUniqueName()).thenReturn(dataTypeManagerWithUniqueName);
    when(dataTypeManagerWithUniqueName.get()).thenReturn(expectedUpdateDataType);
    final DataType actualUpdatedDataType = handler.updateDataTypeProperties(dataType, parentUUID, itemDefinition);
    assertEquals(expectedUpdateDataType, actualUpdatedDataType);
}
Also used : DataTypeManager(org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager) 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