Search in sources :

Example 91 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project openlmis-stockmanagement by OpenLMIS.

the class UuidUtilTest method shouldRetrieveIdsFromMap.

@Test
public void shouldRetrieveIdsFromMap() {
    UUID id1 = randomUUID();
    UUID id2 = randomUUID();
    UUID id3 = randomUUID();
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add(ID, id1.toString());
    params.add(ID, id2.toString());
    params.add(ID, id3.toString());
    params.add("ids", randomUUID());
    params.add("someParameter", randomUUID());
    assertThat(UuidUtil.getIds(params), hasItems(id1, id2, id3));
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) UUID.randomUUID(java.util.UUID.randomUUID) UUID(java.util.UUID) Test(org.junit.Test)

Example 92 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project SONG by overture-stack.

the class InfoSearchTest method search2.

@SneakyThrows
private List<InfoSearchResponse> search2(boolean includeInfo, String... searchTermStrings) {
    val searchTerms = parseSearchTerms(searchTermStrings);
    val map = new LinkedMultiValueMap<String, String>();
    searchTerms.forEach(x -> map.put(x.getKey(), newArrayList(x.getValue())));
    return service.infoSearch(STUDY, includeInfo, map);
}
Also used : lombok.val(lombok.val) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) SneakyThrows(lombok.SneakyThrows)

Example 93 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project carina by qaprosoft.

the class HockeyAppManager method scanAppForBuild.

/**
 * @param appIds takes in the application Ids
 * @param buildType takes in the particular build to download (i.e. Prod.AdHoc, QA.Debug, Prod-Release, QA-Internal etc...)
 * @param version takes in either "latest" to take the first build that matches the criteria or allows to consume a version to download that
 *            build.
 * @return
 */
private String scanAppForBuild(List<String> appIds, String buildType, String version) {
    for (String appId : appIds) {
        MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        queryParams.add("page", "1");
        queryParams.add("include_build_urls", "true");
        RequestEntity<String> retrieveBuilds = buildRequestEntity(hockeyAppUrl, "api/2/apps/" + appId + "/app_versions", queryParams, HttpMethod.GET);
        JsonNode buildResults = restTemplate.exchange(retrieveBuilds, JsonNode.class).getBody();
        for (JsonNode node : buildResults.get("app_versions")) {
            if (checkBuild(version, node) && checkTitleForCorrectPattern(buildType.toLowerCase(), node) || checkNotesForCorrectBuild(buildType.toLowerCase(), node)) {
                LOGGER.info("Downloading Version: " + node);
                versionNumber = node.get("shortversion").asText();
                revision = node.get("version").asText();
                List<String> packageUrls = new ArrayList<>();
                packageUrls.add("build_url");
                packageUrls.add("download_url");
                for (String packageUrl : packageUrls) {
                    if (node.has(packageUrl)) {
                        return node.get(packageUrl).asText();
                    }
                }
            }
        }
    }
    throw new RuntimeException(String.format("Unable to find build to download, version provided (%s)", version));
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 94 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project spring-data-commons by spring-projects.

the class ReflectionRepositoryInvokerUnitTests method failedParameterConversionCapturesContext.

// DATACMNS-700
@Test
public void failedParameterConversionCapturesContext() throws Exception {
    RepositoryInvoker invoker = getInvokerFor(mock(SimpleRepository.class));
    MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
    parameters.add("value", "value");
    Method method = SimpleRepository.class.getMethod("findByClass", int.class);
    try {
        invoker.invokeQueryMethod(method, parameters, Pageable.unpaged(), Sort.unsorted());
    } catch (QueryMethodParameterConversionException o_O) {
        assertThat(o_O.getParameter()).isEqualTo(new MethodParameters(method).getParameters().get(0));
        assertThat(o_O.getSource()).isEqualTo("value");
        assertThat(o_O.getCause()).isInstanceOf(ConversionFailedException.class);
    }
}
Also used : ConversionFailedException(org.springframework.core.convert.ConversionFailedException) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 95 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project spring-data-commons by spring-projects.

the class ReflectionRepositoryInvokerUnitTests method considersFormattingAnnotationsOnQueryMethodParameters.

// DATACMNS-589
@Test
public void considersFormattingAnnotationsOnQueryMethodParameters() throws Exception {
    MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
    parameters.add("date", "2013-07-18T10:49:00.000+02:00");
    Method method = PersonRepository.class.getMethod("findByCreatedUsingISO8601Date", Date.class, Pageable.class);
    PersonRepository repository = mock(PersonRepository.class);
    getInvokerFor(repository, expectInvocationOf(method)).invokeQueryMethod(method, parameters, Pageable.unpaged(), Sort.unsorted());
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) PersonRepository(org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)427 Test (org.junit.Test)159 HttpHeaders (org.springframework.http.HttpHeaders)135 MultiValueMap (org.springframework.util.MultiValueMap)102 Test (org.junit.jupiter.api.Test)88 HttpEntity (org.springframework.http.HttpEntity)70 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)45 List (java.util.List)44 HashMap (java.util.HashMap)38 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)37 MediaType (org.springframework.http.MediaType)35 URI (java.net.URI)34 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)33 Map (java.util.Map)32 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)30 ArrayList (java.util.ArrayList)29 IOException (java.io.IOException)27 UUID (java.util.UUID)27 lombok.val (lombok.val)27 Autowired (org.springframework.beans.factory.annotation.Autowired)26