@Test public void testCallbackWithDefaultCommand() { CommandWithThrowableDrivenErrorCallback callback = new CommandWithThrowableDrivenErrorCallback(hasBusyIndicator, commands, defaultCommand); callback.error(message, new RuntimeException()); verify(runtimeException).execute(any()); verify(nullPointerException, never()).execute(any()); verify(defaultCommand, never()).execute(any()); verify(hasBusyIndicator, never()).hideBusyIndicator(); callback.error(message, new NullPointerException()); verify(runtimeException).execute(any()); verify(nullPointerException).execute(any()); verify(defaultCommand, never()).execute(any()); verify(hasBusyIndicator, never()).hideBusyIndicator(); callback.error(message, new Exception()); verify(runtimeException).execute(any()); verify(nullPointerException).execute(any()); verify(defaultCommand).execute(any()); verify(hasBusyIndicator, never()).hideBusyIndicator(); }
@Override public boolean error(final Message message, final Throwable throwable) { final Throwable _throwable = (throwable.getCause() == null ? throwable : throwable.getCause()); for (Map.Entry<Class<? extends Throwable>, CommandWithThrowable> e : commands.entrySet()) { if (e.getKey().getName().equals(_throwable.getClass().getName())) { e.getValue().execute(_throwable); return false; } } if (defaultCommand != null) { defaultCommand.execute(throwable); return false; } return super.error(message, throwable); }
CommandWithThrowableDrivenErrorCallback extends HasBusyIndicatorDefaultErrorCallback { @Override public boolean error(final Message message, final Throwable throwable) { final Throwable _throwable = (throwable.getCause() == null ? throwable : throwable.getCause()); for (Map.Entry<Class<? extends Throwable>, CommandWithThrowable> e : commands.entrySet()) { if (e.getKey().getName().equals(_throwable.getClass().getName())) { e.getValue().execute(_throwable); return false; } } if (defaultCommand != null) { defaultCommand.execute(throwable); return false; } return super.error(message, throwable); } }
CommandWithThrowableDrivenErrorCallback extends HasBusyIndicatorDefaultErrorCallback { @Override public boolean error(final Message message, final Throwable throwable) { final Throwable _throwable = (throwable.getCause() == null ? throwable : throwable.getCause()); for (Map.Entry<Class<? extends Throwable>, CommandWithThrowable> e : commands.entrySet()) { if (e.getKey().getName().equals(_throwable.getClass().getName())) { e.getValue().execute(_throwable); return false; } } if (defaultCommand != null) { defaultCommand.execute(throwable); return false; } return super.error(message, throwable); } CommandWithThrowableDrivenErrorCallback(final HasBusyIndicator view,
                                                   final Map<Class<? extends Throwable>, CommandWithThrowable> commands);  CommandWithThrowableDrivenErrorCallback(final HasBusyIndicator view,
                                                   final Map<Class<? extends Throwable>, CommandWithThrowable> commands,
                                                   final CommandWithThrowable defaultCommand);  CommandWithThrowableDrivenErrorCallback(HasBusyIndicator view, CommandWithThrowable defaultCommand); }
CommandWithThrowableDrivenErrorCallback extends HasBusyIndicatorDefaultErrorCallback { @Override public boolean error(final Message message, final Throwable throwable) { final Throwable _throwable = (throwable.getCause() == null ? throwable : throwable.getCause()); for (Map.Entry<Class<? extends Throwable>, CommandWithThrowable> e : commands.entrySet()) { if (e.getKey().getName().equals(_throwable.getClass().getName())) { e.getValue().execute(_throwable); return false; } } if (defaultCommand != null) { defaultCommand.execute(throwable); return false; } return super.error(message, throwable); } CommandWithThrowableDrivenErrorCallback(final HasBusyIndicator view,
                                                   final Map<Class<? extends Throwable>, CommandWithThrowable> commands);  CommandWithThrowableDrivenErrorCallback(final HasBusyIndicator view,
                                                   final Map<Class<? extends Throwable>, CommandWithThrowable> commands,
                                                   final CommandWithThrowable defaultCommand);  CommandWithThrowableDrivenErrorCallback(HasBusyIndicator view, CommandWithThrowable defaultCommand); @Override boolean error(final Message message,
                         final Throwable throwable); }
CommandWithThrowableDrivenErrorCallback extends HasBusyIndicatorDefaultErrorCallback { @Override public boolean error(final Message message, final Throwable throwable) { final Throwable _throwable = (throwable.getCause() == null ? throwable : throwable.getCause()); for (Map.Entry<Class<? extends Throwable>, CommandWithThrowable> e : commands.entrySet()) { if (e.getKey().getName().equals(_throwable.getClass().getName())) { e.getValue().execute(_throwable); return false; } } if (defaultCommand != null) { defaultCommand.execute(throwable); return false; } return super.error(message, throwable); } CommandWithThrowableDrivenErrorCallback(final HasBusyIndicator view,
                                                   final Map<Class<? extends Throwable>, CommandWithThrowable> commands);  CommandWithThrowableDrivenErrorCallback(final HasBusyIndicator view,
                                                   final Map<Class<? extends Throwable>, CommandWithThrowable> commands,
                                                   final CommandWithThrowable defaultCommand);  CommandWithThrowableDrivenErrorCallback(HasBusyIndicator view, CommandWithThrowable defaultCommand); @Override boolean error(final Message message,
                         final Throwable throwable);  }