From: David ‘Bombe’ Roden Date: Fri, 31 Jul 2015 14:50:37 +0000 (+0200) Subject: Add test for reply sorter X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fd936f56bc88ffea49bb81baf9c113fe933b14a2;p=Sone.git Add test for reply sorter --- diff --git a/src/test/java/net/pterodactylus/sone/data/ReplyTest.java b/src/test/java/net/pterodactylus/sone/data/ReplyTest.java new file mode 100644 index 0000000..0410ac6 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/data/ReplyTest.java @@ -0,0 +1,35 @@ +package net.pterodactylus.sone.data; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.hamcrest.Matchers; +import org.junit.Test; + +/** + * Unit test for the static elements in {@link Reply}. + * + * @author David ‘Bombe’ Roden + */ +public class ReplyTest { + + @Test + public void comparatorSortsRepliesCorrectly() { + Reply reply1 = mock(Reply.class); + when(reply1.getTime()).thenReturn(3000L); + Reply reply2 = mock(Reply.class); + when(reply2.getTime()).thenReturn(2000L); + Reply reply3 = mock(Reply.class); + when(reply3.getTime()).thenReturn(1000L); + List> replies = new ArrayList>(Arrays.>asList(reply1, reply2, reply3)); + Collections.sort(replies, Reply.TIME_COMPARATOR); + assertThat(replies, Matchers.>contains(reply3, reply2, reply1)); + } + +}