use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testEnableEditMode.
@Test
public void testEnableEditMode() {
final DataType dataType = mock(DataType.class);
final String expectedName = "name";
final String expectedType = "type";
final String expectedConstraint = "constraint";
final boolean expectedIsList = true;
final String expectedConstraintType = "";
doReturn(dataType).when(listItem).getDataType();
when(dataType.getName()).thenReturn(expectedName);
when(dataType.getType()).thenReturn(expectedType);
when(dataType.getConstraint()).thenReturn(expectedConstraint);
when(dataType.isList()).thenReturn(expectedIsList);
when(view.isOnFocusMode()).thenReturn(false);
listItem.enableEditMode();
assertEquals(expectedName, listItem.getOldName());
assertEquals(expectedType, listItem.getOldType());
assertEquals(expectedConstraint, listItem.getOldConstraint());
assertEquals(expectedIsList, listItem.getOldIsList());
assertEquals(expectedConstraintType, listItem.getOldConstraintType());
verify(view).showSaveButton();
verify(view).showDataTypeNameInput();
verify(view).enableFocusMode();
verify(view).hideListYesLabel();
verify(view).showListContainer();
verify(dataTypeSelectComponent).enableEditMode();
verify(dataTypeConstraintComponent).enableEditMode();
verify(editModeToggleEvent).fire(eventArgumentCaptor.capture());
verify(dataTypeList).fireOnDataTypeListItemUpdateCallback(listItem);
assertTrue(eventArgumentCaptor.getValue().isEditModeEnabled());
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testInsertNewFieldIfDataTypeIsStructureWhenDataTypeIsStructureButHasFields.
@Test
public void testInsertNewFieldIfDataTypeIsStructureWhenDataTypeIsStructureButHasFields() {
final DataTypeListItem newListItem = mock(DataTypeListItem.class);
final DataType dataType = mock(DataType.class);
final String hash = "hash";
when(newListItem.getDataType()).thenReturn(dataType);
when(dataType.hasSubDataTypes()).thenReturn(true);
when(newListItem.isStructureType()).thenReturn(true);
when(dataTypeList.findItemByDataTypeHash(hash)).thenReturn(Optional.of(newListItem));
listItem.insertNewFieldIfDataTypeIsStructure(hash);
verify(dataTypeList, never()).insertNestedField(Mockito.<String>any());
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testSetupDataType.
@Test
public void testSetupDataType() {
final DataType expectedDataType = this.dataType;
final int expectedLevel = 1;
doNothing().when(listItem).setupDragAndDropComponent();
doNothing().when(listItem).setupView();
listItem.setupDataType(expectedDataType, expectedLevel);
final InOrder inOrder = inOrder(listItem);
inOrder.verify(listItem).setupDragAndDropComponent();
inOrder.verify(listItem).setupSelectComponent();
inOrder.verify(listItem).setupListComponent();
inOrder.verify(listItem).setupConstraintComponent();
inOrder.verify(listItem).setupView();
assertEquals(expectedDataType, listItem.getDataType());
assertEquals(expectedLevel, listItem.getLevel());
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testSaveAndCloseEditModeWhenDataTypeIsValid.
@Test
public void testSaveAndCloseEditModeWhenDataTypeIsValid() {
final DataType dataType = spy(makeDataType());
final DataType updatedDataType = spy(makeDataType());
final Command doSaveAndCloseCommand = mock(Command.class);
final Command doDisableEditMode = mock(Command.class);
doReturn(dataType).when(listItem).getDataType();
doReturn(updatedDataType).when(listItem).updateProperties(dataType);
doReturn(true).when(updatedDataType).isValid();
doReturn(doSaveAndCloseCommand).when(listItem).doValidateDataTypeNameAndSave(updatedDataType);
doReturn(doDisableEditMode).when(listItem).doDisableEditMode();
listItem.saveAndCloseEditMode();
verify(confirmation).ifDataTypeDoesNotHaveLostSubDataTypes(updatedDataType, doSaveAndCloseCommand, doDisableEditMode);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testRefresh.
@Test
public void testRefresh() {
final DataType dataType = spy(makeDataType());
final String expectedConstraint = "constraint";
final String expectedName = "name";
doReturn(expectedConstraint).when(dataType).getConstraint();
doReturn(expectedName).when(dataType).getName();
doReturn(dataType).when(listItem).getDataType();
doNothing().when(listItem).hideTooltips();
listItem.refresh();
verify(dataTypeSelectComponent).refresh();
verify(dataTypeSelectComponent).init(listItem, dataType);
verify(dataTypeConstraintComponent).refreshView();
verify(view).setName(expectedName);
verify(listItem).setupListComponent();
verify(listItem).setupConstraintComponent();
verify(listItem).hideTooltips();
}
Aggregations