Example usage for org.springframework.util MultiValueMap add

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

Introduction

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

Prototype

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

Source Link

Document

Add the given single value to the current list of values for the given key.

Usage

From source file:eu.cloudwave.wp5.monitoring.rest.FeedbackHandlerMonitoringClient.java

/**
 * Sends monitoring data (i.e. the call trace) and its attached metrics to the Feedback Handler.
 * /*from   www.  j av a 2  s .c  o m*/
 * @param executions
 *          the {@link RunningProcedureExecution}'s (i.e. the call trace)
 * @return <code>true</code> if the data has been successfully sent to the Feedback Handler, <code>false</code>
 *         otherwise
 */
public boolean postData(final RunningProcedureExecution rootProcedureExecution) {
    final MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
    headers.add(Headers.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
    headers.add(Headers.ACCESS_TOKEN, accessToken());
    headers.add(Headers.APPLICATION_ID, applicationId());
    final HttpEntity<MetricContainingProcedureExecutionDto> httpEntity = new HttpEntity<MetricContainingProcedureExecutionDto>(
            rootProcedureExecution, headers);
    final ResponseEntity<Boolean> result = new RestTemplate().exchange(url(), HttpMethod.POST, httpEntity,
            Boolean.class);
    return result.getBody();
}

From source file:org.intermine.app.net.request.post.FetchListResultsRequest.java

@Override
public MultiValueMap<String, String> getPost() {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add(FORMAT_PARAM, JSON);
    params.add(QUERY_PARAM, mQuery);//from  w  w  w .  j  a va 2s.c  o m

    if (mSize > 0) {
        params.add(START_PARAM, Integer.toString(mStart));
        params.add(SIZE_PARAM, Integer.toString(mSize));
    }
    return params;
}

From source file:org.nekorp.workflow.desktop.data.access.rest.ImagenDAOImp.java

@Override
public ImagenMetadata saveImage(BufferedImage image) {
    try {/*w  w w. ja  va  2s  . c om*/
        ImagenMetadata r = factory.getTemplate().getForObject(factory.getRootUlr() + "/upload/url",
                ImagenMetadata.class);
        File file = new File("data/upload.jpg");
        ImageIO.write(image, "jpg", file);
        MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
        form.add("myFile", new FileSystemResource(file));
        r = factory.getTemplate().postForObject(r.getUploadUrl(), form, ImagenMetadata.class);
        File cache = new File("data/" + r.getRawBlobKey());
        file.renameTo(cache);
        return r;
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:de.codecentric.batch.FlatFileJobIntegrationTest.java

protected ExitStatus runJobAndWaitForCompletion(String hostname, String port, String jobName,
        String jobParameters) throws InterruptedException {
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
    parameters.add("jobParameters", jobParameters);
    String jobExecutionId = restTemplate.postForObject(
            "http://" + hostname + ":" + port + "/batch/operations/jobs/" + jobName + "", parameters,
            String.class);
    ExitStatus exitStatus = getStatus(hostname, port, jobExecutionId);
    // Wait for end of job
    while (exitStatus.isRunning()) {
        Thread.sleep(100);//from   w w  w .j a va 2s.c  o  m
        exitStatus = getStatus(hostname, port, jobExecutionId);
    }
    return exitStatus;
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.restapi.validation.UsernameValidationRuleTest.java

@Test
public void validate_allDataValid_doesntThrowException() {
    // given//from   w  w  w . ja  va  2 s. c  om
    MultiValueMap<String, String> requestWithUsername = new LinkedMultiValueMap<>();
    requestWithUsername.add(UsernameValidationRule.USERNAME_KEY, "some-username");
    UsernameValidationRule rule = new UsernameValidationRule(new FormDataValidator());

    // when
    rule.validate(requestWithUsername);

    // then
    // no exception is thrown
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.restapi.validation.PasswordValidationRuleTest.java

@Test
public void validate_allDataValid_doesntThrowException() {
    //given/*from  w  ww.ja v a2s . co m*/
    MultiValueMap<String, String> requestWithPassword = new LinkedMultiValueMap<>();
    requestWithPassword.add(PasswordValidationRule.PASSWORD_KEY, "some-password");
    PasswordValidationRule rule = new PasswordValidationRule(new FormDataValidator());

    //when
    rule.validate(requestWithPassword);

    //then
    // no exception is thrown
}

From source file:fr.keemto.web.LoginWebIT.java

@Test
public void shouldAuthenticateUserWithValidCredentials() {

    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.add(USERNAME_PARAM, VALID_USERNAME);
    params.add(PASSWORD_PARAM, "test");

    LoginStatus status = template.postForObject(URL, params, LoginStatus.class);

    assertThat(status.isLoggedIn(), is(true));
    assertThat(status.getUsername(), equalTo(VALID_USERNAME));
}

From source file:fr.keemto.web.LoginWebIT.java

@Test
public void shouldRejectInvalidUsername() {

    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.add(USERNAME_PARAM, "invalid-login");
    params.add(PASSWORD_PARAM, "fake");

    LoginStatus status = template.postForObject(URL, params, LoginStatus.class);

    assertThat(status.isLoggedIn(), is(false));
    assertThat(status.getUsername(), equalTo("invalid-login"));

}

From source file:fr.keemto.web.LoginWebIT.java

@Test
public void shouldRejectValidUserWithWrongCredentials() {

    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.add(USERNAME_PARAM, VALID_USERNAME);
    params.add(PASSWORD_PARAM, "invalid");

    LoginStatus status = template.postForObject(URL, params, LoginStatus.class);

    assertThat(status.isLoggedIn(), is(false));
    assertThat(status.getUsername(), equalTo(VALID_USERNAME));

}

From source file:org.trustedanalytics.h2oscoringengine.publisher.restapi.validation.UsernameValidationRuleTest.java

@Test
public void validate_emptyUsernameKeyInData_exceptionThrown() {
    // given/*from w  w w  .j  a v  a 2s.  c o m*/
    MultiValueMap<String, String> requestWithEmptyUsernameKey = new LinkedMultiValueMap<>();
    requestWithEmptyUsernameKey.add(UsernameValidationRule.USERNAME_KEY, "");
    UsernameValidationRule rule = new UsernameValidationRule(new FormDataValidator());

    // then
    thrown.expect(ValidationException.class);

    // when
    rule.validate(requestWithEmptyUsernameKey);
}