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:br.com.edo.atmlist.controller.ATMControllerTest.java
@Test public void callATMList() throws Exception { System.out.println("callATMList"); this.mockMvc/*from w ww . java 2 s. c o m*/ .perform(get("/atmList").contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)); }
From source file:com.sastix.cms.common.services.ApiVersionControllerTest.java
@Test public final void testRestController() throws Exception { MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); MvcResult result = mockMvc.perform(get(Constants.GET_API_VERSION).accept(MediaType.APPLICATION_JSON)) .andReturn();//from w w w. ja v a 2s .co m assertEquals("Status should be 200 - OK", 200, result.getResponse().getStatus()); assertEquals("JSON response should be exactly " + TEST_VERSION_JSON, result.getResponse().getContentAsString(), TEST_VERSION_JSON); }
From source file:com.nebhale.devoxx2013.web.DoorControllerTest.java
@Test public void modifyDoorOpened() throws Exception { Game game = createGame();/*from w w w. j av a2 s. c om*/ List<Door> doors = createDoors(game); Door door0 = doors.get(0); Door door1 = doors.get(1); this.gameService.select(door0); this.mockMvc .perform(put("/games/{game}/doors/{door}", game.getId(), door1.getId()) .content("{ \"status\" : \"OPENED\" }").contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); assertThat(door1.getStatus(), equalTo(Door.DoorStatus.OPENED)); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.portfolio.PrivatePortfolioAttainmentResourceTest.java
@Test public void thatWhitelistedAttainmentIdsAreUpdated() throws Exception { StudyAttainmentWhitelistDto dto = new StudyAttainmentWhitelistDto(); dto.oodiStudyAttainmentIds = Lists.newArrayList(3L, 4L); mockMvc.perform(post(RESOURCE_URL + "/whitelist").with(securityContext(studentSecurityContext())) .content(WebTestUtils.toJsonBytes(dto)).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$.oodiStudyAttainmentIds").isArray()) .andExpect(jsonPath("$.oodiStudyAttainmentIds").value(hasSize(2))) .andExpect(jsonPath("$.oodiStudyAttainmentIds[0]").value(3)) .andExpect(jsonPath("$.oodiStudyAttainmentIds[1]").value(4)); }
From source file:de.dominikschadow.configclient.secret.SecretControllerTest.java
@Test public void writeSecretForUserReturnsOk() throws Exception { Secret secret = Secret.builder().userId(12345L).data("My secret").build(); String secretJson = mapper.writeValueAsString(secret); mvc.perform(//from w w w.ja va 2s. com MockMvcRequestBuilders.post("/secrets").contentType(MediaType.APPLICATION_JSON).content(secretJson)) .andExpect(MockMvcResultMatchers.status().isOk()); }
From source file:com.parivero.swagger.demo.controller.PaisControllerTest.java
@Test public void modificacion_conRecursoInValido_retornaBadRequest() throws Exception { this.mockMvc/* www .j av a2 s . co m*/ .perform( put("/paises").contentType(MediaType.APPLICATION_JSON).content("\"nombre\":\"Argentina\"}")) .andDo(print()).andExpect(status().isBadRequest()); }
From source file:org.jboss.spring3_2.example.test.MemberMockMVCTest.java
@Test public void getAccount() throws Exception { this.mockMvc.perform(get("/rest/members/0").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andExpect(content().contentType("application/json")) .andExpect(jsonPath("$.name").value("John Smith")); }
From source file:fi.helsinki.opintoni.web.rest.privateapi.portfolio.PortfolioResourceTest.java
private ResultActions createPortfolio(SecurityContext securityContext, String apiUrl) throws Exception { return mockMvc.perform(post(apiUrl).with(securityContext(securityContext)).characterEncoding("UTF-8") .accept(MediaType.APPLICATION_JSON)); }
From source file:com.ns.retailmgr.controller.ShopControllerTest.java
@Test public void test_addShop_Success() throws Exception { mockShopDetails.setStatus("New"); when(shopService.addShop(any(ShopDetails.class))).thenReturn(mockShopDetails); RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/shop").accept(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsBytes(jsonAddress)).contentType(MediaType.APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); MockHttpServletResponse response = result.getResponse(); assertEquals(HttpStatus.CREATED.value(), response.getStatus()); }