GroupEditorWorkflow implements IsWidget { void onDeleteGroupEvent(@Observes final OnDeleteEvent onDeleteEvent) { if (checkEventContext(onDeleteEvent, groupEditor)) { confirmBox.show(UsersManagementWidgetsConstants.INSTANCE.confirmAction(), UsersManagementWidgetsConstants.INSTANCE.ensureRemoveGroup(), this::delete, () -> { }); } } @Inject  GroupEditorWorkflow(final ClientUserSystemManager userSystemManager,
                               final Caller<AuthorizationService> authorizationService,
                               final PermissionManager permissionManager,
                               final Event<OnErrorEvent> errorEvent,
                               final ConfirmBox confirmBox,
                               final LoadingBox loadingBox,
                               final Event<NotificationEvent> workbenchNotification,
                               final Event<SaveGroupEvent> saveGroupEvent,
                               final Event<DeleteGroupEvent> deleteGroupEvent,
                               final GroupEditor groupEditor,
                               final GroupEditorDriver groupEditorDriver,
                               final EntityWorkflowView view); @PostConstruct void setup(); @Override Widget asWidget(); GroupEditor getGroupEditor(); void show(final String name); void clear(); boolean isDirty(); public EntityWorkflowView view; }
@Test public void testOnDeleteGroupEvent() { final OnDeleteEvent onDeleteEvent = mock(OnDeleteEvent.class); when(onDeleteEvent.getContext()).thenReturn(groupEditor); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocationOnMock) throws Throwable { final Command callback = (Command) invocationOnMock.getArguments()[2]; callback.execute(); return null; } }).when(confirmBox).show(anyString(), anyString(), any(), any()); tested.group = group; tested.onDeleteGroupEvent(onDeleteEvent); verify(confirmBox, times(1)).show(anyString(), anyString(), any(), any()); verify(deleteGroupEvent, times(1)).fire(any(DeleteGroupEvent.class)); verify(workbenchNotification, times(1)).fire(any(NotificationEvent.class)); }