diff options
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())); + } } |