aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/test/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-09-25 10:24:59 +0300
committerGravatar Vitaly Takmazov2017-09-25 10:24:59 +0300
commit207e2632a878ff308b30cbf24b0930e7221ffe5c (patch)
treea39d4251836fa02364482386934b8cb07e10f062 /juick-api/src/test/java/com
parenta0fba35796e6dfb1188d716985e1d483bf1098c4 (diff)
api: add timestamp and 404 tests
Diffstat (limited to 'juick-api/src/test/java/com')
-rw-r--r--juick-api/src/test/java/com/juick/api/tests/MessagesTests.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
index e8045cc2..b30cdece 100644
--- a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
+++ b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
@@ -31,6 +31,7 @@ import com.juick.service.MessagesService;
import com.juick.service.TagService;
import com.juick.service.UserService;
import com.juick.test.util.MockUtils;
+import com.juick.util.DateFormattersHolder;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,6 +52,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.socket.client.WebSocketConnectionManager;
import javax.inject.Inject;
+import java.time.Instant;
import java.util.*;
import static org.hamcrest.Matchers.hasSize;
@@ -151,7 +153,8 @@ public class MessagesTests {
String msgText = "Привет, я - Угнич";
Message msg = MockUtils.mockMessage(1, ugnich, msgText);
-
+ Instant now = Instant.now();
+ msg.setTimestamp(now);
when(messagesService.getMyFeed(1, 0, true))
.thenReturn(Collections.singletonList(1));
when(messagesService.getMessages(Collections.singletonList(1)))
@@ -164,6 +167,7 @@ public class MessagesTests {
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("$[0].mid", is(1)))
+ .andExpect(jsonPath("$[0].timestamp", is(DateFormattersHolder.getMessageFormatterInstance().format(now))))
.andExpect(jsonPath("$[0].body", is(msgText)));
}
@@ -288,4 +292,9 @@ public class MessagesTests {
.with(httpBasic(ugnichName, ugnichPassword)))
.andExpect(status().isOk());
}
+ @Test
+ public void threadWithEphemeralNumberShouldReturn404() throws Exception {
+ mockMvc.perform(get("/thread").param("mid", "999999999")
+ .with(httpBasic(ugnichName, ugnichPassword))).andExpect(status().is4xxClientError());
+ }
}