diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/juick/model/PrivateChats.java | 2 | ||||
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/com/juick/model/PrivateChats.java b/src/main/java/com/juick/model/PrivateChats.java index 7a20ddbc..c480d00a 100644 --- a/src/main/java/com/juick/model/PrivateChats.java +++ b/src/main/java/com/juick/model/PrivateChats.java @@ -17,6 +17,7 @@ package com.juick.model; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Collections; @@ -34,6 +35,7 @@ public class PrivateChats { } @JsonProperty("pms") + @JsonInclude(JsonInclude.Include.ALWAYS) public List<Chat> getUsers() { return users; } 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())); + + } } |