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:svc.data.citations.datasources.tyler.TylerCitationDataSourceTest.java

@SuppressWarnings("unchecked")
@Test/*from  w  w w. j  a va  2 s  .  c  o m*/
public void returnsCitationsGivenLicenseAndDOB() {
    final String DRIVERSLICENSENUMBER = "ABCDE";
    final String DRIVERSLICENSESTATE = "AZ";
    final LocalDate DOB = LocalDate.parse("2000-06-01");
    mockTylerConfiguration.rootUrl = "http://myURL.com";
    mockTylerConfiguration.apiKey = "1234";
    final Citation CITATION = new Citation();
    CITATION.id = 3;
    final List<Citation> CITATIONS = Lists.newArrayList(CITATION);
    final List<TylerCitation> tylerCitations = Lists.newArrayList();
    Mockito.doReturn(tylerCitations).when(tylerCitationsResponseSpy).getBody();

    when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET), any(HttpEntity.class),
            any(ParameterizedTypeReference.class))).thenReturn(tylerCitationsResponseSpy);

    when(mockCitationTransformer.fromTylerCitations(tylerCitations)).thenReturn(CITATIONS);
    when(mockCitationFilter.RemoveCitationsWithExpiredDates(CITATIONS)).thenReturn(CITATIONS);

    List<Citation> citations = mockTylerCitationDataSource.getByLicenseAndDOB(DRIVERSLICENSENUMBER,
            DRIVERSLICENSESTATE, DOB);

    assertThat(citations.get(0).id, is(3));
}

From source file:fi.okm.mpass.shibboleth.profile.impl.BuildMetaRestResponse.java

/** {@inheritDoc} */
@Override/*  w  w  w.j  a  v a2s  . co  m*/
@Nonnull
public Event execute(@Nonnull final RequestContext springRequestContext) {
    ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
    final HttpServletRequest httpRequest = getHttpServletRequest();
    pushHttpResponseProperties();
    final HttpServletResponse httpResponse = getHttpServletResponse();

    try {
        final Writer out = new OutputStreamWriter(httpResponse.getOutputStream(), "UTF-8");

        if (!HttpMethod.GET.toString().equals(httpRequest.getMethod())) {
            log.warn("{}: Unsupported method attempted {}", getLogPrefix(), httpRequest.getMethod());
            out.append(makeErrorResponse(HttpStatus.SC_METHOD_NOT_ALLOWED,
                    httpRequest.getMethod() + " not allowed", "Only GET is allowed"));
        } else if (metaDTO != null) {
            final Gson gson = new Gson();
            out.append(gson.toJson(getMetaDTO()));
            httpResponse.setStatus(HttpStatus.SC_OK);
        } else {
            out.append(
                    makeErrorResponse(HttpStatus.SC_NOT_IMPLEMENTED, "Not implemented on the server side", ""));
        }
        out.flush();
    } catch (IOException e) {
        log.error("{}: Could not encode the JSON response", getLogPrefix(), e);
        httpResponse.setStatus(HttpStatus.SC_SERVICE_UNAVAILABLE);
        return ActionSupport.buildEvent(this, EventIds.IO_ERROR);
    }
    return ActionSupport.buildProceedEvent(this);
}

From source file:org.zalando.github.spring.pagination.PagingIterator.java

protected ResponseEntity<E> getReponseEntity() {
    if (responseType != null) {
        return restOperations.exchange(uri, HttpMethod.GET, null, responseType);
    } else {/*from  www.ja v  a 2 s .  co  m*/
        return restOperations.exchange(uri, HttpMethod.GET, null, parameterizedTypeReference);
    }
}

From source file:com.gopivotal.cla.github.GitHubConditionalTest.java

@Test
public void notCollection() {
    ResponseEntity<String> response = new ResponseEntity<String>("", HttpStatus.OK);
    when(this.restOperations.exchange(URL, HttpMethod.GET, REQUEST_ENTITY, String.class)).thenReturn(response);

    StubNonCollectionGitHubType nonCollectionGitHubType = new StubNonCollectionGitHubType(URL);

    nonCollectionGitHubType.getTrigger();

    assertTrue(nonCollectionGitHubType.initializedCalled);
}

From source file:com.appglu.impl.UserTemplate.java

/**
 * {@inheritDoc}/*w w  w  .  j a v a  2 s  .  c  o  m*/
 */
public void refreshUserProfile() throws AppGluRestClientException {
    try {
        ResponseEntity<UserBody> response = this.restOperations.exchange(ME_URL, HttpMethod.GET, null,
                UserBody.class);
        this.saveAuthenticatedUser(response);
    } catch (AppGluHttpUserUnauthorizedException e) {
        this.userSessionPersistence.logout();
        throw e;
    } catch (RestClientException e) {
        throw new AppGluRestClientException(e.getMessage(), e);
    }
}

From source file:org.zalando.github.spring.OrganizationTemplateTest.java

@Test
public void getOrganization() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/orgs/zalando-stups")).andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(//from www.j a  v a2s  . co m
                    withSuccess(new ClassPathResource("getOrga.json", getClass()), MediaType.APPLICATION_JSON));

    ExtOrganization orga = usersTemplate.getOrganization("zalando-stups");

    Assertions.assertThat(orga).isNotNull();
    Assertions.assertThat(orga.getName()).isEqualTo("zalando-stups");
    Assertions.assertThat(orga.getLogin()).isEqualTo("zalando-stups");
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.steps.CreatingPlanVisibilityStep.java

private String getServicePlanGuid(String serviceGuid) throws IOException {
    String cfServicePlanUrl = cfApiUrl + GET_SERVICE_PLANS_ENDPOINT_TEMPLATE;
    ResponseEntity<String> response = cfRestTemplate.exchange(cfServicePlanUrl, HttpMethod.GET,
            HttpCommunication.simpleJsonRequest(), String.class, serviceGuid);

    return JsonDataFetcher.getStringValue(response.getBody(), FIRST_SERVICE_PLAN_GUID);

}

From source file:org.jasig.portlet.degreeprogress.dao.xml.HttpDegreeProgressDaoImpl.java

@Override
public DegreeProgressReport getProgressReport(PortletRequest request) {
    Map<String, String> params = createParameters(request, urlParams);
    if (log.isDebugEnabled()) {
        log.debug("Invoking uri '" + degreeProgressUrlFormat + "' with the following parameters:  "
                + params.toString());//from   w w w  .  ja v a2  s  .co m
    }

    HttpEntity<?> requestEntity = getRequestEntity(request);
    HttpEntity<DegreeProgressReport> response = restTemplate.exchange(degreeProgressUrlFormat, HttpMethod.GET,
            requestEntity, DegreeProgressReport.class, params);

    DegreeProgressReport report = response.getBody();
    for (DegreeRequirementSection section : report.getDegreeRequirementSections()) {
        for (JAXBElement<? extends GeneralRequirementType> requirement : section.getGeneralRequirements()) {
            GeneralRequirementType req = requirement.getValue();
            if (req instanceof GpaRequirement) {
                section.setRequiredGpa(((GpaRequirement) req).getRequiredGpa());
            }
        }
        for (CourseRequirement req : section.getCourseRequirements()) {
            for (Course course : req.getCourses()) {
                StudentCourseRegistration registration = new StudentCourseRegistration();
                registration.setCredits(course.getCredits());
                registration.setSource(course.getSource());
                registration.setSemester(course.getSemester());
                registration.setCourse(course);
                Grade grade = new Grade();
                grade.setCode(course.getGrade().getCode());
                registration.setGrade(grade);
                req.getRegistrations().add(registration);
            }
        }
        report.addSection(section);
    }
    return report;
}

From source file:org.zalando.github.spring.IssuesTemplateTest.java

@Test
public void listOrgaIssues() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/orgs/zalando-stups/issues?per_page=25"))
            .andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("listIssues.json", getClass()),
                    MediaType.APPLICATION_JSON));

    List<Issue> issueList = issuesTemplate.listOrganizationIssues("zalando-stups");

    Assertions.assertThat(issueList).isNotNull();
    Assertions.assertThat(issueList.size()).isEqualTo(1);
    Assertions.assertThat(issueList.get(0).getId()).isEqualTo(1);
}

From source file:com.organization.projectname.config.WebSecurityConfig.java

@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
    httpSecurity//from   w ww .  java  2  s.  c  om
            // we don't need CSRF because our token is invulnerable
            .csrf().disable().exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
            // don't create session
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
            .authorizeRequests()
            //.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()

            // allow anonymous resource requests
            .antMatchers(HttpMethod.GET, "/", "/*.html", "/favicon.ico", "/**/*.html", "/**/*.css", "/**/*.js")
            .permitAll().antMatchers("/api/v1/auth").permitAll().antMatchers("/api/v1/").permitAll()
            .antMatchers("/api/v1/admin").hasRole("ADMIN").anyRequest().authenticated();

    // Custom JWT based security filter
    httpSecurity.addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);

    // disable page caching
    httpSecurity.headers().cacheControl();
}