List of usage examples for org.springframework.http HttpMethod POST
HttpMethod POST
To view the source code for org.springframework.http HttpMethod POST.
Click Source Link
From source file:org.client.one.service.OAuthAuthenticationService.java
public boolean updateCurrentUserProfile(String token, Profile profile) throws JsonGenerationException, JsonMappingException, IOException, JSONException { RestOperations rest = new RestTemplate(); HttpHeaders headersA = new HttpHeaders(); headersA.set("Authorization", "Bearer " + token); headersA.setContentType(MediaType.TEXT_PLAIN); ObjectMapper mapper = new ObjectMapper(); HttpEntity<String> request = new HttpEntity<String>(mapper.writeValueAsString(profile), headersA); ResponseEntity<String> responseUpdate = rest.exchange(oauthServerBaseURL + "/resources/profile/update", HttpMethod.POST, request, String.class); JSONObject responseUpdateJSON = new JSONObject(responseUpdate.getBody()); return responseUpdateJSON.getBoolean("success"); }
From source file:com.auditbucket.client.AbRestClient.java
public int flushXReferences(List<CrossReferenceInputBean> referenceInputBeans) { logger.info("Processing [{}] cross references - simulate [{}]", referenceInputBeans.size(), simulateOnly); if (simulateOnly) return 0; RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); HttpHeaders httpHeaders = getHeaders(userName, password); HttpEntity<List<CrossReferenceInputBean>> requestEntity = new HttpEntity<>(referenceInputBeans, httpHeaders);/*from w w w. ja v a 2 s . c o m*/ try { ResponseEntity<ArrayList> response = restTemplate.exchange(CROSS_REFERENCES, HttpMethod.POST, requestEntity, ArrayList.class); logServerMessages(response); return referenceInputBeans.size(); } catch (HttpClientErrorException e) { // ToDo: Rest error handling pretty useless. need to know why it's failing logger.error("AB Client Audit error {}", getErrorMessage(e)); return 0; } catch (HttpServerErrorException e) { logger.error("AB Server Audit error {}", getErrorMessage(e)); return 0; } }
From source file:org.cloudfoundry.identity.uaa.integration.ClientAdminEndpointsIntegrationTests.java
@Test public void implicitGrantClientWithoutSecretIsOk() throws Exception { BaseClientDetails client = new BaseClientDetails(new RandomValueStringGenerator().generate(), "", "foo,bar", "implicit", "uaa.none"); ResponseEntity<Void> result = serverRunning.getRestTemplate().exchange( serverRunning.getUrl("/oauth/clients"), HttpMethod.POST, new HttpEntity<BaseClientDetails>(client, headers), Void.class); assertEquals(HttpStatus.CREATED, result.getStatusCode()); }
From source file:com.gooddata.dataload.processes.ProcessService.java
/** * Create new process from appstore./*w ww. j av a 2 s . c o m*/ * Process must have set path field to valid appstore path in order to deploy from appstore. * This method is asynchronous, because when deploying from appstore, deployment worker can be triggered. * * @param project project to which the process belongs * @param process to create * @return created process */ public FutureResult<DataloadProcess> createProcessFromAppstore(Project project, DataloadProcess process) { notNull(project, "project"); notNull(process, "process"); notEmpty(process.getPath(), "process path"); return postProcess(process, getProcessesUri(project), HttpMethod.POST); }
From source file:org.cloudfoundry.identity.uaa.login.RemoteUaaControllerViewTests.java
@Test public void testAccessConfirmationPage() throws Exception { mockRestServiceServer.expect(requestTo("https://uaa.cloudfoundry.com/oauth/authorize")) .andExpect(method(HttpMethod.POST)).andRespond(withSuccess(UAA_JSON, MediaType.APPLICATION_JSON)); UsernamePasswordAuthenticationToken principal = new UsernamePasswordAuthenticationToken( testAccounts.getUserName(), null, Arrays.asList(UaaAuthority.fromAuthorities("uaa.user"))); MockHttpServletRequestBuilder get = get("/oauth/authorize").param("response_type", "code") .param("client_id", "app").param("redirect_uri", "http://example.com").principal(principal); mockMvc.perform(get).andExpect(status().isOk()).andExpect(model().attributeExists("client_id")) .andExpect(model().attribute("undecided_scopes", hasSize(2))) .andExpect(model().attribute("approved_scopes", hasSize(1))) .andExpect(model().attribute("denied_scopes", hasSize(1))) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andExpect(xpath("//h1[text()='Application Authorization']").exists()) .andExpect(xpath(/*from ww w. j a v a 2s . co m*/ "//input[@type='checkbox' and @name='scope.0' and @value='scope.cloud_controller.write' and @checked='checked']") .exists()) .andExpect(xpath( "//input[@type='checkbox' and @name='scope.1' and @value='scope.scim.userids' and @checked='checked']") .exists()) .andExpect(xpath( "//input[@type='checkbox' and @name='scope.2' and @value='scope.password.write' and @checked='checked']") .exists()) .andExpect(xpath( "//input[@type='checkbox' and @name='scope.3' and @value='scope.cloud_controller.read']") .exists()) .andExpect(xpath( "//input[@type='checkbox' and @name='scope.3' and @value='scope.cloud_controller.read' and @checked='checked']") .doesNotExist()); }
From source file:com.sitewhere.rest.service.SiteWhereClient.java
@Override public Device createDevice(DeviceCreateRequest request) throws SiteWhereException { Map<String, String> vars = new HashMap<String, String>(); return sendRest(getBaseUrl() + "devices", HttpMethod.POST, request, Device.class, vars); }
From source file:cucumber.api.spring.test.web.servlet.MockMvcStepdefs.java
@When("^I perform a POST request on \"(.*?)\"$") public void i_perform_a_post_request_on(String uri) throws Throwable { i_perform_a_request_on(HttpMethod.POST, uri); }
From source file:com.garyclayburg.UserRestSmokeTest.java
@Ignore @Test/* w ww .j a v a 2 s . c o m*/ public void testJsonutf8Apache() throws Exception { RestTemplate rest = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); SimpleUser user1 = new SimpleUser(); user1.setFirstname("Tommy"); user1.setLastname("Deleteme"); user1.setId("112" + (int) (Math.floor(Math.random() * 10000))); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("Content-Type", "application/json;charset=UTF-8"); // HttpEntity<?> requestEntity = new HttpEntity(requestHeaders); HttpEntity<?> requestEntity = new HttpEntity(user1, requestHeaders); ResponseEntity<SimpleUser> simpleUserResponseEntity = rest.exchange( "http://" + endpoint + "/audited-users/auditedsave", HttpMethod.POST, requestEntity, SimpleUser.class); // ResponseEntity<SimpleUser> userResponseEntity = // rest.postForEntity("http://" + endpoint + "/audited-users/auditedsave",user1,SimpleUser.class); log.info("got a response"); MatcherAssertionErrors.assertThat(simpleUserResponseEntity.getStatusCode(), Matchers.equalTo(HttpStatus.OK)); }
From source file:org.trustedanalytics.h2oscoringengine.publisher.steps.AppRouteCreatingStepTest.java
@Test public void createAppRoute_oneRouteFound_dontCreateAnotherRoute() throws Exception { // given/* www. j a va 2 s . c om*/ AppRouteCreatingStep step = new AppRouteCreatingStep(restTemplateMock, testCfApi, testAppGuid); // when when(domainsResponseMock.getBody()).thenReturn(validDomainsResponse); when(routesResponseMock.getBody()).thenReturn(oneRouteResponse); step.createAppRoute(testSpaceGuid, testSubdomain); // then verify(restTemplateMock, never()).exchange(eq(testCfCreateRouteEndpoint), same(HttpMethod.POST), eq(HttpCommunication.postRequest(createRouteRequestBody)), same(String.class)); }