コード例 #1
0
  @Test
  public void loadRepoWithNEvent() {
    when(repo.getModificationId()).thenReturn("modif id");
    IEvent first = mock(IEvent.class);
    IEvent second = mock(IEvent.class);
    IEvent third = mock(IEvent.class);
    // stub sorting order
    when(first.compareTo(second)).thenReturn(-1);
    when(first.compareTo(third)).thenReturn(-1);
    when(second.compareTo(first)).thenReturn(1);
    when(second.compareTo(third)).thenReturn(-1);
    when(third.compareTo(first)).thenReturn(1);
    when(third.compareTo(second)).thenReturn(1);

    // pass the events not sorted:
    List<IEvent> events = Arrays.asList(second, first, third);

    when(repo.getEventsSubscribedOnProperScheduler()).thenReturn(Observable.from(events));
    sut.loadEvents(false, callback);

    // verify we received them in order
    List<IEvent> sortedEvents = Arrays.asList(first, second, third);
    verify(callback).onEventsLoadingStarted("modif id");
    verify(callback).onEventsLoadingFinished(sortedEvents, "modif id");
  }
コード例 #2
0
ファイル: RemoveActionTest.java プロジェクト: lweynant/Yearly
  @Test
  public void remove() {
    RemoveAction sut = new RemoveAction(transaction, eventNotification);
    sut.remove(event);

    verify(transaction).remove(event);
    verify(transaction).commit();
    verify(eventNotification).cancel(event.getID());
  }
コード例 #3
0
ファイル: RemoveActionTest.java プロジェクト: lweynant/Yearly
 @Before
 public void setUp() {
   when(event.getID()).thenReturn(3);
   when(transaction.remove(any(IEvent.class))).thenReturn(transaction);
 }