Skip to content

Commit

Permalink
Remove deprecated APPLICATION_JSON_UTF8 in favor of APPLICATION_JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
drumonii committed Oct 24, 2019
1 parent f417f05 commit 9b58ed1
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ErrorRestController(ErrorAttributes errorAttributes) {
super(errorAttributes);
}

@RequestMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
Map<String, Object> body = getErrorAttributes(request, false);
HttpStatus status = getStatus(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class JsonAuthenticationFailureHandler implements AuthenticationFailureHa
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
AuthenticationException exception) throws IOException {
response.setStatus(HttpStatus.OK.value());
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());

LoginResponse failedLoginResponse = new FailedLoginResponseBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class JsonAuthenticationSuccessHandler implements AuthenticationSuccessHa
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException {
response.setStatus(HttpStatus.OK.value());
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());

LoginResponse successfulLoginResponse = new SuccessfulLoginResponseBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class JsonLogoutSuccessHandler implements LogoutSuccessHandler {
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws IOException {
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());

LogoutResponse logoutResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void getBuilds() throws Exception {
// qbe
mockMvc.perform(get("{apiPath}/builds", apiPath))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.content").exists())
.andExpect(jsonPath("$.pageable").exists())
.andExpect(jsonPath("$.totalPages").exists())
Expand Down Expand Up @@ -130,7 +130,7 @@ public void getBuild() throws Exception {
// find with existing build Id with attributes
mockMvc.perform(get("{apiPath}/builds/{id}", apiPath, build.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.champion").exists())
.andExpect(jsonPath("$.championId", is(build.getChampionId())))
.andExpect(jsonPath("$.item1").exists())
Expand Down Expand Up @@ -161,7 +161,7 @@ public void saveBuild() throws Exception {

// Save with missing attributes
mockMvc.perform(post("{apiPath}/builds", apiPath).with(csrf())
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(build)))
.andExpect(status().isBadRequest());

Expand Down Expand Up @@ -191,11 +191,11 @@ public void saveBuild() throws Exception {

// Save full build
mockMvc.perform(post("{apiPath}/builds", apiPath).with(csrf())
.contentType(MediaType.APPLICATION_JSON_UTF8)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(build)))
.andExpect(status().isCreated())
.andExpect(header().exists("Location"))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.championId", is(build.getChampionId())))
.andExpect(jsonPath("$.item1Id", is(build.getItem1Id())))
.andExpect(jsonPath("$.item2Id", is(build.getItem2Id())))
Expand Down Expand Up @@ -229,7 +229,7 @@ public void countBuild() throws Exception {

mockMvc.perform(get("{apiPath}/builds/count", apiPath))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(content().json(count + ""));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,42 @@ public void getChampions() throws Exception {
// qbe
mockMvc.perform(get("{apiPath}/champions", apiPath))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with name
mockMvc.perform(get("{apiPath}/champions", apiPath)
.param("name", champion.getName().toLowerCase()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with title
mockMvc.perform(get("{apiPath}/champions", apiPath)
.param("title", champion.getTitle().toLowerCase()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with partype
mockMvc.perform(get("{apiPath}/champions", apiPath)
.param("partype", champion.getPartype().toLowerCase()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with tags
mockMvc.perform(get("/api/champions")
.param("tags", champion.getTags().iterator().next()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with no results
mockMvc.perform(get("{apiPath}/champions", apiPath)
.param("name", "abcd1234"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(content().json("[]"));
}

Expand All @@ -105,21 +105,21 @@ public void getChampion() throws Exception {
// find with existing champion Id
mockMvc.perform(get("{apiPath}/champions/{id}", apiPath, poppy.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// find with existing champion name
mockMvc.perform(get("/api/champions/{id}", poppy.getName()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());
}

@Test
public void getTags() throws Exception {
mockMvc.perform(get("{apiPath}/champions/tags", apiPath))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8));
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}

@Test
Expand All @@ -136,7 +136,7 @@ public void trollBuild() throws Exception {
mockMvc.perform(get("{apiPath}/champions/{id}/troll-build", apiPath, azir.getId())
.param("mapId", String.valueOf(HOWLING_ABYSS_ID)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(6)))
Expand All @@ -148,7 +148,7 @@ public void trollBuild() throws Exception {
mockMvc.perform(get("/api/champions/{id}/troll-build", azir.getName())
.param("mapId", String.valueOf(HOWLING_ABYSS_ID)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(6)))
Expand All @@ -159,7 +159,7 @@ public void trollBuild() throws Exception {
// get with champion Id and no map specified
mockMvc.perform(get("{apiPath}/champions/{id}/troll-build", apiPath, azir.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.items.length()", is(6)))
.andExpect(jsonPath("$.summonerSpells").exists())
Expand All @@ -169,7 +169,7 @@ public void trollBuild() throws Exception {
// get with champion name and no map specified
mockMvc.perform(get("/api/champions/{id}/troll-build", azir.getName()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(6)))
Expand All @@ -186,7 +186,7 @@ public void trollBuildForViktor() throws Exception {
mockMvc.perform(get("{apiPath}/champions/{id}/troll-build", apiPath, viktor.getId())
.param("mapId", String.valueOf(HOWLING_ABYSS_ID)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(6)))
Expand All @@ -198,7 +198,7 @@ public void trollBuildForViktor() throws Exception {
mockMvc.perform(get("{apiPath}/champions/{id}/troll-build", apiPath, viktor.getName())
.param("mapId", String.valueOf(HOWLING_ABYSS_ID)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(6)))
Expand All @@ -209,7 +209,7 @@ public void trollBuildForViktor() throws Exception {
// get with Viktor Id and no map specified
mockMvc.perform(get("{apiPath}/champions/{id}/troll-build", apiPath, viktor.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(6)))
Expand All @@ -220,7 +220,7 @@ public void trollBuildForViktor() throws Exception {
// get with Viktor name and no map specified
mockMvc.perform(get("{apiPath}/champions/{id}/troll-build", apiPath, viktor.getName()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(6)))
Expand All @@ -240,7 +240,7 @@ public void trollBuildWithNoItems() throws Exception {
mockMvc.perform(get("{apiPath}/champions/{id}/troll-build", apiPath, orianna.getId())
.param("mapId", String.valueOf(HOWLING_ABYSS_ID)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(0)))
Expand All @@ -252,7 +252,7 @@ public void trollBuildWithNoItems() throws Exception {
mockMvc.perform(get("/api/champions/{id}/troll-build", orianna.getName())
.param("mapId", String.valueOf(HOWLING_ABYSS_ID)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(0)))
Expand All @@ -263,7 +263,7 @@ public void trollBuildWithNoItems() throws Exception {
// get with champion Id and no map specified
mockMvc.perform(get("{apiPath}/champions/{id}/troll-build", apiPath, orianna.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(0)))
Expand All @@ -274,7 +274,7 @@ public void trollBuildWithNoItems() throws Exception {
// get with champion name and no map specified
mockMvc.perform(get("/api/champions/{id}/troll-build", orianna.getName()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.items").exists())
.andExpect(jsonPath("$.totalGold").exists())
.andExpect(jsonPath("$.items.length()", is(0)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,35 @@ public void getItems() throws Exception {
// qbe
mockMvc.perform(get("{apiPath}/items", apiPath))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with name
mockMvc.perform(get("{apiPath}/items", apiPath)
.param("name", item.getName().toLowerCase()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with required champion
mockMvc.perform(get("{apiPath}/items", apiPath)
.param("requiredChampion", item.getRequiredChampion().toLowerCase()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with maps
mockMvc.perform(get("{apiPath}/items", apiPath)
.param("maps[12]", Boolean.TRUE.toString()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with no results
mockMvc.perform(get("{apiPath}/items", apiPath)
.param("name", "abcd1234"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(content().json("[]"));
}

Expand All @@ -99,7 +99,7 @@ public void getItem() throws Exception {
// find with existing item Id
mockMvc.perform(get("{apiPath}/items/{id}", apiPath, sunfireCape.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
}

@Test
Expand All @@ -112,7 +112,7 @@ public void getBoots() throws Exception {
mockMvc.perform(get("{apiPath}/items/boots", apiPath)
.param("mapId", SUMMONERS_RIFT_SID))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].group").exists())
.andExpect(jsonPath("$.[*].from").isNotEmpty())
.andExpect(jsonPath("$.[*].into").exists())
Expand All @@ -131,7 +131,7 @@ public void getTrinkets() throws Exception {
mockMvc.perform(get("{apiPath}/items/trinkets", apiPath)
.param("mapId", SUMMONERS_RIFT_SID))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].group").exists())
.andExpect(jsonPath("$.[*].from").isNotEmpty())
.andExpect(jsonPath("$.[*].into").isNotEmpty())
Expand All @@ -149,7 +149,7 @@ public void getViktorOnly() throws Exception {

mockMvc.perform(get("{apiPath}/items/viktor-only", apiPath))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].from").isNotEmpty())
.andExpect(jsonPath("$.[*].into").isNotEmpty())
.andExpect(jsonPath("$.[*].requiredChampion", hasItem("Viktor")))
Expand All @@ -163,7 +163,7 @@ public void getForTrollBuild() throws Exception {
mockMvc.perform(get("{apiPath}/items/for-troll-build", apiPath)
.param("mapId", SUMMONERS_RIFT_SID))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].from").isNotEmpty())
.andExpect(jsonPath("$.[*].into").isNotEmpty())
.andExpect(jsonPath("$.[*].maps", hasItem(hasEntry(SUMMONERS_RIFT_SID, true))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ public void getGameMaps() throws Exception {
// qbe
mockMvc.perform(get("{apiPath}/maps", apiPath))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with name
mockMvc.perform(get("{apiPath}/maps", apiPath)
.param("mapName", map.getMapName().toLowerCase()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());

// qbe with no results
mockMvc.perform(get("{apiPath}/maps", apiPath)
.param("mapName", "abcd1234"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(content().json("[]"));
}

Expand All @@ -75,15 +75,15 @@ public void getGameMap() throws Exception {
// find with existing map Id
mockMvc.perform(get("{apiPath}/maps/{id}", apiPath, howlingAbyss.getMapId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());
}

@Test
public void getForTrollBuild() throws Exception {
mockMvc.perform(get("{apiPath}/maps/for-troll-build", apiPath))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*]").isNotEmpty());
}

Expand Down
Loading

0 comments on commit 9b58ed1

Please sign in to comment.