BaseUserEditorWorkflow implements IsWidget { protected void setDirty(final boolean isDirty) { this.isDirty = isDirty; view.setSaveButtonEnabled(isDirty); handleNotifications(); } 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 testSetDirtyTrue() { tested.user = user; tested.setDirty(true); verify(view, times(0)).setCancelButtonVisible(anyBoolean()); verify(view, times(0)).setCallback(any(EntityWorkflowView.Callback.class)); verify(view, times(0)).setSaveButtonText(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); verify(view, times(0)).setSaveButtonVisible(anyBoolean()); verify(view, times(1)).setSaveButtonEnabled(true); verify(view, times(2)).showNotification(anyString()); verify(view, times(1)).clearNotifications(); verify(loadingBox, times(0)).show(); verify(loadingBox, times(0)).hide(); }
@Test public void testSetDirtyFalse() { tested.setDirty(false); verify(view, times(0)).setCancelButtonVisible(anyBoolean()); verify(view, times(0)).setCallback(any(EntityWorkflowView.Callback.class)); verify(view, times(0)).setSaveButtonText(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); verify(view, times(0)).setSaveButtonVisible(anyBoolean()); verify(view, times(1)).setSaveButtonEnabled(false); verify(view, times(0)).showNotification(anyString()); verify(view, times(1)).clearNotifications(); verify(loadingBox, times(0)).show(); verify(loadingBox, times(0)).hide(); }
@Test public void testNotifyEmptyAssignments() { when(userAssignedGroupsExplorer.getValue()).thenReturn(Collections.emptySet()); when(userAssignedRolesExplorer.getValue()).thenReturn(Collections.emptySet()); tested.user = user; tested.setDirty(false); verify(view, times(0)).setCancelButtonVisible(anyBoolean()); verify(view, times(0)).setCallback(any(EntityWorkflowView.Callback.class)); verify(view, times(0)).setSaveButtonText(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); verify(view, times(0)).setSaveButtonVisible(anyBoolean()); verify(view, times(1)).setSaveButtonEnabled(false); verify(view, times(1)).showNotification(anyString()); verify(view, times(1)).clearNotifications(); verify(loadingBox, times(0)).show(); verify(loadingBox, times(0)).hide(); }
@Test public void testNoNeedToNotifyAssignmentsFound() { when(userAssignedGroupsExplorer.getValue()).thenReturn(Collections.singleton(new GroupImpl("g1"))); when(userAssignedRolesExplorer.getValue()).thenReturn(Collections.emptySet()); tested.user = user; tested.setDirty(false); verify(view, times(0)).setCancelButtonVisible(anyBoolean()); verify(view, times(0)).setCallback(any(EntityWorkflowView.Callback.class)); verify(view, times(0)).setSaveButtonText(anyString()); verify(view, times(0)).setWidget(any(IsWidget.class)); verify(view, times(0)).setSaveButtonVisible(anyBoolean()); verify(view, times(1)).setSaveButtonEnabled(false); verify(view, times(0)).showNotification(anyString()); verify(view, times(1)).clearNotifications(); verify(loadingBox, times(0)).show(); verify(loadingBox, times(0)).hide(); }