aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/test/java/com/juick/server')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index a94acc82..a7104931 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -37,6 +37,7 @@ import com.juick.util.DateFormattersHolder;
import com.juick.util.MessageUtils;
import org.apache.commons.codec.CharEncoding;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
@@ -87,13 +88,17 @@ import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
-import java.nio.file.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -1328,24 +1333,26 @@ public class ServerTests {
mockMvc.perform(get("/.well-known/webfinger?resource=acct:ugnich@localhost"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.subject", is("acct:ugnich@localhost")))
- .andExpect(jsonPath("$.links", hasSize(2)))
+ .andExpect(jsonPath("$.links", hasSize(1)))
.andExpect(jsonPath("$.links[0].href", is("http://localhost:8080/u/ugnich")));
mockMvc.perform(get("/.well-known/webfinger?resource=acct:durov@localhost"))
.andExpect(status().isNotFound());
}
@Test
public void userProfileAndBlogShouldBeExposedAsActivityStream() throws Exception {
- mockMvc.perform(get("/u/ugnich").accept(ActivityObject.CONTENT_TYPE))
+ mockMvc.perform(get("/u/ugnich").accept(ActivityObject.LD_JSON_MEDIA_TYPE))
.andExpect(status().isOk())
.andExpect(jsonPath("$.@context", is(ActivityObject.CONTEXT_URI)))
- .andExpect(jsonPath("$.icon", is("http://localhost:8080/i/a/1.png")));
+ .andExpect(jsonPath("$.icon.url", is("http://localhost:8080/i/a/1.png")));
jdbcTemplate.execute("DELETE FROM messages");
- IntStream.rangeClosed(1, 30).forEach(i -> {
- messagesService.createMessage(ugnich.getUid(), String.format("message %d", i), null, null);
- });
- mockMvc.perform(get("/u/ugnich/blog").accept(ActivityObject.CONTENT_TYPE))
+ List<Integer> mids = IteratorUtils.toList(IntStream.rangeClosed(1, 30)
+ .mapToObj(i -> messagesService.createMessage(ugnich.getUid(),
+ String.format("message %d", i), null, null))
+ .collect(Collectors.toCollection(ArrayDeque::new)).descendingIterator());
+ List<Integer> midsPage = mids.stream().limit(20).collect(Collectors.toList());
+ mockMvc.perform(get("/u/ugnich/blog").accept(ActivityObject.ACTIVITY_JSON_MEDIA_TYPE))
.andExpect(status().isOk())
- .andExpect(jsonPath("$.first.orderedItems", hasSize(20)))
- .andExpect(jsonPath("$.first.next.href", is("http://localhost:8080/u/ugnich/blog?before=11")));
+ .andExpect(jsonPath("$.orderedItems", hasSize(20)))
+ .andExpect(jsonPath("$.next.href", is("http://localhost:8080/u/ugnich/blog?before=" + midsPage.get(midsPage.size() - 1))));
}
}