use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemViewTest method testSetupReadOnlyCSSClassWhenIsReadOnlyDiagram.
@Test
public void testSetupReadOnlyCSSClassWhenIsReadOnlyDiagram() {
final DataType dataType = mock(DataType.class);
dragAndDropElement.classList = mock(DOMTokenList.class);
when(dataType.isReadOnly()).thenReturn(false);
when(readOnlyProvider.isReadOnlyDiagram()).thenReturn(true);
view.setupReadOnlyCSSClass(dataType);
verify(dragAndDropElement.classList).add("read-only");
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemViewTest method testIsOnFocusModeWhenItReturnsTrue.
@Test
public void testIsOnFocusModeWhenItReturnsTrue() {
final DataType dataType = mock(DataType.class);
final Element dataTypeRow = mock(Element.class);
dataTypeRow.classList = mock(DOMTokenList.class);
doReturn(dataType).when(view).getDataType();
doReturn(dataTypeRow).when(view).getRowElement(dataType);
when(dataTypeRow.classList.contains(FOCUSED_CSS_CLASS)).thenReturn(true);
assertTrue(view.isOnFocusMode());
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class WarningMessageTest method testGetFlashMessage.
@Test
public void testGetFlashMessage() {
final String uuid = "uuid";
final FlashMessage.Type expectedType = WARNING;
final String expectedStrongMessage = "expectedStrongMessage";
final String expectedRegularMessage = "expectedRegularMessage";
final String expectedErrorElementSelector = "[data-row-uuid=\"uuid\"] .bootstrap-select";
final Command expectedOnSuccessCallback = mock(Command.class);
final Command expectedOnErrorCallback = mock(Command.class);
final DataType dataType = mock(DataType.class);
final WarningMessage errorMessage = new WarningMessage(translationService) {
@Override
String getStrongMessage(final DataType dataType) {
return expectedStrongMessage;
}
@Override
String getRegularMessage() {
return expectedRegularMessage;
}
};
when(dataType.getUUID()).thenReturn(uuid);
final FlashMessage flashMessage = errorMessage.getFlashMessage(dataType, expectedOnSuccessCallback, expectedOnErrorCallback);
final FlashMessage.Type actualType = flashMessage.getType();
final String actualStrongMessage = flashMessage.getStrongMessage();
final String actualRegularMessage = flashMessage.getRegularMessage();
final String actualErrorElementSelector = flashMessage.getElementSelector();
final Command actualOnSuccessCallback = flashMessage.getOnSuccess();
final Command actualOnErrorCallback = flashMessage.getOnError();
assertEquals(expectedType, actualType);
assertEquals(expectedStrongMessage, actualStrongMessage);
assertEquals(expectedRegularMessage, actualRegularMessage);
assertEquals(expectedErrorElementSelector, actualErrorElementSelector);
assertEquals(expectedOnSuccessCallback, actualOnSuccessCallback);
assertEquals(expectedOnErrorCallback, actualOnErrorCallback);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeUpdateHandlerTest method testRefreshSubDataType.
@Test
public void testRefreshSubDataType() {
final DataType dataType = mock(DataType.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final String newType = "newType";
final String type = "type";
final String uuid = "uuid";
when(dataType.getType()).thenReturn(type);
when(dataType.getUUID()).thenReturn(uuid);
when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
when(dataTypeManager.from(dataType)).thenReturn(dataTypeManager);
when(dataTypeManager.withType(newType)).thenReturn(dataTypeManager);
handler.refreshSubDataType(dataType, newType);
final InOrder inOrder = Mockito.inOrder(dataTypeManager, dataTypeManager, recordEngine, handler);
inOrder.verify(dataTypeManager).from(dataType);
inOrder.verify(dataTypeManager).withType(newType);
inOrder.verify(recordEngine).doUpdate(dataType, itemDefinition);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeUpdateHandlerTest method testUpdateWhenDataTypeIsNotStructure.
@Test
public void testUpdateWhenDataTypeIsNotStructure() {
final DataType dataType = mock(DataType.class);
doReturn(false).when(handler).isStructure(dataType);
when(dataTypeManager.from(dataType)).thenReturn(dataTypeManager);
handler.update(dataType);
verify(dataTypeManager).withSubDataTypes(emptyList());
}
Aggregations