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:io.github.robwin.swagger2markup.petstore.Swagger2MarkupTest.java
@Test public void addANewPetToTheStore() throws Exception { this.mockMvc.perform(post("/pets/").content(createPet()).contentType(MediaType.APPLICATION_JSON)) .andDo(document("addPetUsingPOST", preprocessResponse(prettyPrint()))).andExpect(status().isOk()); }
From source file:com.parivero.swagger.demo.controller.PersonaControllerTest.java
/** * Test of alta method, of class PaisController. *//*w w w .j a va 2 s . c om*/ @Test public void alta_conRecursoValido_retornaPaisConNombreCreado() throws Exception { this.mockMvc .perform(post("/personas").contentType(MediaType.APPLICATION_JSON).content("{\"nombre\":\"Coco\"}")) .andDo(print()).andExpect(status().isCreated()) .andExpect(jsonPath("$.nombre").value(containsString("Modificado"))); }
From source file:tds.assessment.web.endpoints.ItemControllerIntegrationTests.java
@Test public void shouldReturnStimulusItemMetadata() throws Exception { String url = "/assessments/item/metadata?clientName=SBAC_PT&bankKey=1&stimulusKey=3"; ItemFileMetadata itemFileMetadata = ItemFileMetadata.create(ItemFileType.STIMULUS, "1-3", "stimulusFile", "stimulusFile/"); when(mockItemService.findItemFileMetadataByStimulusKey("SBAC_PT", 1, 3)) .thenReturn(Optional.of(itemFileMetadata)); MvcResult result = http.perform(get(url).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andReturn();//from w w w .j a v a2s . c o m ItemFileMetadata parsedResponse = objectMapper.readValue(result.getResponse().getContentAsByteArray(), ItemFileMetadata.class); assertThat(parsedResponse.getId()).isEqualTo("1-3"); assertThat(parsedResponse.getFileName()).isEqualTo("stimulusFile"); assertThat(parsedResponse.getFilePath()).isEqualTo("stimulusFile/"); assertThat(parsedResponse.getItemType()).isEqualTo(ItemFileType.STIMULUS); }
From source file:org.cloudfoundry.identity.uaa.security.web.UaaRequestMatcherTests.java
@Test public void pathMatcherMatchesExpectedPathsAndMatchingAcceptHeader() throws Exception { // Accept only JSON UaaRequestMatcher matcher = new UaaRequestMatcher("/somePath"); matcher.setAccept(Arrays.asList(MediaType.APPLICATION_JSON.toString())); assertTrue(matcher.matches(request("/somePath", "application/json"))); }
From source file:com.logaritex.hadoop.configuration.manager.SimpleHttpService.java
private static HttpHeaders createHttpHeaders(String username, String password) { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.set("Accept-Encoding", "gzip"); httpHeaders.set("Authorization", getBasicAuthHeaderValue(username, password)); httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); return httpHeaders; }
From source file:com.atlassian.connect.spring.test.ContextModelAttributesTest.java
@Test public void shouldReturnTimezoneModelAttribute() throws Exception { String timezone = "Australia/Sydney"; mvc.perform(get("/model-public").param("tz", timezone).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk())/* w w w . jav a 2 s . c om*/ .andExpect(jsonPath("$.['atlassian-connect-timezone']").value(is(timezone))); }
From source file:example.users.UserControllerClientTests.java
@Test public void accessJsonFieldsOnNestedPayload() { assertDave(issueGet("/changed", MediaType.APPLICATION_JSON)); }
From source file:net.kaczmarzyk.NullE2eTest.java
@Test public void findsEntitiesWithNotNullAttributeValue() throws Exception { mockMvc.perform(get("/characters?nickNameNull=false").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$").isArray()) .andExpect(jsonPath("$[?(@.firstName=='Marge')]").doesNotExist()) .andExpect(jsonPath("$[?(@.firstName=='Lisa')]").doesNotExist()) .andExpect(jsonPath("$[?(@.firstName=='Maggie')]").doesNotExist()) .andExpect(jsonPath("$[?(@.firstName=='Moe')]").doesNotExist()) .andExpect(jsonPath("$[?(@.firstName=='Homer')]").exists()) .andExpect(jsonPath("$[?(@.firstName=='Bart')]").exists()) .andExpect(jsonPath("$[?(@.firstName=='Ned')]").exists()) .andExpect(jsonPath("$[4]").doesNotExist()); }
From source file:org.jimsey.project.turbine.spring.controller.HelloControllerTest.java
@Test public void getHello() throws Exception { // use this for a spy... // Mockito.doReturn(123l).when(ping).ping(); Mockito.when(ping.ping()).thenReturn(123l); mvc.perform(MockMvcRequestBuilders.get("/ping").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(content().string(equalTo("123"))); }