use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class ProfessionalTypeControllerTests method testGetProfessionalType.
@Test
@DatabaseSetup("/data/professionaltype/professional-type-after-updating.xml")
@ExpectedDatabase(table = "professional_types", value = "/data/professionaltype/professional-type-after-updating.xml", assertionMode = NON_STRICT)
public void testGetProfessionalType() throws Exception {
MvcResult mvcResult = mvc.perform(get("/api/v1/user-management/professional-types/" + PROFESSIONAL_TYPE_ID)).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(UPDATED_PROFESSIONAL_TYPE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of org.springframework.test.web.servlet.MvcResult in project ArachneCentralAPI by OHDSI.
the class ProfessionalTypeControllerTests method testCreateProfessionalType.
@Test
@DatabaseSetup(value = "/data/professionaltype/empty-professional-type.xml")
@ExpectedDatabase(table = "users_data", value = "/data/users-without-external-dependency.xml", assertionMode = NON_STRICT)
public void testCreateProfessionalType() throws Exception {
CommonProfessionalTypeDTO professionalTypeDTO = new CommonProfessionalTypeDTO();
professionalTypeDTO.setName(PROFESSIONAL_TYPE_NAME);
MvcResult mvcResult = mvc.perform(post("/api/v1/admin/professional-types/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(professionalTypeDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(PROFESSIONAL_TYPE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of org.springframework.test.web.servlet.MvcResult in project nixmash-blog by mintster.
the class GlobalControllerTests method googleAnalyticsAnonymousUserTest.
@Test
@WithAnonymousUser
public void googleAnalyticsAnonymousUserTest() throws Exception {
RequestBuilder request = get("/").with(csrf());
MvcResult result = mockMvc.perform(request).andReturn();
assertTrue(result.getResponse().getContentAsString().contains(TRACKING_ID));
}
use of org.springframework.test.web.servlet.MvcResult in project nixmash-blog by mintster.
the class PermaPostsControllerTests method summaryTwitterCardMetaDataExists.
@Test
public void summaryTwitterCardMetaDataExists() throws Exception {
// H2 PostId 1L has SUMMARY as TwitterCardType
MvcResult mvcResult = this.mockMvc.perform(get("/post/javascript-bootstrap")).andExpect(status().isOk()).andReturn();
assertThat(mvcResult.getResponse().getContentAsString(), containsString("<meta name=\"twitter:card\" content=\"summary\" />"));
}
use of org.springframework.test.web.servlet.MvcResult in project nixmash-blog by mintster.
the class PostsRestControllerTests method moreLikeThis_PostDocNumLessThanAppSetting.
@Test
public void moreLikeThis_PostDocNumLessThanAppSetting() throws Exception {
// MoreLikeThis PopulatePostStream() throws IndexOutOfBoundsException
// Returns No MoreLikeThis Posts message containing "nomlt-message" classname
applicationSettings.setMoreLikeThisNum(1000);
mockMvc.perform(get("/post/" + MLT_POSTNAME)).andExpect(model().attributeExists(MORELIKETHIS_ATTRIBUTE));
MvcResult mvcResult = mockMvc.perform(get("/json/posts/post/mlt/" + MLT_POSTID)).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)).andReturn();
assertThat(mvcResult.getResponse().getContentAsString(), containsString("<div class=\"nomlt-message\">"));
}
Aggregations