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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations