UserEditorWorkflow extends BaseUserEditorWorkflow { void onDeleteUserEvent(@Observes final OnDeleteEvent onDeleteEvent) { if (checkEventContext(onDeleteEvent, userEditor)) { doDelete(); } } @Inject  UserEditorWorkflow(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); @PostConstruct void init(); void show(final String userId);  }
@Test public void testOnDeleteUserEvent() { final OnDeleteEvent onDeleteEvent = mock(OnDeleteEvent.class); when(onDeleteEvent.getContext()).thenReturn(userEditor); tested.user = user; 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.onDeleteUserEvent(onDeleteEvent); verify(confirmBox, times(1)).show(anyString(), anyString(), any(), any()); verify(userManagerService, times(1)).delete(anyString()); }