Example usage for org.springframework.http MediaType APPLICATION_JSON_UTF8

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

Introduction

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

Prototype

MediaType APPLICATION_JSON_UTF8

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

Click Source Link

Document

Public constant media type for application/json;charset=UTF-8 .

Usage

From source file:com.hp.autonomy.frontend.find.core.fields.FieldsControllerIT.java

@Test
public void getParametricDateFields() throws Exception {
    final MockHttpServletRequestBuilder requestBuilder = get(
            FieldsController.FIELDS_PATH + FieldsController.GET_PARAMETRIC_DATE_FIELDS_PATH)
                    .with(authentication(userAuth()));
    addParams(requestBuilder);//from w w w  . j  a  v a2  s  .  c om

    mockMvc.perform(requestBuilder).andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$", not(empty())));
}

From source file:com.snv.todo.TodoControllerTest.java

@Test
public void should_return_BadRequest_when_call_without_todo() throws Exception {
    mockMvc.perform(/*w w w . jav a2  s  .c om*/
            MockMvcRequestBuilders.post(CONTROLLER_URL).content(this.mapper.writeValueAsString(new Todo()))
                    .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().is4xxClientError());
}

From source file:com.snv.calendar.CalendarControllerTest.java

@Test
public void should_return_BadRequest_when_call_without_calendar() throws Exception {
    mockMvc.perform(/*from  w  w  w  .  j a v a 2 s .  c  o  m*/
            MockMvcRequestBuilders.post(CONTROLLER_URL).content(this.mapper.writeValueAsString(new Calendar()))
                    .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().is4xxClientError());
}

From source file:me.geenee.controller.ImageControllerTest.java

/**
 * Can read the list of images.//from   w w w.j a v  a  2  s. c o  m
 * @throws Exception If something goes wrong.
 */
@Test
public final void readsList() throws Exception {
    this.getMvc()
            .perform(MockMvcRequestBuilders.get(ImageController.PATH)
                    .contentType(MediaType.APPLICATION_JSON_UTF8))
            .andDo(MockMvcResultHandlers.print()).andExpect(MockMvcResultMatchers.status().isOk())
            .andExpect(this.listHasSize(Matchers.not(0)));
}

From source file:com.hp.autonomy.frontend.find.idol.search.IdolRelatedConceptsServiceIT.java

@Test
public void findRelatedConceptsWithStateToken() throws Exception {
    final QueryRestrictions<String> queryRestrictions = queryRestrictionsBuilder.setQueryText("*")
            .setFieldText("").setDatabases(Arrays.asList(mvcIntegrationTestUtils.getDatabases())).setMinScore(0)
            .build();//w  w  w. j  a  v  a  2s. com

    final String stateToken = documentsService.getStateToken(queryRestrictions, Integer.MAX_VALUE, false);

    final MockHttpServletRequestBuilder request = get(RelatedConceptsController.RELATED_CONCEPTS_PATH)
            .param(RelatedConceptsController.DATABASES_PARAM, mvcIntegrationTestUtils.getDatabases())
            .param(RelatedConceptsController.QUERY_TEXT_PARAM, "*")
            .param(RelatedConceptsController.FIELD_TEXT_PARAM, "")
            .param(RelatedConceptsController.STATE_TOKEN_PARAM, stateToken).with(authentication(userAuth()));

    mockMvc.perform(request).andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$", not(empty())));
}

From source file:com.hp.autonomy.frontend.find.core.parametricfields.AbstractParametricValuesServiceIT.java

@Test
public void getDateParametricValues() throws Exception {
    final MockHttpServletRequestBuilder requestBuilder = get(ParametricValuesController.PARAMETRIC_VALUES_PATH
            + ParametricValuesController.BUCKET_PARAMETRIC_PATH + '/' + ParametricValuesService.AUTN_DATE_FIELD)
                    .param(ParametricValuesController.DATABASES_PARAM, mvcIntegrationTestUtils.getDatabases())
                    .param(ParametricValuesController.QUERY_TEXT_PARAM, "*")
                    .param(ParametricValuesController.TARGET_NUMBER_OF_BUCKETS_PARAM, "35")
                    .param(ParametricValuesController.BUCKET_MIN_PARAM, "0")
                    .param(ParametricValuesController.BUCKET_MAX_PARAM, String.valueOf(Integer.MAX_VALUE))
                    .with(authentication(userAuth()));

    mockMvc.perform(requestBuilder).andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$", not(empty())));
}

From source file:io.pivotal.ecosystem.service.HelloMVCTest.java

@Test
public void testIt() throws Exception {
    RequestBuilder reqBuilder = MockMvcRequestBuilders.post("/users")
            .contentType(MediaType.APPLICATION_JSON_UTF8).content(toJson(new User(USER, PW, ROLE)));

    MvcResult result = mockMvc.perform(reqBuilder).andExpect(MockMvcResultMatchers.status().isCreated())
            .andReturn();/*from   ww  w  .  j a  v a  2 s .c om*/
    assertNotNull(result);

    mockMvc.perform(get("/greeting?username=foo")).andExpect(status().isOk())
            .andExpect(content().contentType(contentType));

    mockMvc.perform(delete("/users/foo")).andExpect(status().isOk());
}

From source file:com.toptal.controller.SignupControllerTest.java

/**
 * One cannot register a user with set id.
 * @throws Exception If smth goes wrong.
 *///from  www.j  av a  2s  .  c o m
@Test
public final void cannotRegisterWithNotNullUserId() throws Exception {
    final Long uid = 10L;
    final String user = this.json(User.builder().id(uid).name("userNameWithId").password("passw0rdWithId")
            .role(Role.ROLE_USER).build());
    final MvcResult result = this.getMvc()
            .perform(MockMvcRequestBuilders.post(SignupController.PATH)
                    .contentType(MediaType.APPLICATION_JSON_UTF8).content(user))
            .andDo(MockMvcResultHandlers.print()).andExpect(MockMvcResultMatchers.status().isBadRequest())
            .andReturn();
    Assert.assertEquals("User id must be null", result.getResolvedException().getMessage());
}

From source file:com.hp.autonomy.frontend.find.core.search.AbstractDocumentServiceIT.java

@Test
public void queryWithPagination() throws Exception {
    final MockHttpServletRequestBuilder requestBuilder = get(
            DocumentsController.SEARCH_PATH + '/' + DocumentsController.QUERY_PATH)
                    .param(DocumentsController.TEXT_PARAM, "*")
                    .param(DocumentsController.RESULTS_START_PARAM, "51")
                    .param(DocumentsController.MAX_RESULTS_PARAM, "100")
                    .param(DocumentsController.AUTO_CORRECT_PARAM, "false")
                    .param(DocumentsController.SUMMARY_PARAM, "context")
                    .param(DocumentsController.INDEXES_PARAM, mvcIntegrationTestUtils.getDatabases())
                    .with(authentication(userAuth()));

    mockMvc.perform(requestBuilder).andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$.documents", not(empty())));
}

From source file:com.snv.todo.TodoControllerTest.java

@Test
public void should_return_BadRequest_when_call_with_empty_Todo_values() throws Exception {
    Todo emptyTodo = new Todo();

    emptyTodo.setText("");

    mockMvc.perform(//from   ww w . ja  va  2 s.  c om
            MockMvcRequestBuilders.post(CONTROLLER_URL).content(this.mapper.writeValueAsString(emptyTodo))
                    .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(MockMvcResultMatchers.status().is4xxClientError());
}