Search in sources :

Example 91 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class AccountControllerTest method testPasswordStatus.

/**
 * Test of passwordStatus method, of class AccountController.
 *
 * @see AccountController#passwordStatus()
 */
@Test
public void testPasswordStatus() throws Exception {
    log.info("passwordStatus");
    MvcResult result = mvc.perform(get("/api/accounts/password/status.json")).andExpect(status().isOk()).andExpect(jsonPath("$.content").isMap()).andExpect(jsonPath("$.stats").isMap()).andReturn();
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 92 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class ContestControllerTest method testSave.

/**
 * Test of save method, of class ContestController.
 *
 * @see ContestController#save(Contest)
 */
@Test
public void testSave() throws Exception {
    log.info("save");
    Contest contest = mockDataService.contest(false);
    MvcResult result = mvc.perform(post("/api/contests.json").content(objectMapper.writeValueAsString(contest)).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
Also used : Contest(cn.edu.zjnu.acm.judge.domain.Contest) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 93 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class ContestControllerTest method testSubmittedProblems.

/**
 * Test of submittedProblems method, of class ContestController.
 *
 * @see ContestController#submittedProblems(long)
 */
@Test
public void testSubmittedProblems() throws Exception {
    log.info("submittedProblems");
    long id = mockDataService.contest().getId();
    MvcResult result = mvc.perform(get("/api/contests/{id}/problems/submitted.json", id)).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 94 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class ContestControllerTest method testUpdate.

/**
 * Test of update method, of class ContestController.
 *
 * @see ContestController#update(long, Contest)
 */
@Test
public void testUpdate() throws Exception {
    log.info("update");
    long id = mockDataService.contest().getId();
    Contest request = new Contest();
    MvcResult result = mvc.perform(patch("/api/contests/{id}.json", id).content(objectMapper.writeValueAsString(request)).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isNoContent()).andReturn();
}
Also used : Contest(cn.edu.zjnu.acm.judge.domain.Contest) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 95 with MvcResult

use of org.springframework.test.web.servlet.MvcResult in project judge by zjnu-acm.

the class ContestControllerTest method testList.

/**
 * Test of list method, of class ContestController.
 *
 * @see ContestController#list(ContestForm)
 */
@Test
public void testList() throws Exception {
    log.info("list");
    boolean includeDisabled = false;
    String[] exclude = null;
    String[] include = null;
    MvcResult result = mvc.perform(get("/api/contests.json").param("includeDisabled", Boolean.toString(includeDisabled)).param("exclude", Objects.toString(exclude, "")).param("include", Objects.toString(include, ""))).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
}
Also used : MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

MvcResult (org.springframework.test.web.servlet.MvcResult)536 Test (org.junit.Test)300 Test (org.junit.jupiter.api.Test)143 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)132 ResultMatcher (org.springframework.test.web.servlet.ResultMatcher)69 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)38 MockHttpSession (org.springframework.mock.web.MockHttpSession)35 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)34 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)31 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)26 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)26 RequestBuilder (org.springframework.test.web.servlet.RequestBuilder)24 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)22 Map (java.util.Map)22 ResultActions (org.springframework.test.web.servlet.ResultActions)19 Cookie (javax.servlet.http.Cookie)18 MockMvc (org.springframework.test.web.servlet.MockMvc)17 HttpSession (jakarta.servlet.http.HttpSession)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 AbstractSaturnConsoleTest (com.vip.saturn.job.console.AbstractSaturnConsoleTest)15