Search in sources :

Example 6 with FlashMessage

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();
}
Also used : Command(org.uberfire.mvp.Command) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) Test(org.junit.Test)

Example 7 with FlashMessage

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);
}
Also used : Command(org.uberfire.mvp.Command) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) Test(org.junit.Test)

Example 8 with 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());
}
Also used : FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) Test(org.junit.Test)

Example 9 with FlashMessage

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);
}
Also used : Command(org.uberfire.mvp.Command) FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 10 with FlashMessage

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);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) 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