use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class StructureTypesTooltipTest method testGetTypeFields.
@Test
public void testGetTypeFields() {
final String typeName = "tPerson";
final DataType tPerson = mock(DataType.class);
final DataType name = mock(DataType.class);
final DataType age = mock(DataType.class);
doReturn(typeName).when(presenter).getTypeName();
when(tPerson.getSubDataTypes()).thenReturn(asList(name, age));
when(dataTypeManager.getTopLevelDataTypeWithName(typeName)).thenReturn(Optional.of(tPerson));
final List<DataType> typeFields = presenter.getTypeFields();
assertEquals(2, typeFields.size());
assertTrue(typeFields.contains(name));
assertTrue(typeFields.contains(age));
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeNameFormatValidatorTest method testGetCallbackWhenIsNotValid.
@Test
public void testGetCallbackWhenIsNotValid() {
final DataType dataType = mock(DataType.class);
final Command onSuccess = mock(Command.class);
final FlashMessage flashMessage = mock(FlashMessage.class);
when(nameIsInvalidErrorMessage.getFlashMessage(dataType)).thenReturn(flashMessage);
validator.getCallback(dataType, onSuccess).onSuccess(false);
verify(flashMessageEvent).fire(flashMessage);
verify(onSuccess, never()).execute();
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeNameFormatValidatorTest method testGetCallbackWhenIsValid.
@Test
public void testGetCallbackWhenIsValid() {
final DataType dataType = mock(DataType.class);
final Command onSuccess = mock(Command.class);
final FlashMessage flashMessage = mock(FlashMessage.class);
when(nameIsInvalidErrorMessage.getFlashMessage(dataType)).thenReturn(flashMessage);
validator.getCallback(dataType, onSuccess).onSuccess(true);
verify(onSuccess).execute();
verify(flashMessageEvent, never()).fire(flashMessage);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeStoreTest method testIndex.
@Test
public void testIndex() {
// initial state
assertEquals(1, store.size());
// index new data type
final DataType secondDataType = mock(DataType.class);
final String secondUUID = "789";
store.index(secondUUID, secondDataType);
assertEquals(2, store.size());
assertEquals(dataType, store.get(uuid));
assertEquals(secondDataType, store.get(secondUUID));
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DNDDataTypesHandlerTest method testShiftCurrentByReferenceWhenCurrentIsCollapsedAndItIsTopLevelShiftOperation.
@Test
public void testShiftCurrentByReferenceWhenCurrentIsCollapsedAndItIsTopLevelShiftOperation() {
final DataType current = mock(DataType.class);
final DataType clone = mock(DataType.class);
final DataType reference = mock(DataType.class);
final DataType cloneParent1 = mock(DataType.class);
final DataType cloneParent2 = mock(DataType.class);
final DNDDataTypesHandlerShiftStrategy strategy = INSERT_INTO_HOVERED_DATA_TYPE;
final String referenceHash = "referenceHash";
final String cloneHash = "cloneHash";
final DataTypeListItem oldItem = mock(DataTypeListItem.class);
final DataTypeListItem referenceItem = mock(DataTypeListItem.class);
final DataTypeListItem cloneItem = mock(DataTypeListItem.class);
final HTMLElement cloneHTMLElement = mock(HTMLElement.class);
final String cloneParent1UUID = "cloneParent1UUID";
final String cloneParent2UUID = "cloneParent2UUID";
final DataTypeListItem cloneParent1Item = mock(DataTypeListItem.class);
final DataTypeListItem cloneParent2Item = mock(DataTypeListItem.class);
doReturn(clone).when(handler).cloneDataType(current);
doReturn(true).when(handler).isTopLevelShiftOperation(current, strategy);
when(dataTypeList.calculateHash(reference)).thenReturn(referenceHash);
when(dataTypeList.calculateHash(clone)).thenReturn(cloneHash);
when(dataTypeList.findItem(current)).thenReturn(Optional.of(oldItem));
when(dataTypeList.findItemByDataTypeHash(referenceHash)).thenReturn(Optional.of(referenceItem));
when(dataTypeList.findItemByDataTypeHash(cloneHash)).thenReturn(Optional.of(cloneItem));
when(cloneItem.getDragAndDropElement()).thenReturn(cloneHTMLElement);
when(oldItem.isCollapsed()).thenReturn(true);
when(cloneItem.getDataType()).thenReturn(clone);
when(clone.getParentUUID()).thenReturn(cloneParent1UUID);
when(cloneParent1.getParentUUID()).thenReturn(cloneParent2UUID);
when(cloneParent1.getUUID()).thenReturn(cloneParent1UUID);
when(cloneParent2.getUUID()).thenReturn(cloneParent2UUID);
when(dataTypeStore.get(cloneParent1UUID)).thenReturn(cloneParent1);
when(dataTypeStore.get(cloneParent2UUID)).thenReturn(cloneParent2);
when(dataTypeList.findItem(cloneParent1)).thenReturn(Optional.of(cloneParent1Item));
when(dataTypeList.findItem(cloneParent2)).thenReturn(Optional.of(cloneParent2Item));
handler.shiftCurrentByReference(current, reference, strategy);
verify(cloneItem).collapse();
verify(oldItem).destroyWithoutDependentTypes();
verify(referenceItem).insertNestedField(clone);
verify(dataTypeList).highlightLevel(cloneHTMLElement);
verify(cloneParent1Item).expand();
verify(cloneParent2Item).expand();
}
Aggregations