use of org.springframework.test.web.servlet.MvcResult in project Saturn by vipshop.
the class JobOperationRestApiControllerTest method testCreateFailAsInvalidJobType.
@Test
public void testCreateFailAsInvalidJobType() throws Exception {
JobEntity jobEntity = constructJobEntity("job1");
// jobType should be mandatory
jobEntity.setConfig("jobType", "abc");
MvcResult result = mvc.perform(post("/rest/v1/domain/jobs").contentType(MediaType.APPLICATION_JSON).content(jobEntity.toJSON())).andExpect(status().isBadRequest()).andReturn();
String message = fetchErrorMessage(result);
assertEquals("error message not equal", "Invalid request. Parameter: {jobType} is malformed", message);
}
use of org.springframework.test.web.servlet.MvcResult in project Saturn by vipshop.
the class JobOperationRestApiControllerTest method testCreateFailAsUnExpectedExceptionThrows.
@Test
public void testCreateFailAsUnExpectedExceptionThrows() throws Exception {
String customErrMsg = "unexpected exception";
willThrow(new RuntimeException(customErrMsg)).given(restApiService).createJob(any(String.class), any(JobConfig.class));
JobEntity jobEntity = constructJobEntity("job1");
MvcResult result = mvc.perform(post("/rest/v1/domain/jobs").contentType(MediaType.APPLICATION_JSON).content(jobEntity.toJSON())).andExpect(status().isInternalServerError()).andReturn();
String message = fetchErrorMessage(result);
assertEquals("error message not equal", customErrMsg, message);
}
use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testGetStudy.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-after-updating-description.xml")
@ExpectedDatabase(value = "/data/study/study-after-updating-description.xml", assertionMode = NON_STRICT)
public void testGetStudy() throws Exception {
MvcResult mvcResult = mvc.perform(get("/api/v1/study-management/studies/" + STUDY_ID)).andExpect(NO_ERROR_CODE).andExpect(jsonPath("$.result.id").isNotEmpty()).andReturn();
JSONAssert.assertEquals(UPDATED_STUDY_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class SkillControllerTests method testGetSkill.
@Test
@DatabaseSetup("/data/skill/skill-after-updating.xml")
@ExpectedDatabase(value = "/data/skill/skill-after-updating.xml", assertionMode = NON_STRICT)
public void testGetSkill() throws Exception {
MvcResult mvcResult = mvc.perform(get("/api/v1/user-management/skills/" + SKILL_ID)).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(UPDATED_SKILL_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class SkillControllerTests method testCreateSkill.
@Test
@DatabaseSetup("/data/skill/empty-skill.xml")
@ExpectedDatabase(value = "/data/skill/added-skill.xml", assertionMode = NON_STRICT)
public void testCreateSkill() throws Exception {
SkillDTO skillDTO = new SkillDTO();
skillDTO.setName(SKILL_NAME);
MvcResult mvcResult = mvc.perform(post("/api/v1/user-management/skills/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(skillDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(SKILL_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
Aggregations