Examples of ClientDriverResponse


Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test
    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")));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test
    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)));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test
    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)));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test
    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!
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test(expected = RuntimeJsonTypeMismatchException.class)
    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)));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test(expected = RuntimeJsonTypeMismatchException.class)
    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)));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test
    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)));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

    }
   
    @Test
    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"))));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

               
                " { 'things' : " +
                        "[ { 'a': 'one', 'c' : 100 } , " +
                        "  { '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"))));
    }
View Full Code Here

Examples of com.github.restdriver.clientdriver.ClientDriverResponse

   
    @Test
    public void jsonPathWithoutMatcher() {
        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"));
    }
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.