From 5ef424120ed694b1f69daeafaa1454455d13dee2 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 31 Jan 2024 16:50:01 +0300 Subject: CI: enable SQLite * SQLite JDBC driver does not support generated keys feature. So we implement `returningId` helper * only one connection should be used from connection pooler * changes made to prevent connection locking --- src/test/java/com/juick/server/tests/ServerTests.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/test/java/com/juick/server/tests') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 81718cab..64fbd030 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -371,10 +371,7 @@ public class ServerTests { int mid2 = messagesService.createMessage(user.getUid(), "yo2", null, tagList); Message msg2 = messagesService.getMessage(mid2).get(); assertEquals(1, msg2.getTags().size()); - Exception exc = assertThrows(UsernameTakenException.class, () -> { - userService.createUser("ugnicH", "x"); - }); - assertEquals("Username taken", exc.getMessage()); + assertThat(userService.createUser("ugnicH", "x").isEmpty(), is(true)); User hugnich = userService.createUser("hugnich", "x").orElseThrow(IllegalStateException::new); int rid = messagesService.createReply(msg2.getMid(), 0, hugnich, "bla-bla", null); assertEquals(1, rid); @@ -929,7 +926,7 @@ public class ServerTests { @Test public void mailParserTest() throws Exception { emailService.addEmail(ugnich.getUid(), "ugnich@example.com"); - int mid = messagesService.createMessage(ugnich.getUid(), "text", StringUtils.EMPTY, Set.of()); + int mid = messagesService.createMessage(ugnich.getUid(), "text", null, Set.of()); String mail = String.format( "MIME-Version: 1.0\n" + "Received: by 10.176.0.242 with HTTP; Fri, 16 Mar 2018 05:31:50 -0700 (PDT)\n" @@ -1974,7 +1971,7 @@ public class ServerTests { String deleteJsonStr = IOUtils.toString(new ClassPathResource("delete.json").getURI(), StandardCharsets.UTF_8); Delete delete = jsonMapper.readValue(deleteJsonStr, Delete.class); - int mid = messagesService.createMessage(ugnich.getUid(), "YO", "", Set.of()); + int mid = messagesService.createMessage(ugnich.getUid(), "YO", null, Set.of()); User extUser = new User(); extUser.setUri(URI.create("http://localhost:8080/users/xwatt")); int rid = messagesService.createReply(mid, 0, extUser, "PEOPLE", null); @@ -2098,7 +2095,7 @@ public class ServerTests { User newUser = userService.createUser("newuser", "assword").orElseThrow(IllegalStateException::new); assertThat(newUser.getUid(), greaterThanOrEqualTo(0)); assertThat(newUser.getSeen(), is(nullValue())); - messagesService.createMessage(newUser.getUid(), "YO", "", Set.of()); + messagesService.createMessage(newUser.getUid(), "YO", null, Set.of()); assertThat(userService.getUserByUID(newUser.getUid()).get().getSeen(), greaterThanOrEqualTo(now)); } @@ -2255,7 +2252,7 @@ public class ServerTests { @Test public void federatedAttachmentsAsLinks() throws Exception { - int mid = messagesService.createMessage(ugnich.getUid(), "test", StringUtils.EMPTY, Set.of()); + int mid = messagesService.createMessage(ugnich.getUid(), "test", null, Set.of()); Message testMessage = MockUtils.mockMessage(mid, freefd, "reply"); String activity = IOUtils.toString(noteWithDocument.getInputStream(), StandardCharsets.UTF_8); Announce announce = jsonMapper.readValue(activity, Announce.class); @@ -2633,7 +2630,7 @@ public class ServerTests { @Test @Transactional public void isSubscribed() { - int mid = messagesService.createMessage(ugnich.getUid(), "test", "", Collections.emptySet()); + int mid = messagesService.createMessage(ugnich.getUid(), "test", null, Collections.emptySet()); var msg = messagesService.getMessage(ugnich.getUid(), mid).orElseThrow(); assertThat(msg.isSubscribed(), is(false)); subscriptionService.subscribeMessage(msg, ugnich); @@ -2661,7 +2658,7 @@ public class ServerTests { @Test public void messagePrivacyFlow() throws Exception { userService.setPremium(ugnich.getUid(), true); - int mid = messagesService.createMessage(ugnich.getUid(), "hidden", "", Collections.emptySet()); + int mid = messagesService.createMessage(ugnich.getUid(), "hidden", null, Collections.emptySet()); var msg = messagesService.getMessage(ugnich.getUid(), mid).orElseThrow(); assertThat(msg.isFriendsOnly(), is(false)); mockMvc.perform(post("/api/messages/set_privacy?mid=" + mid) -- cgit v1.2.3