Example usage for org.springframework.http HttpMethod GET

List of usage examples for org.springframework.http HttpMethod GET

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod GET.

Prototype

HttpMethod GET

To view the source code for org.springframework.http HttpMethod GET.

Click Source Link

Usage

From source file:org.sitenv.referenceccda.services.VocabularyService.java

public Map<String, Map<String, List<String>>> getMapOfSenderAndRecieverValidationObjectivesWithReferenceFiles() {
    RestTemplate restTemplate = new RestTemplate();
    ResponseEntity<GithubResponseWrapper> responseEntity = restTemplate.exchange(GITHUB_URL, HttpMethod.GET,
            null, new ParameterizedTypeReference<GithubResponseWrapper>() {
            });// www .  j av  a  2s  .  c  o  m

    Map<String, Map<String, List<String>>> messageTypeValidationObjectiveReferenceFilesMap = new HashMap<>();
    for (TestDataTreeWrapper testDataTreeWrapper : responseEntity.getBody().getTree()) {
        if (!(testDataTreeWrapper.getPath().equalsIgnoreCase("license")
                || testDataTreeWrapper.getPath().equalsIgnoreCase("README.md"))) {
            if (isMessageTypeInMap(messageTypeValidationObjectiveReferenceFilesMap, testDataTreeWrapper)) {
                if (isValidationObjectiveInMap(messageTypeValidationObjectiveReferenceFilesMap,
                        testDataTreeWrapper)) {
                    addReferenceFileNameToListInValidationObjectiveMap(
                            messageTypeValidationObjectiveReferenceFilesMap, testDataTreeWrapper);
                } else {
                    addValidationObjectiveToMap(messageTypeValidationObjectiveReferenceFilesMap,
                            testDataTreeWrapper);
                }
            } else {
                addMessageTypeToMap(messageTypeValidationObjectiveReferenceFilesMap, testDataTreeWrapper);
            }
        }
    }
    return messageTypeValidationObjectiveReferenceFilesMap;
}

From source file:io.syndesis.runtime.credential.CredentialITCase.java

@Test
public void callbackErrorsShouldBeHandeled() {
    final String credentialKey = UUID.randomUUID().toString();
    final OAuth2CredentialFlowState flowState = new OAuth2CredentialFlowState.Builder()
            .providerId("test-provider").key(credentialKey).returnUrl(URI.create("/ui#state")).build();

    final HttpHeaders cookies = persistAsCookie(flowState);

    final ResponseEntity<Void> callbackResponse = http(HttpMethod.GET,
            "/api/v1/credentials/callback?denied=something", null, Void.class, null, cookies,
            HttpStatus.TEMPORARY_REDIRECT);

    assertThat(callbackResponse.getStatusCode()).as("Status should be temporarry redirect (307)")
            .isEqualTo(HttpStatus.TEMPORARY_REDIRECT);
    assertThat(callbackResponse.hasBody()).as("Should not contain HTTP body").isFalse();
    assertThat(callbackResponse.getHeaders().getLocation().toString()).matches(
            "http.?://localhost:[0-9]*/api/v1/ui#%7B%22connectorId%22:%22test-provider%22,%22message%22:%22Unable%20to%20update%20the%20state%20of%20authorization%22,%22status%22:%22FAILURE%22%7D");

    final List<String> receivedCookies = callbackResponse.getHeaders().get("Set-Cookie");
    assertThat(receivedCookies).hasSize(1);
    assertThat(receivedCookies.get(0)).isEqualTo("cred-o2-" + credentialKey
            + "=\"\"; path=/; secure; HttpOnly; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:00 GMT");
}

From source file:org.n52.restfulwpsproxy.wps.GetStatusClient.java

public ExceptionReportDocument getExceptions(String processId, String jobId) {
    HttpEntity<?> requestEntity = new HttpEntity<Object>(null, headers);

    ResponseEntity<ExceptionReportDocument> resultDocument = restTemplate.exchange(
            new RequestUrlBuilder(GET_RESULT).jobID(jobId).build(), HttpMethod.GET, requestEntity,
            ExceptionReportDocument.class);

    return resultDocument.getBody();
}

From source file:com.opensearchserver.hadse.index.IndexTest.java

@Test
public void t03_exists() {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));

    RestTemplate template = new RestTemplate();

    ResponseEntity<String> entity = template.exchange("http://localhost:8080/my_index", HttpMethod.GET, null,
            String.class);

    assertEquals(HttpStatus.FOUND, entity.getStatusCode());
}

From source file:de.zib.gndms.gndmc.test.gorfx.ESGFGet.java

@Override
protected void run() throws Exception {

    SetupSSL setupSSL = new SetupSSL();
    setupSSL.setKeyStoreLocation(keyStoreLocation);
    setupSSL.prepareKeyStore(passwd, passwd);
    setupSSL.setupDefaultSSLContext(passwd);

    final RestTemplate rt = new RestTemplate();

    rt.execute(url, HttpMethod.GET, null, new ResponseExtractor<Object>() {
        @Override/* ww  w . ja  v  a2  s  . co m*/
        public Object extractData(final ClientHttpResponse response) throws IOException {

            String url = null;
            String cookieTmp = null;
            System.out.println(response.getStatusCode().toString());
            for (String s : response.getHeaders().keySet())
                for (String v : response.getHeaders().get(s)) {
                    System.out.println(s + ":" + v);
                    if ("Location".equals(s))
                        url = v;
                    else if ("Set-Cookie".equals(s))
                        cookieTmp = v;
                }
            final String cookie = cookieTmp.split(";")[0];

            if (url != null)
                rt.execute(decodeUrl(url), HttpMethod.GET, new RequestCallback() {
                    @Override
                    public void doWithRequest(final ClientHttpRequest request) throws IOException {

                        System.out.println("setting cookie: " + cookie);
                        request.getHeaders().set("Cookie", cookie);
                    }
                }, new ResponseExtractor<Object>() {
                    @Override
                    public Object extractData(final ClientHttpResponse response) throws IOException {

                        System.out.println(response.getStatusCode().toString());
                        System.out.println("Received data, copying");
                        InputStream is = response.getBody();
                        OutputStream os = new FileOutputStream(off);
                        StreamCopyNIO.copyStream(is, os);
                        System.out.println("Done");
                        return null;
                    }
                });

            return null;
        }
    });
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.http.FilesDownloaderTest.java

@Test
public void download_serverResponse200_resourcesDownloaded() throws Exception {
    // given//from   w  w  w. j a va2  s  . com
    FilesDownloader downloader = new FilesDownloader(testCredentials, restTemplateMock);

    // when
    when(responseMock.getBody()).thenReturn(testServerResponse.getBytes());
    downloader.download(testResource, testPath);

    // then
    verify(restTemplateMock).exchange(testCredentials.getHost() + testResource, HttpMethod.GET,
            HttpCommunication.basicAuthRequest(testCredentials.getBasicAuthToken()), byte[].class);
    assertThat(new String(Files.readAllBytes(testPath)), equalTo(testServerResponse));
}

From source file:fi.helsinki.opintoni.server.FlammaServer.java

public void expectEnglishTeacherNews() {
    server.expect(requestTo(flammaBaseUrl + "/infotaulu/atom-tiedotteet-opetusasiat-en.xml"))
            .andExpect(method(HttpMethod.GET))
            .andRespond(withSuccess(toText("flamma/englishteachernews.xml"), MediaType.TEXT_XML));
}

From source file:org.openlmis.fulfillment.service.referencedata.BaseReferenceDataService.java

<P> P get(Class<P> type, String resourceUrl, RequestParameters parameters) {
    String url = getServiceUrl() + getUrl() + resourceUrl;

    ResponseEntity<P> response = restTemplate.exchange(createUri(url, parameters), HttpMethod.GET,
            createEntity(), type);/*  w  w w.j  av  a2s  .co  m*/

    return response.getBody();
}

From source file:ca.qhrtech.services.implementations.BGGServiceImpl.java

/**
 * Consumes a BGG XML API End Point and converts the response to a usable
 * POJO using the passed converter/* www. j ava 2 s  .  c o  m*/
 *
 * @param <T> - Class the response should expect
 * @param <K> - Class the converter produces
 * @param uri - end point
 * @param t - Class the response should expect
 * @param converter - converts T to K
 * @return - results of the conversion
 */
private <T, K> K consumeBggApi(URI uri, Class<T> t, Converter<T, K> converter) {
    RestTemplate template = new RestTemplate();
    ResponseEntity<T> response;
    response = template.exchange(uri, HttpMethod.GET, buildXmlHttpHeader(), t);
    return converter.convert(response.getBody());
}