@Override public String toString() { return "OnDeleteEvent [context=" + getContext() + "]"; } }
@Override public String toString() { return "OnDeleteEvent [context=" + getContext() + "]"; } }
@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()); }
@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(Command.class), any(Command.class)); tested.onDeleteUserEvent(onDeleteEvent); verify(confirmBox, times(1)).show(anyString(), anyString(), any(Command.class), any(Command.class)); verify(userManagerService, times(1)).delete(anyString()); }
@Test public void testOnDeleteUserEvent() { 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)); }