Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.koushikdutta.ion.mock;
 
Created by koush on 3/6/15.
public class MockResponseFuture<T> extends SimpleFuture<T> implements ResponseFuture<T> {
    private AsyncHttpRequest request;
    public MockResponseFuture(AsyncHttpRequest request) {
        this. = request;
    }
    protected Headers getHeaders() {
        return new Headers();
    }
    protected HeadersResponse getHeadersResponse() {
        return new HeadersResponse(200, "OK"getHeaders());
    }
    private Response<T> getResponse(Exception e, T result) {
        return new Response<T>(.getHeadersResponse(), eresult);
    }
    @Override
    public Future<Response<T>> withResponse() {
        final SimpleFuture<Response<T>> ret = new SimpleFuture<Response<T>>();
        setCallback(new FutureCallback<T>() {
            @Override
            public void onCompleted(Exception e, T result) {
                ret.setComplete(getResponse(eresult));
            }
        });
        ret.setParent(this);
        return ret;
    }
New to GrepCode? Check out our FAQ X