List of usage examples for org.springframework.http MediaType APPLICATION_JSON
MediaType APPLICATION_JSON
To view the source code for org.springframework.http MediaType APPLICATION_JSON.
Click Source Link
From source file:ar.com.connectis_ict.proyectoweb.controller.FooControllerComponenteTest.java
@Test public void obtener_conIdExistente_retornaUnaEntidadFoo() throws Exception { MockMvcBuilders.standaloneSetup(instancia).build().perform(get("/foo/1").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultHandlers.print()).andExpect(status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("id", Matchers.equalTo(1))); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.TodoItemResourceTest.java
@Test public void thatTodoItemsReturnCorrectResponse() throws Exception { mockMvc.perform(get("/api/private/v1/todoitems").with(securityContext(studentSecurityContext())) .characterEncoding("UTF-8").contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andExpect(content().contentType(WebConstants.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$").isArray()).andExpect(jsonPath("$", hasSize(2))) .andExpect(jsonPath("$[0].id").value(1)) .andExpect(jsonPath("$[0].createdDate").value(any(Number.class))) .andExpect(jsonPath("$[0].content").value("Do this")) .andExpect(jsonPath("$[1].status").value("OPEN")).andExpect(jsonPath("$[1].id").value(2)) .andExpect(jsonPath("$[1].createdDate").value(any(Number.class))) .andExpect(jsonPath("$[1].content").value("Do this also")) .andExpect(jsonPath("$[1].status").value("OPEN")); }
From source file:io.pivotal.strepsirrhini.chaoslemur.infrastructure.ContentTypeClientHttpRequestInterceptorTest.java
@Test public void intercept() throws IOException { when(this.execution.execute(this.request, this.body)).thenReturn(this.response); this.interceptor.intercept(this.request, this.body, this.execution); assertEquals(MediaType.APPLICATION_JSON, this.response.getHeaders().getContentType()); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.TodoItemResourcePermissionsTest.java
@Test public void thatUserCannotUpdateTodoItemSheDoesNotOwn() throws Exception { TodoItemDto todoItemDto = new TodoItemDto(); todoItemDto.content = "Content"; todoItemDto.status = "OPEN"; mockMvc.perform(put("/api/private/v1/todoitems/1").with(securityContext(teacherSecurityContext())) .characterEncoding("UTF-8").contentType(MediaType.APPLICATION_JSON) .content(WebTestUtils.toJsonBytes(todoItemDto)).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isForbidden()); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.EnrollmentResourceGetTeacherCoursesTest.java
@Test public void thatTeacherCoursesAreReturned() throws Exception { expectTeacherCourses();/* w w w. ja v a2 s .com*/ mockMvc.perform(get("/api/private/v1/teachers/enrollments/courses") .with(securityContext(teacherSecurityContext())).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(content().contentType(WebConstants.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$").isArray()).andExpect(jsonPath("$[0].code").value("10440")) .andExpect(jsonPath("$[0].name").value("Formulation III")) .andExpect(jsonPath("$[0].startDate[0]").value(2015)) .andExpect(jsonPath("$[0].startDate[1]").value(10)) .andExpect(jsonPath("$[0].startDate[2]").value(25)) .andExpect(jsonPath("$[0].startDate[3]").value(22)) .andExpect(jsonPath("$[0].startDate[4]").value(0)) .andExpect(jsonPath("$[0].endDate[0]").value(2016)).andExpect(jsonPath("$[0].endDate[1]").value(4)) .andExpect(jsonPath("$[0].endDate[2]").value(26)).andExpect(jsonPath("$[0].endDate[3]").value(21)) .andExpect(jsonPath("$[0].endDate[4]").value(0)) .andExpect(jsonPath("$[0].webOodiUri").value("https://weboodi.helsinki.fi/")) .andExpect(jsonPath("$[0].isExam").value(false)) .andExpect(jsonPath("$[0].isCancelled").value(false)) .andExpect(jsonPath("$[0].realisationId").value(PARENT_REALISATION_ID)) .andExpect(jsonPath("$[0].parentId").isEmpty()).andExpect(jsonPath("$[1].code").value("10442")) .andExpect(jsonPath("$[1].isExam").value(true)).andExpect(jsonPath("$[1].isCancelled").value(true)) .andExpect(jsonPath("$[1].parentId").value(PARENT_REALISATION_ID)); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.portfolio.PrivatePortfolioKeywordRelationshipResourcePermissionTest.java
@Test public void thatUserCannotUpdateKeywordsFromPrivateApiThatSheDoesNotOwn() throws Exception { UpdateKeywordsRequest updateKeywordsRequest = new UpdateKeywordsRequest(); mockMvc.perform(post(RESOURCE_URL).with(securityContext(teacherSecurityContext())) .characterEncoding("UTF-8").contentType(MediaType.APPLICATION_JSON) .content(WebTestUtils.toJsonBytes(updateKeywordsRequest)).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()); }
From source file:info.losd.galen.api.TestGetHealthcheckDetails.java
@Test public void it_gets_the_details_of_a_healthcheck() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/healthchecks/healthcheck1")).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); HealthcheckApiDTO result = gson.fromJson(mvcResult.getResponse().getContentAsString(), HealthcheckApiDTO.class); checkHealthcheck(result, "healthcheck1"); }
From source file:com.coffeebeans.services.config.MvcConfig.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.defaultContentType(MediaType.APPLICATION_JSON); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.EnrollmentResourceGetTeacherEventsTest.java
@Test public void thatTeacherEventsAreReturned() throws Exception { expectEvents();//from w w w . j ava 2 s .c om mockMvc.perform( get("/api/private/v1/teachers/enrollments/events").with(securityContext(teacherSecurityContext())) .characterEncoding("UTF-8").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(content().contentType(WebConstants.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$").isArray()).andExpect(jsonPath("$", hasSize(4))) .andExpect(jsonPath("$[0].realisationId").value(99903629)) .andExpect(jsonPath("$[0].endDate").isArray()).andExpect(jsonPath("$[0].endDate[0]").value(2015)) .andExpect(jsonPath("$[0].endDate[1]").value(8)).andExpect(jsonPath("$[0].endDate[2]").value(13)) .andExpect(jsonPath("$[0].endDate[3]").value(11)).andExpect(jsonPath("$[0].endDate[4]").value(0)) .andExpect(jsonPath("$[0].startDate").isArray()) .andExpect(jsonPath("$[0].startDate[0]").value(2015)) .andExpect(jsonPath("$[0].startDate[1]").value(8)) .andExpect(jsonPath("$[0].startDate[2]").value(13)) .andExpect(jsonPath("$[0].startDate[3]").value(7)).andExpect(jsonPath("$[0].startDate[4]").value(0)) .andExpect(jsonPath("$[0].title").value("Formulation III")) .andExpect(jsonPath("$[0].locations").value("F24 Fabianinkatu 24, Sali 531, Viikinkaari 11")) .andExpect(jsonPath("$[0].type").value(EventDto.Type.DEFAULT.name())) .andExpect(jsonPath("$[0].source").value(EventDto.Source.OODI.name())) .andExpect(jsonPath("$[0].courseTitle").value("Animal Biotechnology B (KEL/KEBIOT230)")) .andExpect(jsonPath("$[0].courseMaterial.courseMaterialUri") .value("https://dev.student.helsinki" + ".fi/tvt?group-imp-material")) .andExpect(jsonPath("$[0].courseMaterial.courseMaterialType") .value(CourseMaterialDto.CourseMaterialType.COURSE_PAGE.toString())) .andExpect(jsonPath("$[0].building.street").value("Viikinkaari 11")) .andExpect(jsonPath("$[0].building.zipCode").value("00790")) .andExpect(jsonPath("$[0].hasMaterial").value(true)) .andExpect(jsonPath("$[3].title").value("Tentti")) .andExpect(jsonPath("$[3].source").value(EventDto.Source.COURSE_PAGE.name())) .andExpect(jsonPath("$[3].type").value(EventDto.Type.EXAM.name())); }
From source file:sample.RestTests.java
@Test(expected = HttpClientErrorException.class) public void unauthenticatedUserSentToLogInPage() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); ResponseEntity<String> entity = getForUser(this.baseUrl + "/", headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); }