use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DNDDataTypesHandlerContextTest method testGetStrategyInsertTopLevelDataType.
@Test
public void testGetStrategyInsertTopLevelDataType() {
final Element previousElement = mock(Element.class);
final String uuid = "0000-1111-2222-3333";
final Optional<DataType> previousDataType = Optional.of(mock(DataType.class));
when(dataTypeStore.get(uuid)).thenReturn(previousDataType.get());
when(dndListComponent.getPreviousElement(any(), any())).thenReturn(Optional.of(previousElement));
when(currentElement.getAttribute(DATA_X_POSITION)).thenReturn("0");
when(previousElement.getAttribute(DATA_X_POSITION)).thenReturn("0");
when(previousElement.getAttribute(UUID_ATTR)).thenReturn(uuid);
loadReferenceContext();
final DNDDataTypesHandlerShiftStrategy actualShiftStrategy = context.getStrategy();
final DNDDataTypesHandlerShiftStrategy expectedShiftStrategy = INSERT_TOP_LEVEL_DATA_TYPE;
assertEquals(expectedShiftStrategy, actualShiftStrategy);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DNDDataTypesHandlerContextTest method testGetStrategyInsertSiblingDataType.
@Test
public void testGetStrategyInsertSiblingDataType() {
final Element previousElement = mock(Element.class);
final String uuid = "0000-1111-2222-3333";
final Optional<DataType> previousDataType = Optional.of(mock(DataType.class));
when(dataTypeStore.get(uuid)).thenReturn(previousDataType.get());
when(dndListComponent.getPreviousElement(any(), any())).thenReturn(Optional.of(previousElement));
when(currentElement.getAttribute(DATA_X_POSITION)).thenReturn("1");
when(previousElement.getAttribute(DATA_X_POSITION)).thenReturn("1");
when(previousElement.getAttribute(UUID_ATTR)).thenReturn(uuid);
loadReferenceContext();
final DNDDataTypesHandlerShiftStrategy actualShiftStrategy = context.getStrategy();
final DNDDataTypesHandlerShiftStrategy expectedShiftStrategy = INSERT_SIBLING_DATA_TYPE;
assertEquals(expectedShiftStrategy, actualShiftStrategy);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class ItemDefinitionRecordEngineTest method testDestroyWithoutDependentTypes.
@Test
public void testDestroyWithoutDependentTypes() {
final DataType dataType = mock(DataType.class);
final List<DataType> dependentDataTypes = asList(mock(DataType.class), mock(DataType.class));
when(dataTypeDestroyHandler.refreshDependentDataTypes(dataType)).thenReturn(dependentDataTypes);
final List<DataType> actualDependentDataTypes = recordEngine.destroyWithoutDependentTypes(dataType);
final List<DataType> expectedDependentDataTypes = singletonList(dataType);
verify(dataTypeDestroyHandler).destroy(dataType);
verify(itemDefinitionDestroyHandler).destroy(dataType, false);
assertEquals(expectedDependentDataTypes, actualDependentDataTypes);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class ItemDefinitionRecordEngineTest method testIsValidWhenItIsTrue.
@Test
public void testIsValidWhenItIsTrue() {
final DataType dataType = mock(DataType.class);
doReturn(true).when(dataTypeNameValidator).isValid(dataType);
assertTrue(recordEngine.isValid(dataType));
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class ItemDefinitionRecordEngineTest method testUpdateWhenDataTypeIsNotValid.
@Test
public void testUpdateWhenDataTypeIsNotValid() {
final DataType dataType = mock(DataType.class);
when(dataType.isValid()).thenReturn(false);
assertThatThrownBy(() -> recordEngine.update(dataType)).isInstanceOf(UnsupportedOperationException.class).hasMessageContaining("An invalid Data Type cannot be updated.");
}
Aggregations