Package com.jayway.restassured.specification

Examples of com.jayway.restassured.specification.RequestSpecification


  public void testCompleteGetParameters() {
   
    Map<String, String> queryParameters = getCompleteStringQueryParameters();
    queryParameters.put("memberOfGroup", MockProvider.EXAMPLE_GROUP_ID);
   
    RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
    for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
      requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
    }
   
    requestSpecification.expect().statusCode(Status.OK.getStatusCode())
      .when().get(USER_QUERY_URL);
   
    verify(mockQuery).userEmail(MockProvider.EXAMPLE_USER_EMAIL);
    verify(mockQuery).userFirstName(MockProvider.EXAMPLE_USER_FIRST_NAME);
    verify(mockQuery).userLastName(MockProvider.EXAMPLE_USER_LAST_NAME);
View Full Code Here


    List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations();
    AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations);

    Map<String, String> queryParameters = getCompleteStringQueryParameters();

    RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
    for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
      requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
    }

    requestSpecification.expect().statusCode(Status.OK.getStatusCode())
      .when().get(SERVICE_PATH);

    verify(mockQuery).authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID);
    verify(mockQuery).authorizationType(MockProvider.EXAMPLE_AUTHORIZATION_TYPE);
    verify(mockQuery).userIdIn(new String[]{MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_ID2});
View Full Code Here

  public void testCompleteGetParameters() {
   
    Map<String, String> queryParameters = getCompleteStringQueryParameters();
    queryParameters.put("member", MockProvider.EXAMPLE_USER_ID);
   
    RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
    for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
      requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
    }
   
    requestSpecification.expect().statusCode(Status.OK.getStatusCode())
      .when().get(GROUP_QUERY_URL);
   
    verify(mockQuery).groupName(MockProvider.EXAMPLE_GROUP_NAME);
    verify(mockQuery).groupType(MockProvider.EXAMPLE_GROUP_TYPE);
    verify(mockQuery).groupMember(MockProvider.EXAMPLE_USER_ID);
View Full Code Here

    }

    @Override
    public final Response createAsResponse(final T resource, final Pair<String, String> credentials) {
        Preconditions.checkNotNull(resource);
        RequestSpecification givenAuthenticated = null;
        if (credentials != null) {
            givenAuthenticated = auth.givenBasicAuthenticated(credentials.getLeft(), credentials.getRight());
        } else {
            givenAuthenticated = givenWriteAuthenticated();
        }

        final String resourceAsString = marshaller.encode(resource);
        logger.debug("Creating Resource against URI: " + getUri());
        return givenAuthenticated.contentType(marshaller.getMime()).body(resourceAsString).post(getUri());
    }
View Full Code Here

    @Test
    public void whenConsumingSimillarResourceName_thenRedirectedToCorrectResourceName() {
        final String simillarUriOfResource = getUri().substring(0, getUri().length() - 1);
        final Pair<String, String> readCredentials = getApi().getReadCredentials();
        final RequestSpecification givenAuthenticated = auth.givenBasicAuthenticated(readCredentials.getLeft(), readCredentials.getRight());
        final RequestSpecification readReq = givenAuthenticated.header(HttpHeaders.ACCEPT, marshaller.getMime());
        final RequestSpecification customRequest = readReq.config(new RestAssuredConfig().redirect(new RedirectConfig().followRedirects(false)));
        final Response responseOfSimillarUri = getApi().findOneByUriAsResponse(simillarUriOfResource, customRequest);
        assertThat(responseOfSimillarUri.getStatusCode(), is(301));
    }
View Full Code Here

        return locationOfCreatedResource;
    }

    final Response createAsResponse(final T resource) {
        Preconditions.checkNotNull(resource);
        final RequestSpecification givenAuthenticated = givenAuth();

        final String resourceAsString = marshaller.encode(resource);
        return givenAuthenticated.contentType(marshaller.getMime()).body(resourceAsString).post(getURL());
    }
View Full Code Here

TOP

Related Classes of com.jayway.restassured.specification.RequestSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.