diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/juick/server/api/Messages.java | 2 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/Notifications.java | 12 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/PM.java | 6 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/Post.java | 4 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/Tags.java | 2 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/Users.java | 8 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/activity/Profile.java | 2 | ||||
-rw-r--r-- | src/test/java/com/juick/FormatterTest.java | 8 | ||||
-rw-r--r-- | src/test/java/com/juick/MessageTest.java | 8 | ||||
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 27 |
10 files changed, 40 insertions, 39 deletions
diff --git a/src/main/java/com/juick/server/api/Messages.java b/src/main/java/com/juick/server/api/Messages.java index 1c9e37ad..f7b8c156 100644 --- a/src/main/java/com/juick/server/api/Messages.java +++ b/src/main/java/com/juick/server/api/Messages.java @@ -49,7 +49,7 @@ import java.util.stream.Collectors; * @author ugnich */ @RestController -@RequestMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) +@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE) public class Messages { private static final ResponseEntity<List<com.juick.Message>> NOT_FOUND = ResponseEntity diff --git a/src/main/java/com/juick/server/api/Notifications.java b/src/main/java/com/juick/server/api/Notifications.java index f2c2d712..72988298 100644 --- a/src/main/java/com/juick/server/api/Notifications.java +++ b/src/main/java/com/juick/server/api/Notifications.java @@ -84,7 +84,7 @@ public class Notifications { } @ApiIgnore - @RequestMapping(value = "/api/notifications", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/notifications", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<User>> doGet( @Visitor User visitor, @RequestParam(required = false, defaultValue = "0") int uid, @@ -119,7 +119,7 @@ public class Notifications { } @ApiIgnore - @RequestMapping(value = "/api/notifications", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/notifications", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Status> doDelete( @Visitor User visitor, @RequestBody List<ExternalToken> list) { @@ -145,7 +145,7 @@ public class Notifications { return ResponseEntity.ok(Status.OK); } @ApiIgnore - @RequestMapping(value = "/api/notifications/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/notifications/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Status> doDeleteTokens( @Visitor User visitor, @RequestBody List<ExternalToken> list) { @@ -172,7 +172,7 @@ public class Notifications { } @ApiIgnore - @RequestMapping(value = "/api/notifications", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/notifications", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public Status doPut( @Visitor User visitor, @RequestBody List<ExternalToken> list) throws IOException { @@ -195,7 +195,7 @@ public class Notifications { } @Deprecated - @RequestMapping(value = "/api/android/register", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/android/register", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public Status doAndroidRegister( @Visitor User visitor, @RequestParam(name = "regid") String regId) { @@ -204,7 +204,7 @@ public class Notifications { } @Deprecated - @RequestMapping(value = "/api/winphone/register", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/winphone/register", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public Status doWinphoneRegister( @Visitor User visitor, @RequestParam(name = "url") String regId) { diff --git a/src/main/java/com/juick/server/api/PM.java b/src/main/java/com/juick/server/api/PM.java index 4a408dce..6e6cdcac 100644 --- a/src/main/java/com/juick/server/api/PM.java +++ b/src/main/java/com/juick/server/api/PM.java @@ -55,7 +55,7 @@ public class PM { @Inject private WebApp webApp; - @RequestMapping(value = "/api/pm", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/pm", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public List<com.juick.Message> doGetPM( @Visitor User visitor, @RequestParam(required = false) String uname) { @@ -73,7 +73,7 @@ public class PM { return msgs; } - @RequestMapping(value = "/api/pm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/pm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public com.juick.Message doPostPM( @Visitor User visitor, @RequestParam String uname, @@ -105,7 +105,7 @@ public class PM { } throw new HttpBadRequestException(); } - @RequestMapping(value = "/api/groups_pms", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/groups_pms", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public PrivateChats doGetGroupsPMs( @Visitor User visitor, @RequestParam(defaultValue = "5") int cnt) { diff --git a/src/main/java/com/juick/server/api/Post.java b/src/main/java/com/juick/server/api/Post.java index 10e19faf..59bd05a7 100644 --- a/src/main/java/com/juick/server/api/Post.java +++ b/src/main/java/com/juick/server/api/Post.java @@ -67,7 +67,7 @@ public class Post { @Inject CommandsManager commandsManager; - @RequestMapping(value = "/api/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.OK) public CommandResult doPostMessage( @Visitor User visitor, @@ -99,7 +99,7 @@ public class Post { return commandsManager.processCommand(visitor, body, attachmentFName); } - @RequestMapping(value = "/api/comment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/comment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public CommandResult doPostComment( @Visitor User visitor, @RequestParam(defaultValue = "0") int mid, diff --git a/src/main/java/com/juick/server/api/Tags.java b/src/main/java/com/juick/server/api/Tags.java index 35f2bc66..2862d883 100644 --- a/src/main/java/com/juick/server/api/Tags.java +++ b/src/main/java/com/juick/server/api/Tags.java @@ -38,7 +38,7 @@ public class Tags { @Inject private TagService tagService; - @RequestMapping(value = "/api/tags", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/tags", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public List<TagStats> tags( @Visitor User visitor, @RequestParam(required = false, defaultValue = "0") int user_id diff --git a/src/main/java/com/juick/server/api/Users.java b/src/main/java/com/juick/server/api/Users.java index 74a720d4..6d7c7a45 100644 --- a/src/main/java/com/juick/server/api/Users.java +++ b/src/main/java/com/juick/server/api/Users.java @@ -81,12 +81,12 @@ public class Users { @Inject private EmailManager emailManager; - @RequestMapping(value = "/api/auth", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/auth", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public String getAuthToken(@Visitor User visitor) { return userService.getHashByUID(visitor.getUid()); } - @RequestMapping(value = "/api/users", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/users", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public List<User> doGetUsers( @Visitor User visitor, @RequestParam(value = "uname", required = false) List<String> unames) { @@ -190,7 +190,7 @@ public class Users { } } - @RequestMapping(value = "/api/users/read", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/users/read", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public List<User> doGetUserRead( @Visitor User visitor, @RequestParam String uname) { @@ -214,7 +214,7 @@ public class Users { throw new HttpNotFoundException(); } - @RequestMapping(value = "/api/users/readers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "/api/users/readers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public List<User> doGetUserReaders( @Visitor User visitor, @RequestParam String uname) { diff --git a/src/main/java/com/juick/server/api/activity/Profile.java b/src/main/java/com/juick/server/api/activity/Profile.java index 77945d6b..88c76a93 100644 --- a/src/main/java/com/juick/server/api/activity/Profile.java +++ b/src/main/java/com/juick/server/api/activity/Profile.java @@ -388,7 +388,7 @@ public class Profile { } return new ResponseEntity<>(CommandResult.fromString("Can not authenticate"), HttpStatus.UNAUTHORIZED); } - @PostMapping(value = "/u/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @PostMapping(value = "/u/", produces = MediaType.APPLICATION_JSON_VALUE) public User fetchUser(@RequestParam URI uri) { return activityPubManager.personToUser(uri); } diff --git a/src/test/java/com/juick/FormatterTest.java b/src/test/java/com/juick/FormatterTest.java index da9f5d26..8a6bf83f 100644 --- a/src/test/java/com/juick/FormatterTest.java +++ b/src/test/java/com/juick/FormatterTest.java @@ -39,13 +39,13 @@ public class FormatterTest { public void forAnyDateFormatterShouldReturnNotEmptyString() throws Exception { Instant ts = Instant.now(); - assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(isEmptyOrNullString())); - assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(isEmptyOrNullString())); + assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(emptyOrNullString())); + assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(emptyOrNullString())); ts = Instant.ofEpochMilli(RandomUtils.nextLong(1, Long.MAX_VALUE / 10000)); - assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(isEmptyOrNullString())); - assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(isEmptyOrNullString())); + assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(emptyOrNullString())); + assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(emptyOrNullString())); } @Test diff --git a/src/test/java/com/juick/MessageTest.java b/src/test/java/com/juick/MessageTest.java index b4c5f4ab..64d19e13 100644 --- a/src/test/java/com/juick/MessageTest.java +++ b/src/test/java/com/juick/MessageTest.java @@ -129,20 +129,20 @@ public class MessageTest { public void tagsStringShouldBeEmptyIfNoTags() { Message message = new Message(); - assertThat(MessageUtils.getTagsString(message), isEmptyString()); + assertThat(MessageUtils.getTagsString(message), is(emptyString())); message.FriendsOnly = true; - assertThat(MessageUtils.getTagsString(message), isEmptyString()); + assertThat(MessageUtils.getTagsString(message), is(emptyString())); message.Hidden = true; message.ReadOnly = true; - assertThat(MessageUtils.getTagsString(message), isEmptyString()); + assertThat(MessageUtils.getTagsString(message), is(emptyString())); message.setTags(MessageUtils.parseTags(" ")); - assertThat(MessageUtils.getTagsString(message), isEmptyString()); + assertThat(MessageUtils.getTagsString(message), is(emptyString())); } @Test diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 644ff096..f89eca81 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -504,7 +504,7 @@ public class ServerTests { get("/api/home") .with(httpBasic(ugnichName, ugnichPassword))) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$[0].mid", is(msg.getMid()))) .andExpect(jsonPath("$[0].timestamp", is(DateFormattersHolder.getMessageFormatterInstance().format(msg.getCreated())))) @@ -574,7 +574,7 @@ public class ServerTests { .param("uname", "ugnich") .param("uname", "freefd")) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$", hasSize(2))); } @@ -593,7 +593,7 @@ public class ServerTests { mockMvc.perform(get("/api/messages?"+ "hash=" + userIdHash)) .andDo(print()) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect((jsonPath("$[0].reactions[?(@.id == 3)].count", is(Collections.singletonList(1))))) .andExpect((jsonPath("$[0].reactions[?(@.id == 2)].count", @@ -601,7 +601,7 @@ public class ServerTests { mockMvc.perform(get("/api/reactions?hash=" + userIdHash)) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.length()", is(7))); } @@ -660,7 +660,7 @@ public class ServerTests { String token = "123456"; ExternalToken registration = new ExternalToken(null, "apns", token, null); mockMvc.perform(put("/api/notifications").with(httpBasic(ugnichName, ugnichPassword)) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonMapper.writeValueAsBytes(Collections.singletonList(registration)))) .andExpect(status().isOk()); MvcResult result = mockMvc.perform(get("/api/notifications") @@ -685,10 +685,10 @@ public class ServerTests { public void notificationsTokensTest() throws Exception { List<ExternalToken> tokens = Collections.singletonList(new ExternalToken(null, "gcm", "123456", null)); mockMvc.perform(delete("/api/notifications").with(httpBasic(ugnichName, ugnichPassword)) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonMapper.writeValueAsBytes(tokens))).andExpect(status().isForbidden()); mockMvc.perform(delete("/api/notifications").with(httpBasic(juickName, juickPassword)) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(jsonMapper.writeValueAsBytes(tokens))).andExpect(status().isOk()); } @Test @@ -1134,8 +1134,9 @@ public class ServerTests { MvcResult apiResult = mockMvc.perform(get("/api/thread?mid=" + msg.getMid())) .andExpect(status().isOk()) .andReturn(); - List<Message> fromApi = jsonMapper.readValue(apiResult.getResponse().getContentAsString(), - new TypeReference<List<Message>>() {}); + List<Message> fromApi = jsonMapper.readValue(apiResult.getResponse().getContentAsString(StandardCharsets.UTF_8), + new TypeReference<>() { + }); assertThat(fromApi.get(0).getTags(), is(tags)); } @Test @@ -1671,7 +1672,7 @@ public class ServerTests { public void appAssociationsTest() throws Exception { mockMvc.perform((get("/.well-known/apple-app-site-association"))) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.webcredentials.apps[0]", is(appId))); } @Test @@ -1705,7 +1706,7 @@ public class ServerTests { @Test public void swaggerOutput() throws Exception { MvcResult result = mockMvc.perform(get("/v2/api-docs") - .accept(MediaType.APPLICATION_JSON_UTF8)) + .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn(); String outputDir = System.getProperty("io.springfox.staticdocs.outputDir"); @@ -1834,9 +1835,9 @@ public class ServerTests { URI testuserkeyUri = URI.create("https://example.com/u/testuser#main-key"); MockRestServiceServer restServiceServer = MockRestServiceServer.createServer(apClient); restServiceServer.expect(times(3), requestTo(testuserUri)) - .andRespond(withSuccess(testuserResponseString, MediaType.APPLICATION_JSON_UTF8)); + .andRespond(withSuccess(testuserResponseString, MediaType.APPLICATION_JSON)); restServiceServer.expect(times(3), requestTo(testuserkeyUri)) - .andRespond(withSuccess(testuserResponseString, MediaType.APPLICATION_JSON_UTF8)); + .andRespond(withSuccess(testuserResponseString, MediaType.APPLICATION_JSON)); Person testuser = (Person)signatureManager.getContext(testuserUri).get(); Assert.assertThat(testuser.getPublicKey().getPublicKeyPem(), is(testKeystoreManager.getPublicKeyPem())); Instant now2 = Instant.now(); |