// Path: src/main/java/net/joelinn/asana/Asana.java
// public class Asana {
//     protected String apiKey;
// 
//     private Integer connectionTimeout;
// 
//     private Integer readTimeout;
// 
//     protected Map<Class<? extends AbstractClient>, AbstractClient> clients;
// 
//     public Asana(String apiKey){
//         this.apiKey = apiKey;
//         clients = new HashMap<>();
//     }
// 
//     /**
//      * @param apiKey your Asana API key
//      * @param connectionTimeout the connection timeout in MILLISECONDS
//      * @param readTimeout the read timeout in MILLISECONDS
//      */
//     public Asana(String apiKey, int connectionTimeout, int readTimeout){
//         this(apiKey);
//         this.connectionTimeout = connectionTimeout;
//         this.readTimeout = readTimeout;
//     }
// 
//     @SuppressWarnings("unchecked")
//     protected <T> T getClient(Class<? extends AbstractClient> clazz){
//         if(!clients.containsKey(clazz)){
//             try {
//                 AbstractClient client;
//                 if(this.connectionTimeout != null && this.readTimeout != null){
//                     client = clazz.getConstructor(String.class, int.class, int.class)
//                             .newInstance(apiKey, connectionTimeout, readTimeout);
//                 }
//                 else{
//                     client = clazz.getConstructor(String.class).newInstance(apiKey);
//                 }
//                 clients.put(clazz, client);
//             } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
//                 // This should never happen.
//                 e.printStackTrace();
//             }
//         }
//         return (T) clients.get(clazz);
//     }
// 
//     public ProjectsClient projects(){
//         return getClient(ProjectsClient.class);
//     }
// 
//     public StoriesClient stories(){
//         return getClient(StoriesClient.class);
//     }
// 
//     public TagsClient tags(){
//         return getClient(TagsClient.class);
//     }
// 
//     public TasksClient tasks(){
//         return getClient(TasksClient.class);
//     }
// 
//     public TeamsClient teams(){
//         return getClient(TeamsClient.class);
//     }
// 
//     public UsersClient users(){
//         return getClient(UsersClient.class);
//     }
// 
//     public WorkspacesClient workspaces(){
//         return getClient(WorkspacesClient.class);
//     }
// }
// 
// Path: src/main/java/net/joelinn/asana/projects/ProjectsClient.java
// public class ProjectsClient extends AbstractClient{
//     public ProjectsClient(String apiKey) {
//         super(apiKey);
//     }
// 
//     /**
//      * @param apiKey            your Asana API key
//      * @param connectionTimeout the connection timeout in MILLISECONDS
//      * @param readTimeout       the read timeout in MILLISECONDS
//      */
//     public ProjectsClient(String apiKey, int connectionTimeout, int readTimeout) {
//         super(apiKey, connectionTimeout, readTimeout);
//     }
// 
//     public Project createProject(ProjectRequestBuilder builder){
//         return post("", builder.build()).getEntity(Project.class);
//     }
// 
//     public Project updateProject(long projectId, ProjectRequestBuilder builder){
//         return put(Long.toString(projectId), builder.build()).getEntity(Project.class);
//     }
// 
//     public Project getProject(long projectId){
//         return get(Long.toString(projectId)).getEntity(Project.class);
//     }
// 
//     public void deleteProject(long projectId){
//         delete(Long.toString(projectId));
//     }
//  	
//     public Tasks getExpandedTasks (long projectId) {
//         MultivaluedMapImpl params = new MultivaluedMapImpl();
//         params.add("opt_expand", ".");
//         return get(String.format("%s/tasks", projectId), params).getEntity(Tasks.class);
//     }
// 
//     public Tasks getTasks(long projectId){
//         return get(String.format("%s/tasks", projectId)).getEntity(Tasks.class);
//     }
// 
//     public Projects getProjects(long workspaceId, boolean archived){
//         MultivaluedMapImpl params = new MultivaluedMapImpl();
//         params.add("workspace", workspaceId);
//         params.add("archvied", archived);
//         return get("", params).getEntity(Projects.class);
//     }
// 
//     @Override
//     protected ClientResponse request(String method, String url, MultivaluedMapImpl queryParams, MultivaluedMapImpl data) {
//         return super.request(method, "projects/" + url, queryParams, data);
//     }
// }


import junit.framework.TestCase;
import net.joelinn.asana.Asana;
import net.joelinn.asana.projects.ProjectsClient;
import org.junit.Before;
import org.junit.Test;
package net.joelinn.asana.test;


/**
 * User: Joe Linn
 * Date: 12/18/13
 * Time: 6:12 PM
 */
public class AsanaTest extends BaseTest{
    protected Asana client;

    @Before
    public void setUp(){
        client = new Asana(getApiKey());
    }

    @Test
    public void testGetClient(){
// Path: src/main/java/net/joelinn/asana/Asana.java
// public class Asana {
//     protected String apiKey;
// 
//     private Integer connectionTimeout;
// 
//     private Integer readTimeout;
// 
//     protected Map<Class<? extends AbstractClient>, AbstractClient> clients;
// 
//     public Asana(String apiKey){
//         this.apiKey = apiKey;
//         clients = new HashMap<>();
//     }
// 
//     /**
//      * @param apiKey your Asana API key
//      * @param connectionTimeout the connection timeout in MILLISECONDS
//      * @param readTimeout the read timeout in MILLISECONDS
//      */
//     public Asana(String apiKey, int connectionTimeout, int readTimeout){
//         this(apiKey);
//         this.connectionTimeout = connectionTimeout;
//         this.readTimeout = readTimeout;
//     }
// 
//     @SuppressWarnings("unchecked")
//     protected <T> T getClient(Class<? extends AbstractClient> clazz){
//         if(!clients.containsKey(clazz)){
//             try {
//                 AbstractClient client;
//                 if(this.connectionTimeout != null && this.readTimeout != null){
//                     client = clazz.getConstructor(String.class, int.class, int.class)
//                             .newInstance(apiKey, connectionTimeout, readTimeout);
//                 }
//                 else{
//                     client = clazz.getConstructor(String.class).newInstance(apiKey);
//                 }
//                 clients.put(clazz, client);
//             } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
//                 // This should never happen.
//                 e.printStackTrace();
//             }
//         }
//         return (T) clients.get(clazz);
//     }
// 
//     public ProjectsClient projects(){
//         return getClient(ProjectsClient.class);
//     }
// 
//     public StoriesClient stories(){
//         return getClient(StoriesClient.class);
//     }
// 
//     public TagsClient tags(){
//         return getClient(TagsClient.class);
//     }
// 
//     public TasksClient tasks(){
//         return getClient(TasksClient.class);
//     }
// 
//     public TeamsClient teams(){
//         return getClient(TeamsClient.class);
//     }
// 
//     public UsersClient users(){
//         return getClient(UsersClient.class);
//     }
// 
//     public WorkspacesClient workspaces(){
//         return getClient(WorkspacesClient.class);
//     }
// }
// 
// Path: src/main/java/net/joelinn/asana/projects/ProjectsClient.java
// public class ProjectsClient extends AbstractClient{
//     public ProjectsClient(String apiKey) {
//         super(apiKey);
//     }
// 
//     /**
//      * @param apiKey            your Asana API key
//      * @param connectionTimeout the connection timeout in MILLISECONDS
//      * @param readTimeout       the read timeout in MILLISECONDS
//      */
//     public ProjectsClient(String apiKey, int connectionTimeout, int readTimeout) {
//         super(apiKey, connectionTimeout, readTimeout);
//     }
// 
//     public Project createProject(ProjectRequestBuilder builder){
//         return post("", builder.build()).getEntity(Project.class);
//     }
// 
//     public Project updateProject(long projectId, ProjectRequestBuilder builder){
//         return put(Long.toString(projectId), builder.build()).getEntity(Project.class);
//     }
// 
//     public Project getProject(long projectId){
//         return get(Long.toString(projectId)).getEntity(Project.class);
//     }
// 
//     public void deleteProject(long projectId){
//         delete(Long.toString(projectId));
//     }
//  	
//     public Tasks getExpandedTasks (long projectId) {
//         MultivaluedMapImpl params = new MultivaluedMapImpl();
//         params.add("opt_expand", ".");
//         return get(String.format("%s/tasks", projectId), params).getEntity(Tasks.class);
//     }
// 
//     public Tasks getTasks(long projectId){
//         return get(String.format("%s/tasks", projectId)).getEntity(Tasks.class);
//     }
// 
//     public Projects getProjects(long workspaceId, boolean archived){
//         MultivaluedMapImpl params = new MultivaluedMapImpl();
//         params.add("workspace", workspaceId);
//         params.add("archvied", archived);
//         return get("", params).getEntity(Projects.class);
//     }
// 
//     @Override
//     protected ClientResponse request(String method, String url, MultivaluedMapImpl queryParams, MultivaluedMapImpl data) {
//         return super.request(method, "projects/" + url, queryParams, data);
//     }
// }


// Path: src/test/java/net/joelinn/asana/test/AsanaTest.java
import junit.framework.TestCase;
import net.joelinn.asana.Asana;
import net.joelinn.asana.projects.ProjectsClient;
import org.junit.Before;
import org.junit.Test;

package net.joelinn.asana.test;


/**
 * User: Joe Linn
 * Date: 12/18/13
 * Time: 6:12 PM
 */
public class AsanaTest extends BaseTest{
    protected Asana client;

    @Before
    public void setUp(){
        client = new Asana(getApiKey());
    }

    @Test
    public void testGetClient(){
        TestCase.assertEquals(ProjectsClient.class, client.projects().getClass());