Compare commits

..

1 commit

Author SHA1 Message Date
2740cc53be TD-34: Solved comments made by reviewer
All checks were successful
Quality Check / Validate OAS (push) Successful in 33s
Quality Check / Validate OAS (pull_request) Successful in 34s
Quality Check / Testing (push) Successful in 1m13s
Quality Check / Linting (push) Successful in 1m16s
Quality Check / Static Analysis (push) Successful in 1m22s
Quality Check / Static Analysis (pull_request) Successful in 1m15s
Quality Check / Linting (pull_request) Successful in 1m30s
Quality Check / Testing (pull_request) Successful in 50s
2025-02-26 12:37:10 +01:00
2 changed files with 1 additions and 84 deletions

View file

@ -1,83 +0,0 @@
package de.towerdefence.server.server;
import de.towerdefence.server.IntegrationTest;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
class GetAllPlayersPaginatedAndSortedTest extends IntegrationTest {
private MockHttpServletRequestBuilder createGetAllPlayersRequest(String requestBody) {
return MockMvcRequestBuilders.get(baseUri + "/admin/players")
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody);
}
@Test
void playersExist() throws Exception {
String requestBody = "{" +
"\"page\": 0," +
"\"pageSize\": 10," +
"\"sortBy\": \"username\"," +
"\"order\": \"descending\"," +
"\"username\": \"\"" +
"}";
this.mvc.perform(createGetAllPlayersRequest(requestBody))
.andExpect(status().isOk())
.andExpect(jsonPath("$").isArray())
.andExpect(jsonPath("$[0]").exists());
}
@Test
void playersSortedByAsc() throws Exception {
String requestBody = "{" +
"\"page\": 0," +
"\"pageSize\": 10," +
"\"sortBy\": \"username\"," +
"\"order\": \"ascending\"," +
"\"username\": \"\"" +
"}";
this.mvc.perform(createGetAllPlayersRequest(requestBody))
.andExpect(status().isOk())
.andExpect(jsonPath("$[0].username").value("Alex"))
.andExpect(jsonPath("$[1].username").value("Zorro"));
}
@Test
void playersSortedByDesc() throws Exception {
String requestBody = "{" +
"\"page\": 0," +
"\"pageSize\": 10," +
"\"sortBy\": \"username\"," +
"\"order\": \"descending\"," +
"\"username\": \"\"" +
"}";
this.mvc.perform(createGetAllPlayersRequest(requestBody))
.andExpect(status().isOk())
.andExpect(jsonPath("$[1].username").value("Alex"))
.andExpect(jsonPath("$[0].username").value("Zorro"));
}
@Test
void playersFiltered() throws Exception {
String requestBody = "{" +
"\"page\": 0," +
"\"pageSize\": 10," +
"\"username\": \"Alex\","+
"\"order\": \"ascending\""+
"}";
this.mvc.perform(createGetAllPlayersRequest(requestBody))
.andExpect(status().isOk())
.andExpect(jsonPath("$").isArray())
.andExpect(jsonPath("$[0].username").value("Alex"))
.andExpect(jsonPath("$").isNotEmpty());
}
}

View file

@ -80,4 +80,4 @@ class GetAllPlayersTest extends IntegrationTest {
.andExpect(jsonPath("$[0].username").value("Alex"))
.andExpect(jsonPath("$").isNotEmpty());
}
}
}