コード例 #1
0
 @Test
 public void shouldNotFailIfUnknownFormat() {
   when(finderByPreviousAnalysis.findByPreviousAnalysis(null))
       .thenReturn(
           new PastSnapshot(
               CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS,
               new Snapshot())); // should not be called
   assertNull(finder.find(null, 2, "foooo"));
 }
コード例 #2
0
  @Test
  public void shouldNotFindPreviousAnalysis() {
    when(finderByPreviousAnalysis.findByPreviousAnalysis(null)).thenReturn(null);

    PastSnapshot variationSnapshot =
        finder.find(null, 2, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);

    verify(finderByPreviousAnalysis).findByPreviousAnalysis(null);

    assertNull(variationSnapshot);
  }
コード例 #3
0
  @Test
  public void shouldFindByPreviousAnalysis() throws ParseException {
    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    final Date date = format.parse("2010-05-18");
    Snapshot snapshot = new Snapshot();
    snapshot.setCreatedAt(date);
    when(finderByPreviousAnalysis.findByPreviousAnalysis(null))
        .thenReturn(new PastSnapshot(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, snapshot));

    PastSnapshot variationSnapshot =
        finder.find(null, 2, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);

    verify(finderByPreviousAnalysis).findByPreviousAnalysis(null);
    assertThat(variationSnapshot.getIndex(), is(2));
    assertThat(variationSnapshot.getMode(), is(CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS));
    assertThat(variationSnapshot.getProjectSnapshot(), not(nullValue()));
  }