import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import org.json.JSONObject;
import org.junit.BeforeClass;
import org.junit.Test;
import sculture.Application;

/**
 * Created by bilal on 29/11/15.
 */
public class TestRest {

    static Application application;

    @BeforeClass
    public static void before() {
        application = new Application();
        application.main(new String[0]);
    }

    @Test
    public void test() throws Exception {

        HttpResponse<JsonNode> jsonResponse = null;
        try {


            JSONObject jsonObject = new JSONObject();
            jsonObject.put("username", "test-user");
            jsonObject.put("password", "test-password");
            jsonObject.put("email", "test-password@test.com");


            JsonNode jsonNode = new JsonNode(jsonObject.toString());
            jsonResponse = Unirest.post("http://52.28.216.93:9000/user/register")
                    .header("Content-Type", "application/json")
                    .body(jsonNode)
                    .asJson();
        } catch (UnirestException e) {
            e.printStackTrace();
        }
        if (jsonResponse != null) {
            System.out.println(jsonResponse.getBody());
        }
    }
}

@@ -126,69 +126,8 @@
 st;%0A
-import com.mashape.unirest.http.exceptions.UnirestException;%0A
 impo
@@ -233,16 +233,62 @@
 ation;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 /**%0A * C
@@ -552,16 +552,22 @@
 oid test
+Sample
 () throw
@@ -637,28 +637,9 @@
 ll;%0A
-        try %7B%0A%0A%0A    
+%0A
     
@@ -684,36 +684,32 @@
 ject();%0A        
-   
- 
 jsonObject.put(%22
@@ -729,28 +729,24 @@
 est-user%22);%0A
-    
         json
@@ -790,28 +790,24 @@
 %22);%0A        
- 
-   
 jsonObject.p
@@ -855,20 +855,16 @@
         
-  
-  
 JsonNode
@@ -908,28 +908,24 @@
 oString());%0A
-    
         json
@@ -990,20 +990,16 @@
 ister%22)%0A
-    
         
@@ -1066,20 +1066,16 @@
         
-    
 .body(js
@@ -1082,20 +1082,16 @@
 onNode)%0A
-    
         
@@ -1121,183 +1121,292 @@
     
-%7D catch (UnirestException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        if (jsonResponse != null) %7B%0A            System.out.println(jsonResponse.getBody());%0A        %7D
+assertEquals(jsonResponse.getBody().getObject().getString(%22username%22), %22test-user%22);%0A        assertEquals(jsonResponse.getBody().getObject().getString(%22password%22), %22test-password%22);%0A        assertEquals(jsonResponse.getBody().getObject().getString(%22email%22), %22test-password@test.com%22);
 %0A   

test edit