From eab80ba585ae61a3ddef7a785a87ead7f39e9efe Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 19 Dec 2017 15:44:50 +0300 Subject: jdbc: do not delete last jid --- .../src/test/java/com/juick/service/MessageServiceTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'juick-server-jdbc/src/test') 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 23e01fd2..d9b0f1c3 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 @@ -170,4 +170,12 @@ public class MessageServiceTest extends AbstractJUnit4SpringContextTests { assertEquals("tags string should be empty", StringUtils.EMPTY, msg4.getTagsString()); messagesService.deleteMessage(user_id, mid4); } + @Test + public void lastJidShouldNotBeDeleted() { + int ugnich_id = userService.createUser("hugnich", "x"); + jdbcTemplate.update("INSERT INTO jids(user_id,jid,active) VALUES(?,?,?)", ugnich_id, "firstjid@localhost", 1); + jdbcTemplate.update("INSERT INTO jids(user_id,jid,active) VALUES(?,?,?)", ugnich_id, "secondjid@localhost", 1); + assertThat(userService.deleteJID(ugnich_id, "secondjid@localhost"), equalTo(true)); + assertThat(userService.deleteJID(ugnich_id, "firstjid@localhost"), equalTo(false)); + } } -- cgit v1.2.3