diff options
Diffstat (limited to 'juick-api/src/test')
-rw-r--r-- | juick-api/src/test/java/com/juick/api/tests/MessagesTests.java | 11 |
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 e8045cc2e..b30cdece5 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()); + } } |