package REST.projectEndpoint;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONObject;

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;

import strategy.RESTStrategy;

public class Exists extends RESTStrategy {

	private String projectId;

	@Override
	public void beforeExperiment() throws Exception {
		HashMap<String, HashMap<String, String>> parameters = new HashMap<String, HashMap<String, String>>();
		HashMap<String, String> project = new HashMap<String, String>();
		project.put("name", "Project");
		parameters.put("project", project);
		JSONObject jsonBody = new JSONObject(parameters);
		HttpResponse<JsonNode> response = post(buildUrl(PROJECT_PATH), jsonBody);
		projectId = ((JSONObject) (response.getBody().getObject().get("project"))).get("id").toString();
	}
	
	@Override
	public String request(String string) throws Exception {
		get(buildUrl(PROJECT_PATH + "/" + projectId));
		return null;
	}
	
	@Override
	public void afterExperiment() throws Exception {
		delete(buildUrl(PROJECT_PATH + "/" + projectId));
	}

	@Override
	public void configure(Map<Object, Object> options) {
		configure(options, "kalibro_processor");
	}

}

@@ -45,795 +45,87 @@
 til.
-HashMap;%0Aimport java.util.Map;%0A%0Aimport org.json.JSONObject;%0A%0Aimport com.mashape.unirest.http.HttpResponse;%0Aimport com.mashape.unirest.http.JsonNode;%0A%0Aimport strategy.RESTStrategy;%0A%0Apublic class Exists extends RESTStrategy %7B%0A%0A%09private String projectId;%0A%0A%09@Override%0A%09public void beforeExperiment() throws Exception %7B%0A%09%09HashMap%3CString, HashMap%3CString, String%3E%3E parameters = new HashMap%3CString, HashMap%3CString, String%3E%3E();%0A%09%09HashMap%3CString, String%3E project = new HashMap%3CString, String%3E();%0A%09%09project.put(%22name%22, %22Project%22);%0A%09%09parameters.put(%22project%22, project);%0A%09%09JSONObject jsonBody = new JSONObject(parameters);%0A%09%09HttpResponse%3CJsonNode%3E response = post(buildUrl(PROJECT_PATH), jsonBody);%0A%09%09projectId = ((JSONObject) (response.getBody().getObject().get(%22project%22))).get(%22id%22).toString();%0A%09%7D
+Map;%0A%0Aimport strategy.RESTStrategy;%0A%0Apublic class Exists extends RESTStrategy %7B
 %0A%09%0A%09
@@ -219,37 +219,33 @@
 CT_PATH + %22/
-%22 + projectId
+1/exists%22
 ));%0A%09%09return
@@ -257,126 +257,8 @@
 ;%0A%09%7D
-%0A%09%0A%09@Override%0A%09public void afterExperiment() throws Exception %7B%0A%09%09delete(buildUrl(PROJECT_PATH + %22/%22 + projectId));%0A%09%7D
 %0A%0A%09@

Fix Project#exists experiment