aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/server
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-03 15:28:06 +0300
committerGravatar Vitaly Takmazov2022-12-14 12:57:52 +0300
commit0c0ea8897e64461b1cfa9cd86a939b48f0bdd640 (patch)
treef11c73b8246b0724b26ca08529c3c702e1722d79 /src/test/java/com/juick/server
parent8344ea3e3e652f5307ffb6115d6fdebf638ba098 (diff)
Initial PostgreSQL schema and profile
Diffstat (limited to 'src/test/java/com/juick/server')
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index d80c9251..3a7697e1 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -77,6 +77,7 @@ import java.security.NoSuchProviderException;
import java.security.spec.InvalidKeySpecException;
import java.sql.Timestamp;
import java.time.Instant;
+import java.time.OffsetDateTime;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
@@ -182,7 +183,6 @@ import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
-import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mockito;
@@ -204,7 +204,6 @@ import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
@@ -242,13 +241,11 @@ import ru.sape.SapePageLinks;
/**
* Created by vitalyster on 25.11.2016.
*/
-@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@TestPropertySource(properties = { "ios_app_id=12345678.com.juick.ExampleApp" })
@AutoConfigureMockMvc
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ServerTests {
-
@Inject
private MockMvc mockMvc;
@Inject
@@ -913,8 +910,8 @@ public class ServerTests {
assertThat(yoyoMsg.getNewMessage().get().getTags().stream().findFirst().get(), is(yo));
Message msg2 = yoyoMsg.getNewMessage().get();
int mid = msg2.getMid();
- Timestamp last = jdbcTemplate.queryForObject("SELECT lastmessage FROM users WHERE id=?",
- Timestamp.class,
+ var last = jdbcTemplate.queryForObject("SELECT lastmessage FROM users WHERE id=?",
+ OffsetDateTime.class,
user.getUid());
assertThat(last.toInstant(), equalTo(yoyoMsg.getNewMessage().get().getCreated()));
assertEquals(true,
@@ -960,8 +957,8 @@ public class ServerTests {
URI.create("https://static.juick.com/settings/facebook.png")).getText());
Message reply = messagesService.getReplies(user, mid).stream().filter(m -> m.getRid() == 3).findFirst()
.orElse(new Message());
- Timestamp lastreply = jdbcTemplate.queryForObject("SELECT lastmessage FROM users WHERE id=?",
- Timestamp.class,
+ var lastreply = jdbcTemplate.queryForObject("SELECT lastmessage FROM users WHERE id=?",
+ OffsetDateTime.class,
user.getUid());
assertThat(lastreply.toInstant(), equalTo(reply.getCreated()));
assertEquals(2, reply.getReplyto());
@@ -1536,7 +1533,8 @@ public class ServerTests {
original.getMid());
assertThat(messagesService.deleteMessage(ugnich.getUid(), original.getMid()), is(true));
assertThat(messagesService.getMessageAuthor(original.getMid()), is(archiveUser));
- jdbcTemplate.update("UPDATE messages_txt SET updated_at=? WHERE message_id=?", Instant.now(),
+ jdbcTemplate.update("UPDATE messages_txt SET updated_at=? WHERE message_id=?",
+ Timestamp.from(Instant.now()),
original.getMid());
assertThat(messagesService.deleteMessage(ugnich.getUid(), original.getMid()), is(false));
assertThat(messagesService.deleteMessage(archiveUser.getUid(), original.getMid()), is(true));
@@ -2306,6 +2304,7 @@ public class ServerTests {
@Test
public void XMPPSignupIsDisabled() throws Exception {
+ jdbcTemplate.execute("DELETE FROM jids");
jdbcTemplate.update("INSERT INTO jids(loginhash, jid) VALUES('1', 'test@jid.tld')");
MvcResult formLoginResult = mockMvc
.perform(post("/login").with(csrf()).param("username", ugnichName).param("password",
@@ -2333,8 +2332,8 @@ public class ServerTests {
@Test
public void verifiedUsersTest() {
assertThat(userService.getUserByName("ugnich").isVerified(), is(false));
- jdbcTemplate.update("INSERT INTO telegram(user_id, tg_id) VALUES(?, ?)", ugnich.getUid(),
- "100001866137681");
+ jdbcTemplate.update("INSERT INTO telegram(user_id, tg_id, tg_name) VALUES(?, ?, ?)", ugnich.getUid(),
+ "100001866137681", "tg_test");
assertThat(userService.canDeleteTelegramUser(userService.getUserByName("ugnich")), is(false));
userService.addFacebookState("12345", "http://localhost");
userService.createFacebookUser(12345, "12345", "5678", "ugnich");