@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); }
ServiceCallback<Boolean> getCallback(final DataType dataType, final Command onSuccess) { return new ServiceCallback<Boolean>() { @Override public void onSuccess(final Boolean isValid) { if (isValid) { onSuccess.execute(); } else { flashMessageEvent.fire(nameIsInvalidErrorMessage.getFlashMessage(dataType)); } } @Override public void onError(final ClientRuntimeError error) { clientServicesProxy.logWarning(error); } }; }
DataTypeNameFormatValidator { ServiceCallback<Boolean> getCallback(final DataType dataType, final Command onSuccess) { return new ServiceCallback<Boolean>() { @Override public void onSuccess(final Boolean isValid) { if (isValid) { onSuccess.execute(); } else { flashMessageEvent.fire(nameIsInvalidErrorMessage.getFlashMessage(dataType)); } } @Override public void onError(final ClientRuntimeError error) { clientServicesProxy.logWarning(error); } }; } }
DataTypeNameFormatValidator { ServiceCallback<Boolean> getCallback(final DataType dataType, final Command onSuccess) { return new ServiceCallback<Boolean>() { @Override public void onSuccess(final Boolean isValid) { if (isValid) { onSuccess.execute(); } else { flashMessageEvent.fire(nameIsInvalidErrorMessage.getFlashMessage(dataType)); } } @Override public void onError(final ClientRuntimeError error) { clientServicesProxy.logWarning(error); } }; } @Inject  DataTypeNameFormatValidator(final DMNClientServicesProxy clientServicesProxy,
                                       final Event<FlashMessage> flashMessageEvent,
                                       final DataTypeNameIsInvalidErrorMessage nameIsInvalidErrorMessage); }
DataTypeNameFormatValidator { ServiceCallback<Boolean> getCallback(final DataType dataType, final Command onSuccess) { return new ServiceCallback<Boolean>() { @Override public void onSuccess(final Boolean isValid) { if (isValid) { onSuccess.execute(); } else { flashMessageEvent.fire(nameIsInvalidErrorMessage.getFlashMessage(dataType)); } } @Override public void onError(final ClientRuntimeError error) { clientServicesProxy.logWarning(error); } }; } @Inject  DataTypeNameFormatValidator(final DMNClientServicesProxy clientServicesProxy,
                                       final Event<FlashMessage> flashMessageEvent,
                                       final DataTypeNameIsInvalidErrorMessage nameIsInvalidErrorMessage); void ifIsValid(final DataType dataType,
                          final Command onSuccess); }
DataTypeNameFormatValidator { ServiceCallback<Boolean> getCallback(final DataType dataType, final Command onSuccess) { return new ServiceCallback<Boolean>() { @Override public void onSuccess(final Boolean isValid) { if (isValid) { onSuccess.execute(); } else { flashMessageEvent.fire(nameIsInvalidErrorMessage.getFlashMessage(dataType)); } } @Override public void onError(final ClientRuntimeError error) { clientServicesProxy.logWarning(error); } }; } @Inject  DataTypeNameFormatValidator(final DMNClientServicesProxy clientServicesProxy,
                                       final Event<FlashMessage> flashMessageEvent,
                                       final DataTypeNameIsInvalidErrorMessage nameIsInvalidErrorMessage); void ifIsValid(final DataType dataType,
                          final Command onSuccess);  }