diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 4 | ||||
-rw-r--r-- | src/main/resources/juick.sql | 1 | ||||
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 14 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index ce9185d9..5e36093e 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -372,7 +372,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + "messages.readonly, messages.privacy, messages.replies," + "messages.attach, COUNT(DISTINCT favorites.user_id) as likes, messages.hidden," + "GROUP_CONCAT(tags.name SEPARATOR ' '), txt.repliesby, txt.txt, '' as q, messages.updated as updated, 0 as to_uid, " - + "NULL as to_name, txt.updated_at, '' as user_uri, '' as to_uri, '' as reply_uri, 0 as html FROM messages " + + "NULL as to_name, txt.updated_at, '' as reply_user_uri, '' as to_uri, '' as reply_uri, 0 as html FROM messages " + "INNER JOIN users ON messages.user_id = users.id " + "INNER JOIN messages_txt AS txt " + "ON messages.message_id = txt.message_id " @@ -382,7 +382,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + "LEFT JOIN tags ON tags.tag_id=messages_tags.tag_id " + "WHERE messages.message_id = ? " + "GROUP BY mid, rid, replyto, uid, nick, banned, messages.ts, readonly, " - + "privacy, replies, attach, repliesby, q, updated_at, user_uri, to_uri, reply_uri, html", + + "privacy, replies, attach, repliesby, q, updated_at, reply_user_uri, to_uri, reply_uri, html", new MessageMapper(), mid); if (!list.isEmpty()) { diff --git a/src/main/resources/juick.sql b/src/main/resources/juick.sql index a6fb76cd..0067389f 100644 --- a/src/main/resources/juick.sql +++ b/src/main/resources/juick.sql @@ -15,6 +15,7 @@ use juick; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +SET GLOBAL SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; -- -- Table structure for table `ads_messages` -- diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 0039d378..32e9929e 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -258,7 +258,6 @@ public class ServerTests { freefd = userService.getUserByUID(freefdId).orElseThrow(IllegalStateException::new); int juickId = userService.createUser(juickName, juickPassword); juick = userService.getUserByUID(juickId).orElseThrow(IllegalStateException::new); - subscriptionService.subscribeUser(freefd, ugnich); webClient.getOptions().setJavaScriptEnabled(false); isSetUp = true; } @@ -272,6 +271,9 @@ public class ServerTests { } @Test public void getMyFeed() { + jdbcTemplate.execute("DELETE FROM telegram"); + jdbcTemplate.execute("DELETE FROM subscr_users"); + subscriptionService.subscribeUser(freefd, ugnich); int mid0 = messagesService.createMessage(ugnich.getUid(), "test", null, null); int mid2 = messagesService.createMessage(ugnich.getUid(), "test2", null, null); List<Integer> freefdFeed = messagesService.getMyFeed(freefd.getUid(), 0, false); @@ -631,10 +633,12 @@ public class ServerTests { .with(httpBasic(juickName, juickPassword))) .andExpect(status().isOk()) .andReturn(); - List<User> user = jsonMapper.readValue(result.getResponse().getContentAsString(), + List<User> users = jsonMapper.readValue(result.getResponse().getContentAsString(), new TypeReference<List<User>>() { }); - assertThat(user.get(0).getTokens().get(0).getToken(), equalTo(token)); + assertThat(users.size(), is(1)); + assertThat(users.get(0).getTokens().size(), is(1)); + assertThat(users.get(0).getTokens().get(0).getToken(), equalTo(token)); } @Test public void tg2juickLinks() { @@ -991,7 +995,7 @@ public class ServerTests { .stream().noneMatch(m -> m.getTags().contains(banned))); assertTrue(messagesService.getMessages(AnonymousUser.INSTANCE, messagesService.getMyFeed(freefd.getUid(), 0, true)) .stream().noneMatch(m -> m.getTags().contains(banned))); - int newUid = userService.createUser("newUser", "12345"); + int newUid = userService.createUser("newUser1", "12345"); int newMid = messagesService.createMessage(newUid, "people", null, Collections.singletonList(banned)); messagesService.recommendMessage(newMid, ugnich.getUid()); assertTrue(messagesService.getMessages(AnonymousUser.INSTANCE, messagesService.getMyFeed(freefd.getUid(), 0, true)) @@ -1362,6 +1366,7 @@ public class ServerTests { } @Test public void bannedUserShouldBeShadowedFromRecommendationsList() throws IOException { + jdbcTemplate.execute("DELETE FROM bl_users"); int ermineId = userService.createUser("ermine", "secret"); int monstreekId = userService.createUser("monstreek", "secret"); int pogoId = userService.createUser("pogo", "secret"); @@ -1829,6 +1834,7 @@ public class ServerTests { public void seenTests() { Instant now = Instant.now(); int newUserUid = userService.createUser("newuser", "assword"); + assertThat(newUserUid, greaterThanOrEqualTo(0)); assertThat(userService.getUserByUID(newUserUid).get().getSeen(), is(nullValue())); messagesService.createMessage(newUserUid, "YO", "", null); assertThat(userService.getUserByUID(newUserUid).get().getSeen(), greaterThanOrEqualTo(now)); |