diff options
author | Vitaly Takmazov | 2017-12-22 12:35:19 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-12-22 12:35:19 +0300 |
commit | a28f045836c1f0cadbbfcbaf85cb03b7ed643039 (patch) | |
tree | 7c6e86757e53b1abb39a804e2bdc3491a84ad154 /juick-server-jdbc/src/test/java/com | |
parent | 8c95c51f0bc226a2ec277d54154760898ccd6f32 (diff) |
jdbc: write last reply time to message
Diffstat (limited to 'juick-server-jdbc/src/test/java/com')
-rw-r--r-- | juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java | 16 |
1 files changed, 16 insertions, 0 deletions
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())); + } } |