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:org.zalando.github.spring.IssuesTemplate.java
@Override public Issue createIssue(IssueRequest issueRequest, String owner, String repo) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repo", repo); URI uri = new UriTemplate(buildUriString("/repos/{owner}/{repo}/issues")).expand(uriVariables); RequestEntity<IssueRequest> entity = RequestEntity.post(uri).contentType(MediaType.APPLICATION_JSON) .body(issueRequest);//ww w . j a v a 2s .co m ResponseEntity<Issue> responseEntity = getRestOperations().exchange(entity, Issue.class); return responseEntity.getBody(); }
From source file:org.openwms.tms.ChangeTUDocumentation.java
public @Test void testTUChangeUnknownTU() throws Exception { // setup .../*from w w w. j ava 2 s.com*/ CreateTransportOrderVO vo = createTO(); postTOAndValidate(vo, NOTLOGGED); vo.setBarcode(UNKNOWN); willThrow(new NotFoundException("", CommonMessageCodes.BARCODE_NOT_FOUND, UNKNOWN)).given(commonGateway) .updateTransportUnit(new TransportUnit(UNKNOWN, null, ERR_LOC_STRING)); // test ... MvcResult res = mockMvc .perform(patch(TMSConstants.ROOT_ENTITIES).contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(vo))) .andExpect(status().isNotFound()).andDo(document("to-patch-tu-unknown")).andReturn(); assertThat(res.getResponse().getContentAsString().contains("COMMON.BARCODE_NOT_FOUND")).isTrue(); }
From source file:org.royrusso.mvc.controller.UserControllerTest.java
@Test public void testSave() throws Exception { mockMvc.perform(post("/user").contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(new User()))) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("success", is(true))); }
From source file:eu.falcon.semantic.client.DenaClient.java
public static String getClassSubclasses(String classURI) { final String uri = "http://falconsemanticmanager.euprojects.net/api/v1/ontology/class/subclasses"; //final String uri = "http://localhost:8090/api/v1/ontology/class/subclasses"; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); RestTemplate restTemplate = new RestTemplate(); HttpEntity<String> entity = new HttpEntity<>(classURI, headers); String result = restTemplate.postForObject(uri, entity, String.class); return result; }
From source file:org.openwms.tms.AddProblemDocumentation.java
public @Test void testAddProblem() throws Exception { // setup ...//from ww w. ja v a 2 s .co m CreateTransportOrderVO vo = createTO(); postTOAndValidate(vo, NOTLOGGED); Message msg = new Message.Builder().withMessage("text").withMessageNo("77").build(); vo.setProblem(msg); // test ... mockMvc.perform(patch(TMSConstants.ROOT_ENTITIES).contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(vo))).andExpect(status().isNoContent()) .andDo(document("to-patch-addproblem")); assertThat(readTransportOrder(vo.getpKey()).getProblem()).isEqualTo(msg); assertThat(getProblemHistories()).hasSize(0); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.UserSettingsResourcePermissionsTest.java
@Test public void thatUserCanOnlyDeleteHerUserAvatar() throws Exception { mockMvc.perform(delete("/api/private/v1/usersettings/1/deleteuseravatar") .with(securityContext(studentSecurityContext())).characterEncoding("UTF-8") .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isForbidden()); }
From source file:fi.helsinki.opintoni.server.UnisportServer.java
public void expectUserReservations() { server.expect(requestTo(unisportBaseUrl + "/api/v1/fi/ext/opintoni/reservations")) .andExpect(method(HttpMethod.GET)) .andExpect(header("Authorization", MockUnisportJWTService.MOCK_JWT_TOKEN)) .andRespond(withSuccess(toText("unisport/user-reservations.json"), MediaType.APPLICATION_JSON)); }
From source file:com.salmon.security.xacml.demo.springmvc.services.RestQueryUnitTest.java
@Test public void getNonExistingDriver() throws Exception { when(marketPlaceController.getDriverDetails(nonExistingDriver)).thenReturn(null); this.mockMvc//from ww w . jav a 2s .com .perform(get("/aggregators/dvla/drivers/{license}", nonExistingDriver) .accept(MediaType.APPLICATION_JSON)) //.andDo(print()) .andExpect(status().isNotFound()); }
From source file:net.kaczmarzyk.DateE2eTest.java
@Test public void findsByDateBeforeWithCustomDateFormat() throws Exception { mockMvc.perform(/*from w ww .j a v a 2 s . c o m*/ get("/customers").param("registeredBefore", "16-03-2014").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$").isArray()) .andExpect(jsonPath("$[0].firstName").value("Homer")) .andExpect(jsonPath("$[1].firstName").value("Moe")).andExpect(jsonPath("$[2]").doesNotExist()); }