BaseUserEditorWorkflow implements IsWidget { protected void checkDirty(final Command callback) { if (isDirty) { confirmBox.show(UsersManagementWidgetsConstants.INSTANCE.confirmAction(), UsersManagementWidgetsConstants.INSTANCE.userIsDirty(), () -> { BaseUserEditorWorkflow.this.isDirty = false; callback.execute(); }, () -> { }); } else { callback.execute(); } } BaseUserEditorWorkflow(final ClientUserSystemManager userSystemManager,
                                  final Event<OnErrorEvent> errorEvent,
                                  final Event<NotificationEvent> workbenchNotification,
                                  final Event<DeleteUserEvent> deleteUserEvent,
                                  final Event<SaveUserEvent> saveUserEvent,
                                  final ConfirmBox confirmBox,
                                  final UserEditor userEditor,
                                  final UserEditorDriver userEditorDriver,
                                  final ChangePassword changePassword,
                                  final LoadingBox loadingBox,
                                  final EntityWorkflowView view); @Override Widget asWidget(); void clear(); UserEditor getUserEditor(); boolean isDirty(); public EntityWorkflowView view; }
@Test public void testCheckDirtyFalse() { final Command command = mock(Command.class); tested.isDirty = false; tested.checkDirty(command); verify(command, times(1)).execute(); assertNoViewCalls(); }
@Test public void testCheckDirtyTrue() { final Command command = mock(Command.class); tested.isDirty = true; tested.checkDirty(command); verify(confirmBox, times(1)).show(anyString(), anyString(), any(), any()); verify(command, times(0)).execute(); assertNoViewCalls(); }