use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class DataTypeNameValidatorTest method testIsValidWhenDataTypeNameIsDefault.
@Test
public void testIsValidWhenDataTypeNameIsDefault() {
final DataType dataType = mock(DataType.class);
final FlashMessage nameIsDefaultMessage = mock(FlashMessage.class);
doReturn(false).when(validator).isBlank(dataType);
doReturn(false).when(validator).isNotUnique(dataType);
doReturn(true).when(validator).isDefault(dataType);
when(nameIsDefaultTypeMessage.getFlashMessage(dataType)).thenReturn(nameIsDefaultMessage);
final boolean isValid = validator.isValid(dataType);
verify(flashMessageEvent).fire(nameIsDefaultMessage);
assertFalse(isValid);
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class DataTypeConfirmationTest method testIfDataTypeDoesNotHaveLostSubDataTypesWhenItemDefinitionItemComponentIsNotEmpty.
@Test
public void testIfDataTypeDoesNotHaveLostSubDataTypesWhenItemDefinitionItemComponentIsNotEmpty() {
final DataType dataType = mock(DataType.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final List<ItemDefinition> itemComponent = singletonList(mock(ItemDefinition.class));
final Command onSuccess = mock(Command.class);
final Command onError = mock(Command.class);
final FlashMessage warningMessage = mock(FlashMessage.class);
final String uuid = "uuid";
when(dataType.getUUID()).thenReturn(uuid);
when(dataType.getType()).thenReturn("tCity");
when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
when(itemDefinition.getItemComponent()).thenReturn(itemComponent);
when(dataTypeHasFieldsWarningMessage.getFlashMessage(dataType, onSuccess, onError)).thenReturn(warningMessage);
confirmation.ifDataTypeDoesNotHaveLostSubDataTypes(dataType, onSuccess, onError);
verify(onSuccess, never()).execute();
verify(flashMessageEvent).fire(warningMessage);
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class DataTypeNameValidatorTest method testIsValidWhenDataTypeNameIsNotUnique.
@Test
public void testIsValidWhenDataTypeNameIsNotUnique() {
final DataType dataType = mock(DataType.class);
final FlashMessage notUniqueMessage = mock(FlashMessage.class);
doReturn(false).when(validator).isBlank(dataType);
doReturn(true).when(validator).isNotUnique(dataType);
when(notUniqueErrorMessage.getFlashMessage(dataType)).thenReturn(notUniqueMessage);
final boolean isValid = validator.isValid(dataType);
verify(flashMessageEvent).fire(notUniqueMessage);
assertFalse(isValid);
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class ErrorMessageTest method testGetFlashMessage.
@Test
public void testGetFlashMessage() {
final String uuid = "uuid";
final FlashMessage.Type expectedType = ERROR;
final String expectedStrongMessage = "expectedStrongMessage";
final String expectedRegularMessage = "expectedRegularMessage";
final String expectedErrorElementSelector = "[data-row-uuid=\"uuid\"] [data-type-field=\"name-input\"]";
final DataType dataType = mock(DataType.class);
final ErrorMessage errorMessage = new ErrorMessage(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);
final FlashMessage.Type actualType = flashMessage.getType();
final String actualStrongMessage = flashMessage.getStrongMessage();
final String actualRegularMessage = flashMessage.getRegularMessage();
final String actualErrorElementSelector = flashMessage.getElementSelector();
assertEquals(expectedType, actualType);
assertEquals(expectedStrongMessage, actualStrongMessage);
assertEquals(expectedRegularMessage, actualRegularMessage);
assertEquals(expectedErrorElementSelector, actualErrorElementSelector);
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class IncludedModelErrorMessageFactoryTest method testGetNameIsNotUniqueFlashMessage.
@Test
public void testGetNameIsNotUniqueFlashMessage() {
final BaseIncludedModelActiveRecord includedModel = mock(BaseIncludedModelActiveRecord.class);
final Type expectedType = ERROR;
final String expectedStrongMessage = "StrongMessage";
final String expectedRegularMessage = "RegularMessage";
final String expectedElementSelector = "[data-card-uuid=\"1234\"] [data-field=\"title-input\"]";
when(includedModel.getUUID()).thenReturn("1234");
when(includedModel.getName()).thenReturn("file");
when(translationService.format(IncludedModelNameIsNotUniqueErrorMessage_StrongMessage, "file")).thenReturn(expectedStrongMessage);
when(translationService.format(IncludedModelNameIsNotUniqueErrorMessage_RegularMessage)).thenReturn(expectedRegularMessage);
final FlashMessage flashMessage = factory.getNameIsNotUniqueFlashMessage(includedModel);
assertEquals(expectedType, flashMessage.getType());
assertEquals(expectedStrongMessage, flashMessage.getStrongMessage());
assertEquals(expectedRegularMessage, flashMessage.getRegularMessage());
assertEquals(expectedElementSelector, flashMessage.getElementSelector());
}
Aggregations