Example usage for org.springframework.util MultiValueMap set

List of usage examples for org.springframework.util MultiValueMap set

Introduction

In this page you can find the example usage for org.springframework.util MultiValueMap set.

Prototype

void set(K key, @Nullable V value);

Source Link

Document

Set the given single value under the given key.

Usage

From source file:com.github.gabrielruiu.springsocial.yahoo.api.impl.AbstractYahooOperations.java

protected URI buildUri(String path, String parameterName, String parameterValue) {
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
    parameters.set(parameterName, parameterValue);
    return buildUri(path, parameters);
}

From source file:au.org.ala.fielddata.mobile.service.LoginService.java

public LoginResponse login(String username, String password, String portalName) {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();

    params.set("portalName", portalName);
    params.set("username", username);
    params.set("password", password);

    String url = getServerUrl() + loginUrl;

    LoginResponse result = null;/*  w ww.j  a  v a  2 s  .com*/
    try {
        result = getRestTemplate().postForObject(url, params, LoginResponse.class);
    } catch (NullPointerException e) {
        // We are getting SSL connection reset errors - at least in the internal network
        // which manifests itself as a NPE.  A retry is usually all that is required to fix it.
        result = getRestTemplate().postForObject(url, params, LoginResponse.class);
    }
    Preferences prefs = new Preferences(ctx);
    prefs.setFieldDataSessionKey(result.ident);
    prefs.setFieldDataPath(result.portal.path);
    prefs.setFieldDataPortalName(result.portal.name);

    return result;
}

From source file:sample.web.thymeleaf3.SampleWebThymeleaf3ApplicationTests.java

@Test
public void testCreate() throws Exception {
    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.set("text", "FOO text");
    map.set("summary", "FOO");
    URI location = this.restTemplate.postForLocation("/", map);
    assertThat(location.toString()).contains("localhost:" + this.port);
}

From source file:jittr.rest.JittleFacadeRestSecurityIntTest.java

@Test
public void passwordGrant() {
    MultiValueMap<String, String> request = new LinkedMultiValueMap<String, String>();
    request.set("username", "habuma");
    request.set("password", "password");
    request.set("grant_type", "password");
    Map<String, Object> token = testRestTemplate.postForObject("/oauth/token", request, Map.class);
    assertNotNull("Wrong response: " + token, token);
}

From source file:com.miserablemind.api.consumer.tradeking.api.impl.AccountTemplate.java

@Override
public TradeKingTransaction[] getTransactionsHistory(String accountId, TradeKingTransaction.Range range,
        TradeKingTransaction.Type type) {
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.set("range", range.toString());
    parameters.set("transactions", type.toString());

    URI url = this.buildUri(String.format(URL_ACCOUNT_HISTORY, accountId), parameters);
    ResponseEntity<TKHistoryResponse> response = this.getRestTemplate().getForEntity(url,
            TKHistoryResponse.class);
    if (null != response.getBody().getError())
        throw new ApiException(TradeKingServiceProvider.PROVIDER_ID, response.getBody().getError());
    return response.getBody().getTransactionHistory();
}

From source file:io.syndesis.runtime.APITokenRule.java

@Override
protected void after() {
    MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
    map.set("refresh_token", refreshToken);
    map.set("client_id", "admin-cli");
    HttpHeaders headers = new HttpHeaders();
    headers.set("Authorization", "Bearer " + accessToken);
    ResponseEntity<JsonNode> json = restTemplate.postForEntity("http://localhost:" + keycloakPort
            + "/auth/realms/" + keycloakRealm + "/protocol/" + keycloakProtocol + "/logout", map,
            JsonNode.class);
    assertThat(json.getStatusCode()).as("logout status code").isEqualTo(HttpStatus.NO_CONTENT);
}

From source file:com.work.petclinic.MessageControllerWebTests.java

@Test
public void testCreate() throws Exception {
    ResponseEntity<String> page = executeLogin("user", "user");
    page = getPage("http://localhost:" + this.port + "/messages?form");

    String body = page.getBody();
    assertNotNull("Body was null", body);

    MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
    form.set("summary", "summary");
    form.set("messageText", "messageText");
    form.set("_csrf", csrfValue);

    String formAction = getFormAction(page);

    page = postPage(formAction, form);//from   w  w  w. ja  va2  s .  co  m
    body = page.getBody();

    assertTrue("Error creating message.", body == null || body.contains("alert alert-danger"));
    assertTrue("Status was not FOUND (redirect), means message was not created properly.",
            page.getStatusCode() == HttpStatus.FOUND);

    page = getPage(page.getHeaders().getLocation());

    body = page.getBody();
    assertTrue("Error creating message.", body.contains("Successfully created a new message"));
}

From source file:org.agorava.yammer.impl.SubscriptionServiceImpl.java

private MultiValueMap<String, String> toParams(String targetType, long id) {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.set("target_type", targetType);
    params.set("target_id", String.valueOf(id));
    return params;
}

From source file:io.syndesis.runtime.APITokenRule.java

@Override
protected void before() throws Throwable {
    MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
    map.set("username", "user");
    map.set("password", "password");
    map.set("grant_type", "password");
    map.set("client_id", "admin-cli");
    ResponseEntity<JsonNode> json = restTemplate.postForEntity(keycloakScheme + "://" + keycloakHost + ":"
            + keycloakPort + "/auth/realms/" + keycloakRealm + "/protocol/" + keycloakProtocol + "/token", map,
            JsonNode.class);
    assertThat(json.getStatusCode()).as("get token status code").isEqualTo(HttpStatus.OK);
    String token = json.getBody().get("access_token").textValue();
    assertThat(token).as("access token").isNotEmpty();
    accessToken = token;/*from  ww w . ja va2  s .  co  m*/
    String refreshToken = json.getBody().get("refresh_token").textValue();
    assertThat(token).as("refresh token").isNotEmpty();
    this.refreshToken = refreshToken;
}

From source file:comsat.sample.ui.SampleGroovyTemplateApplicationTests.java

@Test
public void testCreate() throws Exception {
    MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
    map.set("text", "FOO text");
    map.set("summary", "FOO");
    URI location = new TestRestTemplate().postForLocation("http://localhost:" + this.port, map);
    assertTrue("Wrong location:\n" + location, location.toString().contains("localhost:" + this.port));
}