@Test public void testNotAllowedDelete() throws Exception { when(toggleCommentPresenter.getComment()).thenReturn("test"); presenter.show((value, callback) -> ((ValidatorWithReasonCallback) callback).onFailure(ValidationErrorReason.NOT_ALLOWED.name()), command); presenter.delete(); verify(command, never()).execute("test"); verify(view).handleDeleteNotAllowed(); }
@Test public void testDeleteWithValidationFailed() throws Exception { when(toggleCommentPresenter.getComment()).thenReturn("test"); presenter.show((value, callback) -> callback.onFailure(), command); presenter.delete(); verify(command, never()).execute("test"); verify(view).handleUnexpectedError(); }
@Test public void testDeleteWithCommand() throws Exception { when(toggleCommentPresenter.getComment()).thenReturn("test"); presenter.show((value, callback) -> callback.onSuccess(), command); presenter.delete(); verify(command).execute("test"); verify(view).hide(); }
public void cancel() { view.hide(); }
public void setPrompt(final String prompt) { view.setPrompt(prompt); }
@PostConstruct public void setup() { view.init(this); }
@PostConstruct public void setup() { view.init(this); }
public void cancel() { view.hide(); }
@Override public void onSuccess() { command.execute(comment); view.hide(); }
@Test public void testShow() throws Exception { presenter.show(validator, command); verify(view).show(); assertEquals(validator, presenter.getValidator()); assertEquals(command, presenter.getCommand()); }
@Override public void onFailure() { view.handleUnexpectedError(); } };
@Override public void onFailure() { view.handleUnexpectedError(); } };
@Test public void testNotAllowedDelete() throws Exception { when(toggleCommentPresenter.getComment()).thenReturn("test"); presenter.show((value, callback) -> ((ValidatorWithReasonCallback) callback).onFailure(ValidationErrorReason.NOT_ALLOWED.name()), command); presenter.delete(); verify(command, never()).execute("test"); verify(view).handleDeleteNotAllowed(); }
@Test public void testSetup() throws Exception { presenter.setup(); verify(view).init(presenter); }
@Override public void onFailure(final String reason) { if (ValidationErrorReason.NOT_ALLOWED.name().equals(reason)) { view.handleDeleteNotAllowed(); } else { view.handleUnexpectedError(); } }
@Override public void onSuccess() { command.execute(comment); view.hide(); }
@Test public void testShow() throws Exception { presenter.show(validator, command); verify(view).show(); assertEquals(validator, presenter.getValidator()); assertEquals(command, presenter.getCommand()); }
@Test public void testPrompt() throws Exception { final String prompt = "any text"; presenter.setPrompt(prompt); verify(view).setPrompt(prompt); }
@Test public void testDeleteWithCommand() throws Exception { when(toggleCommentPresenter.getComment()).thenReturn("test"); presenter.show((value, callback) -> callback.onSuccess(), command); presenter.delete(); verify(command).execute("test"); verify(view).hide(); }
@Test public void testPrompt() throws Exception { final String prompt = "any text"; presenter.setPrompt(prompt); verify(view).setPrompt(prompt); }