@Override public List<String> remove(Object key) { return this.headers.remove(key); }
@Override public List<String> remove(Object key) { return this.headers.remove(key); }
public List<String> remove(Object key) { return parameters.remove(key); }
/** * Set the query parameter values overriding all existing query values for * the same parameter. If no values are given, the query parameter is removed. * @param name the query parameter name * @param values the query parameter values * @return this UriComponentsBuilder */ @Override public UriComponentsBuilder replaceQueryParam(String name, Object... values) { Assert.notNull(name, "Name must not be null"); this.queryParams.remove(name); if (!ObjectUtils.isEmpty(values)) { queryParam(name, values); } resetSchemeSpecificPart(); return this; }
/** * Set the query parameter values overriding all existing query values for * the same parameter. If no values are given, the query parameter is removed. * @param name the query parameter name * @param values the query parameter values * @return this UriComponentsBuilder */ @Override public UriComponentsBuilder replaceQueryParam(String name, Object... values) { Assert.notNull(name, "Name must not be null"); this.queryParams.remove(name); if (!ObjectUtils.isEmpty(values)) { queryParam(name, values); } resetSchemeSpecificPart(); return this; }
@Test public void testWithCommaSeparatedStringArray() throws Exception { MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); formData.add("stringArray", "bar"); formData.add("stringArray", "abc"); formData.add("stringArray", "123,def"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertEquals("Expected all three items to be bound", 3, this.testBean.getStringArray().length); formData.remove("stringArray"); formData.add("stringArray", "123,def"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertEquals("Expected only 1 item to be bound", 1, this.testBean.getStringArray().length); }
@Test public void testFieldPrefixCausesFieldReset() throws Exception { MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); formData.add("_postProcessed", "visible"); formData.add("postProcessed", "on"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertTrue(this.testBean.isPostProcessed()); formData.remove("postProcessed"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertFalse(this.testBean.isPostProcessed()); }
@Test public void testFieldDefault() throws Exception { MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); formData.add("!postProcessed", "off"); formData.add("postProcessed", "on"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertTrue(this.testBean.isPostProcessed()); formData.remove("postProcessed"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertFalse(this.testBean.isPostProcessed()); }
@Test public void testFieldDefaultNonBoolean() throws Exception { MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); formData.add("!name", "anonymous"); formData.add("name", "Scott"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertEquals("Scott", this.testBean.getName()); formData.remove("name"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertEquals("anonymous", this.testBean.getName()); }
@Test public void testFieldDefaultPreemptsFieldMarker() throws Exception { MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); formData.add("!postProcessed", "on"); formData.add("_postProcessed", "visible"); formData.add("postProcessed", "on"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertTrue(this.testBean.isPostProcessed()); formData.remove("postProcessed"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertTrue(this.testBean.isPostProcessed()); formData.remove("!postProcessed"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertFalse(this.testBean.isPostProcessed()); }
@Test public void testFieldPrefixCausesFieldResetWithIgnoreUnknownFields() throws Exception { this.binder.setIgnoreUnknownFields(false); MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); formData.add("_postProcessed", "visible"); formData.add("postProcessed", "on"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertTrue(this.testBean.isPostProcessed()); formData.remove("postProcessed"); this.binder.bind(exchange(formData)).block(Duration.ofMillis(5000)); assertFalse(this.testBean.isPostProcessed()); }
switch (scheme) { case header: form.remove("client_secret"); headers.add( "Authorization",
private void bindIndexed(ConfigurationPropertySource source, ConfigurationPropertyName root, AggregateElementBinder elementBinder, IndexedCollectionSupplier collection, ResolvableType elementType) { MultiValueMap<String, ConfigurationProperty> knownIndexedChildren = getKnownIndexedChildren( source, root); for (int i = 0; i < Integer.MAX_VALUE; i++) { ConfigurationPropertyName name = root .append((i != 0) ? "[" + i + "]" : INDEX_ZERO); Object value = elementBinder.bind(name, Bindable.of(elementType), source); if (value == null) { break; } knownIndexedChildren.remove(name.getLastElement(Form.UNIFORM)); collection.get().add(value); } assertNoUnboundChildren(knownIndexedChildren); }
@Test @OAuth2ContextConfiguration(LoginClient.class) public void testMissingUserInfoIsError() throws Exception { params.set("client_id", testAccounts.getDefaultImplicitResource().getClientId()); params.remove("username"); @SuppressWarnings("rawtypes") ResponseEntity<Map> response = serverRunning.postForMap(serverRunning.getAuthorizationUri(), params, headers); assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); @SuppressWarnings("unchecked") Map<String, String> results = response.getBody(); assertNotNull("There should be an error: " + results, results.containsKey("error")); }
@Test @OAuth2ContextConfiguration(LoginClient.class) public void testMissingUsernameIsError() throws Exception { ((RestTemplate) serverRunning.getRestTemplate()) .setRequestFactory(new HttpComponentsClientHttpRequestFactory()); params.set("client_id", testAccounts.getDefaultImplicitResource().getClientId()); params.remove("username"); // Some of the user info is there but not enough to determine a username params.set("given_name", "Mabel"); @SuppressWarnings("rawtypes") ResponseEntity<Map> response = serverRunning.postForMap(serverRunning.getAuthorizationUri(), params, headers); assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); @SuppressWarnings("unchecked") Map<String, String> results = response.getBody(); assertNotNull("There should be an error: " + results, results.containsKey("error")); }
@Test @OAuth2ContextConfiguration(LoginClient.class) public void testAddNewUserWithWrongEmailFormat() throws Exception { ((RestTemplate) serverRunning.getRestTemplate()) .setRequestFactory(new HttpComponentsClientHttpRequestFactory()); params.set("client_id", testAccounts.getDefaultImplicitResource().getClientId()); params.set("source","login"); params.set("username", "newuser"); params.remove("given_name"); params.remove("family_name"); params.set("email", "noAtSign"); params.set(UaaAuthenticationDetails.ADD_NEW, "true"); @SuppressWarnings("rawtypes") ResponseEntity<Map> response = serverRunning.postForMap(serverRunning.getAuthorizationUri(), params, headers); assertNotNull(response); assertNotEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); assertEquals(HttpStatus.FOUND, response.getStatusCode()); @SuppressWarnings("unchecked") Map<String, String> results = response.getBody(); if (results != null) { assertFalse("There should not be an error: " + results, results.containsKey("error")); } }
public IoParameters removeAllOf(String key) { MultiValueMap<String, JsonNode> newValues = new LinkedMultiValueMap<>(query); newValues.remove(key.toLowerCase()); return new IoParameters(newValues); }
/** * Creates a new instance based on the current one and removes given parameter with the all its values. As * a new instance is created the current one stays unchanged (unmutable instance) and can be reused as is. * * @param key * the name of the parameter to remove all its values * @return a new instance with extended key/values */ public IoParameters removeAllOf(String key) { MultiValueMap<String, JsonNode> newValues = new LinkedMultiValueMap<>(query); newValues.remove(key.toLowerCase()); return new IoParameters(newValues).setParseExceptionHandle(parseExceptionHandle); }
@Override protected AccessGrant postForAccessGrant(String accessTokenUrl, MultiValueMap<String, String> parameters) { if ("authorization_code".equals(parameters.getFirst("grant_type"))) { parameters.set("appid", parameters.getFirst("client_id")); parameters.set("secret", parameters.getFirst("client_secret")); parameters.remove("client_id"); parameters.remove("client_secret"); } return super.postForAccessGrant(accessTokenUrl, parameters); }
public void removeConnection(ConnectionKey connectionKey) { connectionKeyConnectionMap.remove(connectionKey); List<Connection<?>> connections = providerIdConnectionMap.get(connectionKey.getProviderId()); providerIdConnectionMap.remove(connectionKey.getProviderId()); // remove them all for (Connection<?> connection : connections) { // add back any that don't have the same key if (!connection.getKey().equals(connectionKey)) { providerIdConnectionMap.add(connectionKey.getProviderId(), connection); } } }