1616@ Sql (executionPhase = ExecutionPhase .BEFORE_TEST_METHOD , scripts = "classpath:sql/prepDefaultData.sql" )
1717@ Sql (executionPhase = ExecutionPhase .BEFORE_TEST_METHOD , scripts = "classpath:sql/prepMapData.sql" )
1818public class MapPoolElideTest extends AbstractIntegrationTest {
19- private static final String NEW_LADDER_MAP_BODY = "{\" data\" :[{\" type\" :\" mapVersion\" ,\" id\" :\" 2\" }]}" ;
19+ private static final String NEW_LADDER_MAP_BODY = """
20+ {
21+ "data": {
22+ "type": "mapPoolAssignment",
23+ "attributes": {
24+ "weight": 1,
25+ "mapParams": "{\\ "type\\ ": \\ "none\\ "}"
26+ },
27+ "relationships": {
28+ "mapPool": {
29+ "data": {
30+ "type": "mapPool",
31+ "id": "1"
32+ }
33+ },
34+ "mapVersion": {
35+ "data": {
36+ "type": "mapVersion",
37+ "id": "1"
38+ }
39+ }
40+ }
41+ }
42+ }""" ;
43+
2044
2145 @ Test
2246 public void cannotCreateMapPoolItemWithoutScope () throws Exception {
2347 mockMvc .perform (
24- post ("/data/mapPool/1/relationships/mapVersions " )
48+ post ("/data/mapPoolAssignment " )
2549 .with (getOAuthTokenWithTestUser (NO_SCOPE , GroupPermission .ROLE_WRITE_MATCHMAKER_MAP ))
2650 .header (HttpHeaders .CONTENT_TYPE , JsonApiMediaType .JSON_API_MEDIA_TYPE )
2751 .content (NEW_LADDER_MAP_BODY )) // magic value from prepMapData.sql
@@ -31,7 +55,7 @@ public void cannotCreateMapPoolItemWithoutScope() throws Exception {
3155 @ Test
3256 public void cannotCreateMapPoolItemWithoutRole () throws Exception {
3357 mockMvc .perform (
34- post ("/data/mapPool/1/relationships/mapVersions " )
58+ post ("/data/mapPoolAssignment " )
3559 .with (getOAuthTokenWithTestUser (OAuthScope ._ADMINISTRATIVE_ACTION , NO_AUTHORITIES ))
3660 .header (HttpHeaders .CONTENT_TYPE , JsonApiMediaType .JSON_API_MEDIA_TYPE )
3761 .content (NEW_LADDER_MAP_BODY )) // magic value from prepMapData.sql
@@ -41,37 +65,34 @@ public void cannotCreateMapPoolItemWithoutRole() throws Exception {
4165 @ Test
4266 public void canCreateMapPoolItemWithScopeAndRole () throws Exception {
4367 mockMvc .perform (
44- post ("/data/mapPool/1/relationships/mapVersions " )
68+ post ("/data/mapPoolAssignment " )
4569 .with (getOAuthTokenWithTestUser (OAuthScope ._ADMINISTRATIVE_ACTION , GroupPermission .ROLE_WRITE_MATCHMAKER_MAP ))
4670 .header (HttpHeaders .CONTENT_TYPE , JsonApiMediaType .JSON_API_MEDIA_TYPE )
4771 .content (NEW_LADDER_MAP_BODY )) // magic value from prepMapData.sql
48- .andExpect (status ().isNoContent ());
72+ .andExpect (status ().isCreated ());
4973 }
5074
5175 @ Test
5276 public void canDeleteMapPoolItemWithScopeAndRole () throws Exception {
5377 mockMvc .perform (
54- delete ("/data/mapPool/1/relationships/mapVersions/1" )
55- .with (getOAuthTokenWithTestUser (OAuthScope ._ADMINISTRATIVE_ACTION , GroupPermission .ROLE_WRITE_MATCHMAKER_MAP ))
56- .content (NEW_LADDER_MAP_BODY )) // magic value from prepMapData.sql
78+ delete ("/data/mapPoolAssignment/1" )
79+ .with (getOAuthTokenWithTestUser (OAuthScope ._ADMINISTRATIVE_ACTION , GroupPermission .ROLE_WRITE_MATCHMAKER_MAP )))
5780 .andExpect (status ().isNoContent ());
5881 }
5982
6083 @ Test
6184 public void cannotDeleteMapPoolItemWithoutScope () throws Exception {
6285 mockMvc .perform (
63- delete ("/data/mapPool/1/relationships/mapVersions/1" )
64- .with (getOAuthTokenWithTestUser (NO_SCOPE , GroupPermission .ROLE_WRITE_MATCHMAKER_MAP ))
65- .content (NEW_LADDER_MAP_BODY )) // magic value from prepMapData.sql
86+ delete ("/data/mapPoolAssignment/1" )
87+ .with (getOAuthTokenWithTestUser (NO_SCOPE , GroupPermission .ROLE_WRITE_MATCHMAKER_MAP )))
6688 .andExpect (status ().isForbidden ());
6789 }
6890
6991 @ Test
7092 public void cannotDeleteMapPoolItemWithoutRole () throws Exception {
7193 mockMvc .perform (
72- delete ("/data/mapPool/1" )
73- .with (getOAuthTokenWithTestUser (OAuthScope ._ADMINISTRATIVE_ACTION , NO_AUTHORITIES ))
74- .content (NEW_LADDER_MAP_BODY )) // magic value from prepMapData.sql
94+ delete ("/data/mapPoolAssignment/1" )
95+ .with (getOAuthTokenWithTestUser (OAuthScope ._ADMINISTRATIVE_ACTION , NO_AUTHORITIES )))
7596 .andExpect (status ().isForbidden ());
7697 }
7798}
0 commit comments