From 21927063ea989551613ae35ab4b71c9e880db0a1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 4 Oct 2022 21:45:26 +0300 Subject: Always include empty pms list in `groups_pms` API response --- src/test/java/com/juick/server/tests/ServerTests.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/test/java/com/juick') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 0971f6b1..87617cea 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -32,6 +32,7 @@ import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.startsWith; +import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -2511,7 +2512,8 @@ public class ServerTests { @Test public void invalidMediaTypeTest() throws Exception { - mockMvc.perform(get("/api/messages").header("Accept", "application/xml")).andExpect(status().isBadRequest()) + mockMvc.perform(get("/api/messages") + .header("Accept", "application/xml")).andExpect(status().isBadRequest()) .andExpect(content().string("Invalid media type")); } @@ -2521,4 +2523,14 @@ public class ServerTests { String contextString = jsonMapper.writeValueAsString(context); assertThat(contextString, is("{\"id\":\"http://juick.com/u/ermine\"}")); } + + @Test + public void emptyListForEmptyChatsList() throws Exception { + jdbcTemplate.execute("DELETE FROM pm"); + mockMvc.perform( + get("/api/groups_pms").with(httpBasic(ugnichName, ugnichPassword))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.pms", empty())); + + } } -- cgit v1.2.3