Search in sources :

Example 16 with FlashMessage

use of org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage in project kie-wb-common by kiegroup.

the class ImportRecordEngineTest method testIsValidWhenNameIsNotUnique.

@Test
public void testIsValidWhenNameIsNotUnique() {
    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("file1");
    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);
    assertFalse(valid);
    verify(flashMessageEvent).fire(flashMessage);
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) ArrayList(java.util.ArrayList) FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 FlashMessage (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage)16 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)9 BaseIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord)6 Command (org.uberfire.mvp.Command)5 ArrayList (java.util.ArrayList)4 Import (org.kie.workbench.common.dmn.api.definition.model.Import)4 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)4 Type (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage.Type)2 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)1