-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
1,325 additions
and
310 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/inttest/java/com/faforever/api/data/MapVersionElideTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.faforever.api.data; | ||
|
||
import com.faforever.api.AbstractIntegrationTest; | ||
import org.junit.Test; | ||
import org.springframework.security.test.context.support.WithUserDetails; | ||
import org.springframework.test.context.jdbc.Sql; | ||
import org.springframework.test.context.jdbc.Sql.ExecutionPhase; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:sql/prepDefaultUser.sql") | ||
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:sql/prepMapVersion.sql") | ||
@Sql(executionPhase = ExecutionPhase.AFTER_TEST_METHOD, scripts = "classpath:sql/cleanMapVersion.sql") | ||
public class MapVersionElideTest extends AbstractIntegrationTest { | ||
|
||
private static final String MAP_VERSION_HIDE_FALSE_ID_1 = "{\n" + | ||
" \"data\": {\n" + | ||
" \"type\": \"mapVersion\",\n" + | ||
" \"id\": \"1\",\n" + | ||
" \"attributes\": {\n" + | ||
" \t\"hidden\": false\n" + | ||
" }\n" + | ||
" } \n" + | ||
"}"; | ||
private static final String MAP_VERSION_HIDE_TRUE_ID_1 = "{\n" + | ||
" \"data\": {\n" + | ||
" \"type\": \"mapVersion\",\n" + | ||
" \"id\": \"1\",\n" + | ||
" \"attributes\": {\n" + | ||
" \t\"hidden\": true\n" + | ||
" }\n" + | ||
" } \n" + | ||
"}"; | ||
private static final String MAP_VERSION_RANKED_FALSE_ID_1 = "{\n" + | ||
" \"data\": {\n" + | ||
" \"type\": \"mapVersion\",\n" + | ||
" \"id\": \"1\",\n" + | ||
" \"attributes\": {\n" + | ||
" \t\"ranked\": false\n" + | ||
" }\n" + | ||
" } \n" + | ||
"}"; | ||
private static final String MAP_VERSION_RANKED_TRUE_ID_1 = "{\n" + | ||
" \"data\": {\n" + | ||
" \"type\": \"mapVersion\",\n" + | ||
" \"id\": \"1\",\n" + | ||
" \"attributes\": {\n" + | ||
" \t\"ranked\": true\n" + | ||
" }\n" + | ||
" } \n" + | ||
"}"; | ||
|
||
|
||
@WithUserDetails(AUTH_USER) | ||
@Test | ||
public void testUpdateHideToTrueDoesWork() throws Exception { | ||
mockMvc.perform( | ||
patch("/data/mapVersion/1") | ||
.content(MAP_VERSION_HIDE_TRUE_ID_1)) | ||
.andExpect(status().isNoContent()); | ||
} | ||
|
||
@WithUserDetails(AUTH_USER) | ||
@Test | ||
public void testUpdateHideToFalseDoesNotWork() throws Exception { | ||
mockMvc.perform( | ||
patch("/data/mapVersion/1") | ||
.content(MAP_VERSION_HIDE_FALSE_ID_1)) | ||
.andExpect(status().isForbidden()); | ||
} | ||
|
||
|
||
@WithUserDetails(AUTH_USER) | ||
@Test | ||
public void testUpdateRankedToFalseDoesWork() throws Exception { | ||
mockMvc.perform( | ||
patch("/data/mapVersion/1") | ||
.content(MAP_VERSION_RANKED_FALSE_ID_1)) | ||
.andExpect(status().isNoContent()); | ||
} | ||
|
||
@WithUserDetails(AUTH_USER) | ||
@Test | ||
public void testUpdateRankedToTrueDoesNotWork() throws Exception { | ||
mockMvc.perform( | ||
patch("/data/mapVersion/1") | ||
.content(MAP_VERSION_RANKED_TRUE_ID_1)) | ||
.andExpect(status().isForbidden()); | ||
} | ||
} |
Oops, something went wrong.