private void registerNotifications() { HashMap<String, Object> request = new HashMap<>(); request.put("source_description", "CF_Identity"); request.put("kinds", notifications.values()); notificationsTemplate.put(notificationsUrl + "/registration", request); isNotificationsRegistered = true; } }
private void executeAndVerify() throws URISyntaxException { this.restTemplate.put(new URI("/composers"), this.people); this.mockServer.verify(); }
private void executeAndVerify(Object body) throws URISyntaxException { this.restTemplate.put(new URI("/foo"), body); this.mockServer.verify(); }
private void executeAndVerify() throws URISyntaxException { this.restTemplate.put(new URI("/composers"), this.people); this.mockServer.verify(); }
private void executeAndVerify() throws URISyntaxException { this.restTemplate.put(new URI("/composers"), people); this.mockServer.verify(); }
private <T> T doExecute(HttpMethod method, ServiceDTO service, String path, Object request, Class<T> responseType, Object... uriVariables) { T result = null; switch (method) { case GET: result = restTemplate.getForObject(parseHost(service) + path, responseType, uriVariables); break; case POST: result = restTemplate.postForEntity(parseHost(service) + path, request, responseType, uriVariables).getBody(); break; case PUT: restTemplate.put(parseHost(service) + path, request, uriVariables); break; case DELETE: restTemplate.delete(parseHost(service) + path, uriVariables); break; default: throw new UnsupportedOperationException(String.format("unsupported http method(method=%s)", method)); } return result; }
@Test public void putNull() throws Exception { HttpHeaders requestHeaders = new HttpHeaders(); mockSentRequest(PUT, "http://example.com", requestHeaders); mockResponseStatus(HttpStatus.OK); template.put("http://example.com", null); assertEquals("Invalid content length", 0, requestHeaders.getContentLength()); verify(response).close(); }
@Test public void put() throws Exception { mockTextPlainHttpMessageConverter(); mockSentRequest(PUT, "http://example.com"); mockResponseStatus(HttpStatus.OK); template.put("http://example.com", "Hello World"); verify(response).close(); }
public static ScimGroup createOrUpdateGroup(RestTemplate client, String url, ScimGroup scimGroup) { //dont modify the actual argument LinkedList<ScimGroupMember> members = new LinkedList<>(scimGroup.getMembers()); ScimGroup existing = getGroup(client, url, scimGroup.getDisplayName()); if (existing != null) { members.addAll(existing.getMembers()); } scimGroup.setMembers(members); if (existing != null) { scimGroup.setId(existing.getId()); client.put(url + "/Groups/{id}", scimGroup, scimGroup.getId()); return scimGroup; } else { ResponseEntity<String> group = client.postForEntity(url + "/Groups", scimGroup, String.class); if (group.getStatusCode() == HttpStatus.CREATED) { return JsonUtils.readValue(group.getBody(), ScimGroup.class); } else { throw new IllegalStateException("Invalid return code:" + group.getStatusCode()); } } }
@Override public void put(String url, Object request, Object... urlVariables) throws RestClientException { getRestTemplate(url).put(url, request, urlVariables); }
@Override public void put(URI url, Object request) throws RestClientException { getRestTemplate(url).put(url, request); }
@Override public void put(String url, Object request, Map<String, ?> urlVariables) throws RestClientException { getRestTemplate(url).put(url, request, urlVariables); }
@Override public void execute(RestTemplate restTemplate, String url, Object request) { restTemplate.put(url, request); } },
@Override public void makeDefault(String name, ApplicationType type, String version) { restTemplate.put(appsLink.getHref() + "/{type}/{name}/{version}", null, type, name, version); } }
private void doSetQuotaToOrg(UUID orgGuid, UUID quotaGuid) { String setPath = "/v2/organizations/{org}"; Map<String, Object> setVars = new HashMap<String, Object>(); setVars.put("org", orgGuid); HashMap<String, Object> setRequest = new HashMap<String, Object>(); setRequest.put("quota_definition_guid", quotaGuid); getRestTemplate().put(getUrl(setPath), setRequest, setVars); }
private void doUpdateSecurityGroup(CloudSecurityGroup currentGroup, String name, List<Map<String, Object>> rules) { String path = "/v2/security_groups/{guid}"; Map<String, Object> pathVariables = new HashMap<String, Object>(); pathVariables.put("guid", currentGroup.getMeta() .getGuid()); HashMap<String, Object> request = new HashMap<String, Object>(); request.put("name", name); request.put("rules", rules); // Updates of bindings to spaces and default staging/running groups must be done // through explicit calls to those methods and not through this generic update getRestTemplate().put(getUrl(path), request, pathVariables); }
@Override public void updateApplicationMemory(String appName, int memory) { UUID appId = getApplicationId(appName); HashMap<String, Object> appRequest = new HashMap<String, Object>(); appRequest.put("memory", memory); getRestTemplate().put(getUrl("/v2/apps/{guid}"), appRequest, appId); }
public void updateAspspConsentData(AspspConsentData consentData) { Optional.ofNullable(consentData) .filter(cd -> StringUtils.isNotBlank(cd.getConsentId()) && Objects.nonNull(cd.getAspspConsentData())) .ifPresent(cd -> { String aspspConsentDataBase64 = Optional.ofNullable(cd.getAspspConsentData()) .map(bytes -> Base64.getEncoder().encodeToString(bytes)) .orElse(null); consentRestTemplate.put(getRemoteUrl().updateAspspConsentData(), new Xs2aConsentData(cd.getConsentId(), aspspConsentDataBase64), cd.getConsentId()); }); }
@Override public void updateApplicationStaging(String appName, Staging staging) { UUID appId = getApplicationId(appName); HashMap<String, Object> appRequest = new HashMap<String, Object>(); addStagingToRequest(staging, appRequest); getRestTemplate().put(getUrl("/v2/apps/{guid}"), appRequest, appId); }
@Override public void stopApplication(String appName) { CloudApplication app = getApplication(appName); if (app.getState() != CloudApplication.AppState.STOPPED) { HashMap<String, Object> appRequest = new HashMap<String, Object>(); appRequest.put("state", CloudApplication.AppState.STOPPED); getRestTemplate().put(getUrl("/v2/apps/{guid}"), appRequest, app.getMeta().getGuid()); } }