use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage 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.common.messages.FlashMessage 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.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class DataTypeListViewTest method testFireSuccessfullyImportedData.
@Test
public void testFireSuccessfullyImportedData() {
final String translated = "translated";
when(translationService.getTranslation(DataTypeSuccessfullyImportedMessage_StrongMessage)).thenReturn(translated);
view.fireSuccessfullyImportedData();
verify(flashMessageEvent).fire(flashMessageCaptor.capture());
final FlashMessage flashMessage = flashMessageCaptor.getValue();
assertEquals(SUCCESS, flashMessage.getType());
assertEquals(translated, flashMessage.getStrongMessage());
assertEquals("", flashMessage.getRegularMessage());
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage 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.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class DataTypeNameValidatorTest method testIsValidWhenDataTypeNameIsBlank.
@Test
public void testIsValidWhenDataTypeNameIsBlank() {
final DataType dataType = mock(DataType.class);
final FlashMessage blankMessage = mock(FlashMessage.class);
doReturn(true).when(validator).isBlank(dataType);
doReturn(true).when(validator).isNotUnique(dataType);
when(blankErrorMessage.getFlashMessage(dataType)).thenReturn(blankMessage);
final boolean isValid = validator.isValid(dataType);
verify(flashMessageEvent).fire(blankMessage);
assertFalse(isValid);
}
Aggregations