Package com.github.restdriver.serverdriver.http.response

Examples of com.github.restdriver.serverdriver.http.response.Response.asJson()


    public void jsonPathCanBeRunOverJsonResponse() {
        String jsonContent = makeJson(" { 'thing' : 'valuoid' } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.thing", equalTo("valuoid")));
    }
   
    @Test
    public void matchingNumbers() {
        String jsonContent = makeJson(" { 'thing' : 5 } ");
View Full Code Here


    public void matchingNumbers() {
        String jsonContent = makeJson(" { 'thing' : 5 } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.thing", is(5)));
    }
   
    @Test
    public void matchingNumbersAsLong() {
        String jsonContent = makeJson(" { 'thing' : 5 } ");
View Full Code Here

    public void matchingNumbersAsLong() {
        String jsonContent = makeJson(" { 'thing' : 5 } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.thing", is(5L)));
    }
   
    @Test
    public void correctHandlingOfDouble_IntMismatch() {
        String jsonContent = makeJson(" { 'thing' : 5.00 } ");
View Full Code Here

    public void correctHandlingOfDouble_IntMismatch() {
        String jsonContent = makeJson(" { 'thing' : 5.00 } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), not(hasJsonPath("$.thing", is(5)))); // it's 5.0, not 5 dammit!
    }
   
    @Test(expected = RuntimeJsonTypeMismatchException.class)
    public void matchingIntWhenNumberOverflows() {
        String jsonContent = makeJson(" { 'thing' : 4294967294 } ");
View Full Code Here

    public void matchingIntWhenNumberOverflows() {
        String jsonContent = makeJson(" { 'thing' : 4294967294 } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.thing", greaterThan(5)));
    }
   
    @Test(expected = RuntimeJsonTypeMismatchException.class)
    public void matchingDoubleWhenNumberOverflows() {
        String jsonContent = makeJson(" { 'thing' : 4294967294 } ");
View Full Code Here

    public void matchingDoubleWhenNumberOverflows() {
        String jsonContent = makeJson(" { 'thing' : 4294967294 } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.thing", greaterThan(5.1)));
    }
   
    @Test
    public void matchingLongWhenNumberOverflowsIsOK() {
        String jsonContent = makeJson(" { 'thing' : 4294967294 } ");
View Full Code Here

    public void matchingLongWhenNumberOverflowsIsOK() {
        String jsonContent = makeJson(" { 'thing' : 4294967294 } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.thing", greaterThan(5L)));
    }
   
    @Test
    public void moreComplexJsonPathCanBeRunOverJsonResponse() throws ParseException {
        String jsonContent = makeJson(" { 'thing' : { 'sub' : { 'subsub' : 'valutron' } } } ");
View Full Code Here

    public void moreComplexJsonPathCanBeRunOverJsonResponse() throws ParseException {
        String jsonContent = makeJson(" { 'thing' : { 'sub' : { 'subsub' : 'valutron' } } } ");
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$..subsub", hasItem(equalTo("valutron"))));
    }
   
    @Test
    public void jsonPathWithConditional() {
        String jsonContent = makeJson(
View Full Code Here

                        "  { 'a': 'two', 'c' : 150 } ] } ");
       
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.things[?(@.c > 125)].a", hasItem(equalTo("two"))));
    }
   
    @Test
    public void jsonPathWithoutMatcher() {
        String jsonContent = makeJson("{'this':'thing','that':3}");
View Full Code Here

        String jsonContent = makeJson("{'this':'thing','that':3}");
       
        driver.addExpectation(new ClientDriverRequest("/"), new ClientDriverResponse(jsonContent, "application/json"));
        Response response = get(baseUrl);
       
        assertThat(response.asJson(), hasJsonPath("$.that"));
    }
   
    private String makeJson(String fakeJson) {
        return fakeJson.replace("'", "\"");
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.