Package com.github.restdriver.clientdriver

Examples of com.github.restdriver.clientdriver.ClientDriverExpectation


    @Rule
    public ExpectedException thrown = ExpectedException.none();
   
    @Test
    public void newlyCreatedExpectationIsExpectedOnceAndNotMatched() {
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        assertThat(expectation.getStatusString(), is("expected: 1, actual: 0"));
    }
View Full Code Here


        assertThat(expectation.getStatusString(), is("expected: 1, actual: 0"));
    }
   
    @Test
    public void newlyCreatedExpectationIsNotSatisfied() {
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        assertThat(expectation.isSatisfied(), is(false));
    }
View Full Code Here

        assertThat(expectation.isSatisfied(), is(false));
    }
   
    @Test
    public void expectationExpectedANumberOfTimesHasCorrectStatusString() {
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        expectation.times(10);
        assertThat(expectation.getStatusString(), is("expected: 10, actual: 0"));
    }
View Full Code Here

    @Test
    public void specifyingNumberOfExpectationsBelowOneThrowsException() {
        thrown.expect(ClientDriverInvalidExpectationException.class);
        thrown.expectMessage("Expectation cannot be matched less than once");
       
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        expectation.times(0);
    }
View Full Code Here

        expectation.times(0);
    }
   
    @Test
    public void matchingExpectationSatisfiesIt() {
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        expectation.times(3);
       
        assertThat(expectation.isSatisfied(), is(false));
       
        HttpRealRequest realRequest = mock(HttpRealRequest.class);
       
        expectation.match(realRequest);
        assertThat(expectation.isSatisfied(), is(false));
        expectation.match(realRequest);
        assertThat(expectation.isSatisfied(), is(false));
        expectation.match(realRequest);
        assertThat(expectation.isSatisfied(), is(true));
    }
View Full Code Here

       
    }
   
    private synchronized ClientDriverRequestResponsePair getMatchingRequestPair(HttpServletRequest request) {
       
        ClientDriverExpectation matchedExpectation = null;
        HttpRealRequest realRequest = new HttpRealRequest(request);
       
        int index;
        for (index = 0; index < expectations.size(); index++) {
            ClientDriverExpectation thisExpectation = expectations.get(index);
            ClientDriverRequestResponsePair thisPair = thisExpectation.getPair();
           
            if (matcher.isMatch(realRequest, thisPair.getRequest())) {
                thisExpectation.match(realRequest);
                matchedExpectation = thisExpectation;
                break;
            }
        }
       
View Full Code Here

     * @return The added expectation
     */
    @Override
    public ClientDriverExpectation addExpectation(ClientDriverRequest request, ClientDriverResponse response) {
        ClientDriverRequestResponsePair pair = new ClientDriverRequestResponsePair(request, response);
        ClientDriverExpectation expectation = new ClientDriverExpectation(pair);
        expectations.add(expectation);
        return expectation;
    }
View Full Code Here

    }
   
    @Test
    public void matchingExpectationCallsMatcher() {
        MatchedRequestHandler matchHandlerMock = mock(MatchedRequestHandler.class);
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        expectation.whenMatched(matchHandlerMock);
       
        HttpRealRequest realRequest = mock(HttpRealRequest.class);
       
        expectation.match(realRequest);
        verify(matchHandlerMock).onMatch(realRequest);
    }
View Full Code Here

        verify(matchHandlerMock).onMatch(realRequest);
    }
   
    @Test
    public void expectationExpectedAnyNumberOfTimesIsMarkedAsSuch() {
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        expectation.anyTimes();
        assertThat(expectation.shouldMatchAnyTimes(), is(true));
    }
View Full Code Here

        assertThat(expectation.shouldMatchAnyTimes(), is(true));
    }
   
    @Test
    public void expectationExpectedAnyNumberOfTimesIsNotSatisfied() {
        ClientDriverExpectation expectation = new ClientDriverExpectation(PAIR);
        expectation.anyTimes();
        assertThat(expectation.isSatisfied(), is(false));
    }
View Full Code Here

TOP

Related Classes of com.github.restdriver.clientdriver.ClientDriverExpectation

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.