From a28f045836c1f0cadbbfcbaf85cb03b7ed643039 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 22 Dec 2017 12:35:19 +0300 Subject: jdbc: write last reply time to message --- .../test/java/com/juick/service/MessageServiceTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'juick-server-jdbc/src/test/java/com') diff --git a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java index 0f6f7c7a..6bab2b1c 100644 --- a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java +++ b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java @@ -32,12 +32,15 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.inject.Inject; +import java.sql.Timestamp; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertEquals; /** @@ -188,4 +191,17 @@ public class MessageServiceTest extends AbstractJUnit4SpringContextTests { assertThat(emailService.deleteEmail(ugnich_id, "second@localhost"), equalTo(true)); assertThat(emailService.deleteEmail(ugnich_id, "first@localhost"), equalTo(false)); } + @Test + public void messageUpdatedTimeShouldMatchLastReplyTime() { + int ugnich_id = userService.createUser("hugnich4", "x"); + int mid = messagesService.createMessage(ugnich_id, "yo", null, null); + Instant ts = jdbcTemplate.queryForObject("SELECT updated FROM messages WHERE message_id=?", + Timestamp.class, mid).toInstant(); + int rid = messagesService.createReply(mid, 0, ugnich_id, "people", null); + Instant rts = jdbcTemplate.queryForObject("SELECT updated FROM messages WHERE message_id=?", + Timestamp.class, mid).toInstant(); + assertThat(rts, greaterThan(ts)); + Message msg = messagesService.getReply(mid, rid); + assertThat(rts, equalTo(msg.getTimestamp())); + } } -- cgit v1.2.3