@Test public void bothTimestampsAreNull() { InvocationTreeElement e1 = new InvocationTreeElement(mock(InvocationSequenceData.class)); InvocationTreeElement e2 = new InvocationTreeElement(mock(InvocationSequenceData.class)); int result = e1.compareTo(e2); assertThat(result, is(0)); }
@Test public void secondTimeIsNull() { InvocationSequenceData sequence1 = mock(InvocationSequenceData.class); InvocationTreeElement e1 = new InvocationTreeElement(sequence1); InvocationTreeElement e2 = new InvocationTreeElement(mock(InvocationSequenceData.class)); when(sequence1.getTimeStamp()).thenReturn(new Timestamp(10)); int result = e1.compareTo(e2); assertThat(result, is(1)); }
@Test public void firstTimeIsNull() { InvocationSequenceData sequence2 = mock(InvocationSequenceData.class); InvocationTreeElement e1 = new InvocationTreeElement(mock(InvocationSequenceData.class)); InvocationTreeElement e2 = new InvocationTreeElement(sequence2); when(sequence2.getTimeStamp()).thenReturn(new Timestamp(10)); int result = e1.compareTo(e2); assertThat(result, is(-1)); } }
@Test public void descendingTime() { InvocationSequenceData sequence1 = mock(InvocationSequenceData.class); InvocationSequenceData sequence2 = mock(InvocationSequenceData.class); InvocationTreeElement e1 = new InvocationTreeElement(sequence1); InvocationTreeElement e2 = new InvocationTreeElement(sequence2); when(sequence1.getTimeStamp()).thenReturn(new Timestamp(20)); when(sequence2.getTimeStamp()).thenReturn(new Timestamp(10)); int result = e1.compareTo(e2); assertThat(result, is(1)); }
@Test public void equalTime() { InvocationSequenceData sequence1 = mock(InvocationSequenceData.class); InvocationSequenceData sequence2 = mock(InvocationSequenceData.class); InvocationTreeElement e1 = new InvocationTreeElement(sequence1); InvocationTreeElement e2 = new InvocationTreeElement(sequence2); when(sequence1.getTimeStamp()).thenReturn(new Timestamp(10)); when(sequence2.getTimeStamp()).thenReturn(new Timestamp(10)); int result = e1.compareTo(e2); assertThat(result, is(0)); }
@Test public void ascendingTime() { InvocationSequenceData sequence1 = mock(InvocationSequenceData.class); InvocationSequenceData sequence2 = mock(InvocationSequenceData.class); InvocationTreeElement e1 = new InvocationTreeElement(sequence1); InvocationTreeElement e2 = new InvocationTreeElement(sequence2); when(sequence1.getTimeStamp()).thenReturn(new Timestamp(10)); when(sequence2.getTimeStamp()).thenReturn(new Timestamp(20)); int result = e1.compareTo(e2); assertThat(result, is(-1)); }