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