// Path: src/test/java/com/asana/AsanaTest.java
// public class AsanaTest
// {
//     protected Client client;
//     protected MockDispatcher dispatcher;
//     protected JsonParser parser;
// 
//     @Before
//     public void setUp()
//     {
//         this.parser = new JsonParser();
//         this.dispatcher = new MockDispatcher();
//         this.client =  new Client(this.dispatcher);
//         this.client.options.put("base_url", "http://app");
//     }
// 
// }
// 
// Path: src/main/java/com/asana/errors/InvalidRequestError.java
// public class InvalidRequestError extends AsanaError {
//     final public static String MESSAGE = "Invalid Request";
//     final public static int STATUS = 400;
// 
//     public InvalidRequestError(HttpResponseException exception) {
//         super(MESSAGE, STATUS, exception);
//     }
// }
// 
// Path: src/main/java/com/asana/errors/InvalidTokenError.java
// public class InvalidTokenError extends AsanaError {
//     final public static String MESSAGE = "Sync token invalid or too old";
//     final public static int STATUS = 412;
// 
//     public String sync;
// 
//     public InvalidTokenError(HttpResponseException exception) {
//         super(MESSAGE, STATUS, exception);
// 
//         try {
//             ResultBodyCollection body = Json.getInstance().fromJson(exception.getContent(), ResultBodyCollection.class);
//             sync = body.sync;
//         } catch (Exception e) {
//         }
//     }
// }
// 
// Path: src/main/java/com/asana/models/Event.java
// public class Event {
//     public class Entity extends Resource {
//         public String name;
//     }
// 
//     public String action;
//     public Entity resource;
//     public String type;
//     public User user;
//     public Entity parent;
// 
//     @SerializedName("created_at")
//     public DateTime createdAt;
// }


import com.asana.AsanaTest;
import com.asana.errors.InvalidRequestError;
import com.asana.errors.InvalidTokenError;
import com.asana.models.Event;
import org.junit.Test;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

        client.events.get("1", "a").execute();
    }

    @Test(expected=InvalidTokenError.class)
    public void testEventsGetInvalidToken() throws Exception
    {
        dispatcher.registerResponse("GET", "http://app/events?resource=1&sync=a").code(412)
                .content("{ \"sync\": \"b\" }");

        client.events.get("1", "a").execute();
    }

    // TODO: is there a way to get an iterator to throw a InvalidRequestError instead of NoSuchElementException?
    @Test(expected=NoSuchElementException.class)
    public void testEventsGetIteratorUnknownObject() throws Exception
    {
        dispatcher.registerResponse("GET", "http://app/events?resource=1&sync=a&limit=50").code(400)
                .content("{ \"sync\": \"b\" }");

        try {
            client.events.get("1", "a").iterator().next();
        } catch (Exception e) {
            assertTrue(e.getCause() instanceof InvalidRequestError);
            throw e;
        }
    }

    // TODO: is there a way to get an iterator to throw a InvalidTokenError instead of NoSuchElementException?
    @Test(expected=NoSuchElementException.class)
// Path: src/test/java/com/asana/AsanaTest.java
// public class AsanaTest
// {
//     protected Client client;
//     protected MockDispatcher dispatcher;
//     protected JsonParser parser;
// 
//     @Before
//     public void setUp()
//     {
//         this.parser = new JsonParser();
//         this.dispatcher = new MockDispatcher();
//         this.client =  new Client(this.dispatcher);
//         this.client.options.put("base_url", "http://app");
//     }
// 
// }
// 
// Path: src/main/java/com/asana/errors/InvalidRequestError.java
// public class InvalidRequestError extends AsanaError {
//     final public static String MESSAGE = "Invalid Request";
//     final public static int STATUS = 400;
// 
//     public InvalidRequestError(HttpResponseException exception) {
//         super(MESSAGE, STATUS, exception);
//     }
// }
// 
// Path: src/main/java/com/asana/errors/InvalidTokenError.java
// public class InvalidTokenError extends AsanaError {
//     final public static String MESSAGE = "Sync token invalid or too old";
//     final public static int STATUS = 412;
// 
//     public String sync;
// 
//     public InvalidTokenError(HttpResponseException exception) {
//         super(MESSAGE, STATUS, exception);
// 
//         try {
//             ResultBodyCollection body = Json.getInstance().fromJson(exception.getContent(), ResultBodyCollection.class);
//             sync = body.sync;
//         } catch (Exception e) {
//         }
//     }
// }
// 
// Path: src/main/java/com/asana/models/Event.java
// public class Event {
//     public class Entity extends Resource {
//         public String name;
//     }
// 
//     public String action;
//     public Entity resource;
//     public String type;
//     public User user;
//     public Entity parent;
// 
//     @SerializedName("created_at")
//     public DateTime createdAt;
// }


// Path: src/test/java/com/asana/resources/EventsTest.java
import com.asana.AsanaTest;
import com.asana.errors.InvalidRequestError;
import com.asana.errors.InvalidTokenError;
import com.asana.models.Event;
import org.junit.Test;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


        client.events.get("1", "a").execute();
    }

    @Test(expected=InvalidTokenError.class)
    public void testEventsGetInvalidToken() throws Exception
    {
        dispatcher.registerResponse("GET", "http://app/events?resource=1&sync=a").code(412)
                .content("{ \"sync\": \"b\" }");

        client.events.get("1", "a").execute();
    }

    // TODO: is there a way to get an iterator to throw a InvalidRequestError instead of NoSuchElementException?
    @Test(expected=NoSuchElementException.class)
    public void testEventsGetIteratorUnknownObject() throws Exception
    {
        dispatcher.registerResponse("GET", "http://app/events?resource=1&sync=a&limit=50").code(400)
                .content("{ \"sync\": \"b\" }");

        try {
            client.events.get("1", "a").iterator().next();
        } catch (Exception e) {
            assertTrue(e.getCause() instanceof InvalidRequestError);
            throw e;
        }
    }

    // TODO: is there a way to get an iterator to throw a InvalidTokenError instead of NoSuchElementException?
    @Test(expected=NoSuchElementException.class)
    public void testEventsGetIteratorInvalidToken() throws Exception