From fd936f56bc88ffea49bb81baf9c113fe933b14a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 31 Jul 2015 16:50:37 +0200 Subject: [PATCH] Add test for reply sorter --- .../net/pterodactylus/sone/data/ReplyTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/java/net/pterodactylus/sone/data/ReplyTest.java 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)); + } + +} -- 2.7.4