use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testGetAnalysis.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-after-title-updating.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-after-title-updating.xml", assertionMode = NON_STRICT) })
public void testGetAnalysis() throws Exception {
MvcResult mvcResult = mvc.perform(get("/api/v1/analysis-management/analyses/" + ANALYSIS_ID)).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(UPDATED_ANALYSIS_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testUpdate.
private void testUpdate(AnalysisUpdateDTO analysisDTO, JSONObject expected, String newValue) throws Exception {
MvcResult mvcResult = mvc.perform(put("/api/v1/analysis-management/analyses/" + ANALYSIS_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(analysisDTO))).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONObject result = getResultJSONObject(mvcResult);
JSONAssert.assertEquals(expected, result, false);
}
use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class AnalysisSubmissionControllerTests method createSubmission.
private void createSubmission(Long studyId, Long analysisId, Long dataSourceId) throws Exception {
final MvcResult mvcResult = sendRequest(studyId, analysisId, dataSourceId).andExpect(NO_ERROR_CODE).andExpect(jsonPath("$.result").isArray()).andExpect(jsonPath("$.result", hasSize(1))).andReturn();
JSONObject expectedJsonObject = new JSONObject().put("dataSource", new JSONObject().put("id", dataSourceId));
JSONAssert.assertEquals(expectedJsonObject, getResultJSONArray(mvcResult).getJSONObject(0), false);
}
use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class AuthControllerTests method testRefreshToken.
@Test
public void testRefreshToken() throws Exception {
String authToken = login();
MvcResult mvcResult = mvc.perform(post("/api/v1/auth/refresh").header(tokenHeader, authToken).contentType(APPLICATION_JSON)).andExpect(NO_ERROR_CODE).andReturn();
authToken = getResponse(mvcResult).getString("result");
mvc.perform(get("/api/v1/test").header(tokenHeader, authToken).contentType(APPLICATION_JSON)).andExpect(status().isNotFound());
}
use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class RoleControllerTests method testUpdateRole.
@Test
@DatabaseSetup(value = "/data/role/role-before-updating.xml")
@ExpectedDatabase(table = "roles", value = "/data/role/roles.xml", assertionMode = NON_STRICT_UNORDERED)
public void testUpdateRole() throws Exception {
RoleDTO roleDTO = new RoleDTO();
roleDTO.setId(ROLE_ID);
roleDTO.setName(UPDATED_ROLE_NAME);
roleDTO.setDescription(ROLE_DESCRIPTION);
MvcResult mvcResult = mvc.perform(put("/api/v1/admin/roles/" + ROLE_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(roleDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(UPDATED_ROLE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
Aggregations