From 48b3585786f463592b67f825394ac62cdeaab787 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 20 Nov 2018 19:36:37 +0300 Subject: Fix tests --- src/test/java/com/juick/server/tests/ServerTests.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 4345d607..0abce093 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -75,6 +75,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; +import org.springframework.util.DigestUtils; import org.springframework.util.FileSystemUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; @@ -438,6 +439,8 @@ public class ServerTests { int mid = result.getNewMessage().get().getMid(); Message msg = messagesService.getMessage(mid).get(); tagService.createTag("ั‚ะตัั‚"); + ClassPathResource defaultAvatar = new ClassPathResource("static/av-96.png"); + String hash = DigestUtils.md5DigestAsHex(IOUtils.toByteArray(defaultAvatar.getInputStream())); mockMvc.perform( get("/api/home") .with(httpBasic(ugnichName, ugnichPassword))) @@ -451,7 +454,8 @@ public class ServerTests { is(String.format("https://i.juick.com/p/%d.png", msg.getMid())))) .andExpect(jsonPath("$[0].attachment.small.url", is(String.format("https://i.juick.com/photos-512/%d.png", msg.getMid())))) - .andExpect(jsonPath("$[0].user.avatar").doesNotExist()); + .andExpect(jsonPath("$[0].user.avatar", + is(String.format("http://localhost:8080/av-96-%s.png", hash)))); } @Test @@ -1437,9 +1441,11 @@ public class ServerTests { } @Test public void userProfileAndBlogShouldBeExposedAsActivityStream() throws Exception { + ClassPathResource defaultAvatar = new ClassPathResource("static/av-96.png"); + String hash = DigestUtils.md5DigestAsHex(IOUtils.toByteArray(defaultAvatar.getInputStream())); mockMvc.perform(get("/u/ugnich").accept(Context.LD_JSON_MEDIA_TYPE)) .andExpect(status().isOk()) - .andExpect(jsonPath("$.icon.url", is("http://localhost:8080/i/a/1.png"))) + .andExpect(jsonPath("$.icon.url", is(String.format("http://localhost:8080/av-96-%s.png", hash)))) .andExpect(jsonPath("$.publicKey.publicKeyPem", is(keystoreManager.getPublicKeyPem()))); jdbcTemplate.execute("DELETE FROM messages"); List mids = IteratorUtils.toList(IntStream.rangeClosed(1, 30) -- cgit v1.2.3