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:edu.fing.tagsi.db4o.business.TrackingController.java
public List<Tracking> getTracking(UUID id) { RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity entity = new HttpEntity(headers); ResponseEntity<RequestTrackingAddPackage[]> tracking = restTemplate.exchange( ConfigController.getInstance().getURLFindTracking() + "/" + id.toString(), GET, entity, RequestTrackingAddPackage[].class); if (tracking != null) { List<Tracking> resultado = new ArrayList<>(tracking.getBody().length); for (RequestTrackingAddPackage r : tracking.getBody()) { resultado.add(new Tracking(UUID.fromString(r.getIdpaquete()), UUID.fromString(r.getIdcliente()), UUID.fromString(r.getIdlugar()), r.getFecha(), r.isEsdestino())); }/*from w w w. j a v a2s . c om*/ return resultado; } else { return null; } }
From source file:fi.helsinki.opintoni.web.rest.publicapi.portfolio.PublicPortfolioResourcePermissionTest.java
@Test public void thatUserCannotLoadPrivatePortfolioFromPublicApi() throws Exception { mockMvc.perform(get("/api/public/v1/portfolio/student/olli-opiskelija").characterEncoding("UTF-8") .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.portfolio.PrivatePortfolioAttainmentResourcePermissionTest.java
@Test public void thatUserCannotGetStudyAttainmentWhitelistSheDoesNotOwnThroughPrivateApi() throws Exception { mockMvc.perform(get(RESOURCE_URL).with(securityContext(teacherSecurityContext())).characterEncoding("UTF-8") .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()); }
From source file:com.nebhale.devoxx2013.web.IntegrationTest.java
@Test public void play() throws Exception { String game = this.mockMvc.perform(post("/games")).andExpect(status().isCreated()).andReturn().getResponse() .getHeader("Location"); List<String> doors = getDoors(game); this.mockMvc.perform( put(doors.get(1)).content("{ \"status\": \"SELECTED\"}").contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); if (Door.DoorStatus.CLOSED == getDoorStatus(doors.get(0))) { this.mockMvc.perform( put(doors.get(0)).content("{ \"status\": \"OPENED\"}").contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); } else {/*from w w w . j a va2s . co m*/ System.out.println("OTHER"); this.mockMvc.perform( put(doors.get(2)).content("{ \"status\": \"OPENED\"}").contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); } assertThat(getGameStatus(game), anyOf(equalTo(Game.GameStatus.WON), equalTo(Game.GameStatus.LOST))); }
From source file:io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEmitter.java
private void notify(RateLimiterEventDTO rateLimiterEventDTO) { try {//from ww w . ja va 2 s . co m sseEmitter.send(rateLimiterEventDTO, MediaType.APPLICATION_JSON); } catch (IOException e) { LOG.warn("Failed to send circuitbreaker event", e); } }
From source file:eu.falcon.semantic.client.DenaClient.java
public static String runQuery(String sparqlQuery) { final String uri = "http://falconsemanticmanager.euprojects.net/api/v1/ontology/query/run"; //final String uri = "http://localhost:8090/api/v1/ontology/query/run"; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); RestTemplate restTemplate = new RestTemplate(); HttpEntity<String> entity = new HttpEntity<>(sparqlQuery, headers); String result = restTemplate.postForObject(uri, entity, String.class); return result; }
From source file:org.cf.serviceregistrybroker.binding.BindingControllerTest.java
@Test public void create() throws Exception { this.mockMvc.perform(put( "/v2/service_instances/test-service-instance-id/service_bindings/test-service-binding-instance-id") .content(bindingInstancePayload()).contentType(MediaType.APPLICATION_JSON)) .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.credentials.uri").exists()); }
From source file:org.nubomedia.marketplace.api.exceptions.GlobalExceptionHandler.java
@ExceptionHandler({ NotFoundException.class }) @ResponseStatus(value = HttpStatus.NOT_FOUND) protected ResponseEntity<Object> handleNotFoundException(HttpServletRequest req, Exception e) { log.error("Exception with message " + e.getMessage() + " was thrown"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); Map body = new HashMap<>(); body.put("error", "Not Found"); body.put("exception", e.getClass().toString()); body.put("message", e.getMessage()); body.put("path", req.getRequestURI()); body.put("status", HttpStatus.NOT_FOUND.value()); body.put("timestamp", new Date().getTime()); ResponseEntity responseEntity = new ResponseEntity(body, headers, HttpStatus.NOT_FOUND); return responseEntity; }
From source file:org.oncoblocks.centromere.web.util.ApiMediaTypes.java
public static List<MediaType> getJsonMediaTypes() { return Arrays.asList(MediaType.APPLICATION_JSON, APPLICATION_HAL_JSON); }
From source file:example.users.UserControllerIntegrationTests.java
@Test public void handlesJsonPayloadWithExactProperties() throws Exception { postAndExpect("{ \"firstname\" : \"Dave\", \"lastname\" : \"Matthews\" }", MediaType.APPLICATION_JSON); }