Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.kristofa.test.http;
 
 import java.util.List;
 
Indicates there are http requests that we expected but did not get and/or that we got unexpected http requests.

Author(s):
kristof
See also:
HttpResponseProvider
public class UnsatisfiedExpectationException extends Exception {
    private static final long serialVersionUID = -6003072239642243697L;
    private final List<HttpRequestmissingHttpRequests = new ArrayList<HttpRequest>();
    private final List<HttpRequestunexpectedHttpRequests = new ArrayList<HttpRequest>();

    
Creates a new instance.

Both collections should not be null. One of both collections can be empty.

Parameters:
missingRequests Requests that we expected but did not get.
unexpectedRequests Requests that we got but did not expect.
    public UnsatisfiedExpectationException(final Collection<HttpRequestmissingRequests,
        final Collection<HttpRequestunexpectedRequests) {
        super();
        Validate.notNull(missingRequests);
        Validate.notNull(unexpectedRequests);
        Validate.isTrue(!missingRequests.isEmpty() || !unexpectedRequests.isEmpty());
        .addAll(missingRequests);
        .addAll(unexpectedRequests);
    }

    
Gets the http requests that we expected but did not get.

Returns:
Collection of http requests that we expected but did not get.
        return Collections.unmodifiableCollection();
    }

    
Gets the http requests that we got but did not expect.

Returns:
Collection of http requests that we got but did not expect.
        return Collections.unmodifiableCollection();
    }

    
    @Override
    public String toString() {
        final String missingExpectedRequestsString = "Missing expected requests: " + getMissingHttpRequests();
        final String unexpectedReceivedRequestsString = "Unexpected received requests: " + getUnexpectedHttpRequests();
        return missingExpectedRequestsString + "\n" + unexpectedReceivedRequestsString;
    }
New to GrepCode? Check out our FAQ X