use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class IncludedModelErrorMessageFactoryTest method testGetNameIsBlankFlashMessage.
@Test
public void testGetNameIsBlankFlashMessage() {
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(translationService.format(IncludedModelNameIsBlankErrorMessage_StrongMessage)).thenReturn(expectedStrongMessage);
when(translationService.format(IncludedModelNameIsBlankErrorMessage_RegularMessage)).thenReturn(expectedRegularMessage);
final FlashMessage flashMessage = factory.getNameIsBlankFlashMessage(includedModel);
assertEquals(expectedType, flashMessage.getType());
assertEquals(expectedStrongMessage, flashMessage.getStrongMessage());
assertEquals(expectedRegularMessage, flashMessage.getRegularMessage());
assertEquals(expectedElementSelector, flashMessage.getElementSelector());
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class ImportRecordEngineTest method testIsValidWhenNameIsUnique.
@Test
public void testIsValidWhenNameIsUnique() {
final BaseIncludedModelActiveRecord record = mock(BaseIncludedModelActiveRecord.class);
final Import import1 = mock(Import.class);
final Import import2 = mock(Import.class);
final Name name1 = mock(Name.class);
final Name name2 = mock(Name.class);
final FlashMessage flashMessage = mock(FlashMessage.class);
final List<Import> imports = new ArrayList<>(asList(import1, import2));
when(name1.getValue()).thenReturn("file1");
when(name2.getValue()).thenReturn("file2");
when(record.getName()).thenReturn("file-new");
when(import1.getName()).thenReturn(name1);
when(import2.getName()).thenReturn(name2);
when(includedModelsIndex.getImport(record)).thenReturn(import2);
when(stateProvider.getImports()).thenReturn(imports);
when(messageFactory.getNameIsNotUniqueFlashMessage(record)).thenReturn(flashMessage);
final boolean valid = recordEngine.isValid(record);
assertTrue(valid);
verifyZeroInteractions(flashMessageEvent);
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class ImportRecordEngineTest method testIsValidWhenNameIsUnchanged.
@Test
public void testIsValidWhenNameIsUnchanged() {
final BaseIncludedModelActiveRecord record = mock(BaseIncludedModelActiveRecord.class);
final Import import1 = mock(Import.class);
final Import import2 = mock(Import.class);
final Name name1 = mock(Name.class);
final Name name2 = mock(Name.class);
final FlashMessage flashMessage = mock(FlashMessage.class);
final List<Import> imports = new ArrayList<>(asList(import1, import2));
when(name1.getValue()).thenReturn("file1");
when(name2.getValue()).thenReturn("file2");
when(record.getName()).thenReturn("file2");
when(import1.getName()).thenReturn(name1);
when(import2.getName()).thenReturn(name2);
when(includedModelsIndex.getImport(record)).thenReturn(import2);
when(stateProvider.getImports()).thenReturn(imports);
when(messageFactory.getNameIsNotUniqueFlashMessage(record)).thenReturn(flashMessage);
final boolean valid = recordEngine.isValid(record);
assertTrue(valid);
verifyZeroInteractions(flashMessageEvent);
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class ImportRecordEngineTest method testIsValidWhenNameIsBlank.
@Test
public void testIsValidWhenNameIsBlank() {
final BaseIncludedModelActiveRecord record = mock(BaseIncludedModelActiveRecord.class);
final Import anImport = mock(Import.class);
final Name name = mock(Name.class);
final FlashMessage flashMessage = mock(FlashMessage.class);
final List<Import> imports = new ArrayList<>(singletonList(anImport));
when(name.getValue()).thenReturn("file");
when(record.getName()).thenReturn("");
when(anImport.getName()).thenReturn(name);
when(includedModelsIndex.getImport(record)).thenReturn(anImport);
when(stateProvider.getImports()).thenReturn(imports);
when(messageFactory.getNameIsBlankFlashMessage(record)).thenReturn(flashMessage);
final boolean valid = recordEngine.isValid(record);
assertFalse(valid);
verify(flashMessageEvent).fire(flashMessage);
}
use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.
the class DataTypeConfirmationTest method testIfIsNotReferencedDataTypeWhenCallbackIsNotExecuted.
@Test
public void testIfIsNotReferencedDataTypeWhenCallbackIsNotExecuted() {
final DataType dataType = mock(DataType.class);
final DataType dataType1 = mock(DataType.class);
final DataType dataType2 = mock(DataType.class);
final List<DataType> allDataTypes = asList(dataType1, dataType2);
final FlashMessage warningMessage = mock(FlashMessage.class);
final Command onSuccess = mock(Command.class);
final String tCity = "tCity";
final String tPerson = "tPerson";
when(dataType.getName()).thenReturn(tCity);
when(dataType1.getType()).thenReturn(tCity);
when(dataType2.getType()).thenReturn(tPerson);
when(referencedDataTypeWarningMessage.getFlashMessage(eq(dataType), eq(onSuccess), any())).thenReturn(warningMessage);
when(dataTypeStore.all()).thenReturn(allDataTypes);
confirmation.ifIsNotReferencedDataType(dataType, onSuccess);
verify(onSuccess, never()).execute();
verify(flashMessageEvent).fire(warningMessage);
}
Aggregations