Example usage for org.springframework.http MediaType APPLICATION_JSON

List of usage examples for org.springframework.http MediaType APPLICATION_JSON

Introduction

In this page you can find the example usage for org.springframework.http MediaType APPLICATION_JSON.

Prototype

MediaType APPLICATION_JSON

To view the source code for org.springframework.http MediaType APPLICATION_JSON.

Click Source Link

Document

Public constant media type for application/json .

Usage

From source file:fi.helsinki.opintoni.web.rest.publicapi.PublicProfileResourceTest.java

@Test
public void getProfileReturnsCorrectResponse() throws Exception {
    mockMvc.perform(get("/api/public/v1/profile/200").accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk()).andExpect(content().contentType(WebConstants.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$.avatarImageUrl")
                    .value("https://opi-1.student.helsinki.fi/api/public/v1/images/avatar/200"))
            .andExpect(jsonPath("$.backgroundImageUrl")
                    .value("https://opi-1.student.helsinki.fi/api/public/v1/images/backgrounds/Profile_2.jpg"));
}

From source file:com.wavemaker.commons.util.WMUtils.java

public static boolean isJsonMediaType(MediaType mediaType) {
    return MediaType.APPLICATION_JSON.equals(mediaType);
}

From source file:nl.flotsam.greader.http.GsonHttpMessageConverter.java

@Override
public List<MediaType> getSupportedMediaTypes() {
    return Arrays.asList(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML);
}

From source file:edu.fing.tagsi.db4o.business.TrackingController.java

public void Registrar(Envio envio) {
    RestTemplate restTemplate = new RestTemplate();
    RequestTrackingAddPackage req = new RequestTrackingAddPackage(envio.getId().toString(),
            envio.getCliente().getId().toString(), envio.getDestino().getId().toString(), envio.getFechaEnvio(),
            false);/*from w  w w  . j av  a 2s  .  c o m*/
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEntity<RequestTrackingAddPackage> entity = new HttpEntity<>(req, headers);
    restTemplate.postForObject(ConfigController.getInstance().getURLAddTracking(), entity, void.class);
}

From source file:com.opensearchserver.hadse.cluster.ClusterTest.java

@Test
public void t01_get() {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));

    RestTemplate template = new RestTemplate();

    ResponseEntity<NodeItem[]> entity = template.exchange("http://localhost:8080/_cluster", HttpMethod.GET,
            null, NodeItem[].class);
    assertTrue(entity.getBody().length >= 1);
    assertEquals(HttpStatus.OK, entity.getStatusCode());
}

From source file:com.recursivechaos.clearent.service.ClearentService.java

public Transaction postTransaction(Transaction transaction) {
    RestTemplate restTemplate = new RestTemplate();
    ResponseEntity<Response> responseEntity;
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
    headers.set("api-key", gatewayProperties.getKey());
    HttpEntity<String> request = new HttpEntity<>(transaction.toString(), headers);
    try {/*from www .  ja v  a 2 s  .  c  om*/
        responseEntity = restTemplate.postForEntity(gatewayProperties.getUrl() + "/transactions", request,
                Response.class);
    } catch (HttpClientErrorException he) {
        logger.error("Gateway Request Failed: {}", he.getLocalizedMessage());
        logger.error(he.getResponseBodyAsString());
        throw new GatewayException(he.getLocalizedMessage());
    }
    assert responseEntity != null;
    return responseEntity.getBody().getPayload().getTransaction();
}

From source file:jetbrains.buildServer.vsoRooms.rest.impl.JsonTeamRoomListConverter.java

public JsonTeamRoomListConverter() {
    super(MediaType.APPLICATION_JSON);
}

From source file:io.pivotal.strepsirrhini.chaoslemur.infrastructure.ContentTypeClientHttpRequestInterceptor.java

@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
        throws IOException {
    ClientHttpResponse response = execution.execute(request, body);
    response.getHeaders().setContentType(MediaType.APPLICATION_JSON);

    return response;
}

From source file:jetbrains.buildServer.vsoRooms.rest.impl.JsonTeamRoomMessageConverter.java

public JsonTeamRoomMessageConverter() {
    super(MediaType.APPLICATION_JSON);
}

From source file:jetbrains.buildServer.vsoRooms.rest.impl.StringJsonConverter.java

public boolean canWrite(Class<?> aClass, MediaType mediaType) {
    return aClass.equals(String.class) && mediaType.equals(MediaType.APPLICATION_JSON);
}