package ai.elimu.rest.v2;

import ai.elimu.util.JsonLoader;
import org.apache.log4j.Logger;
import static org.hamcrest.CoreMatchers.is;
import org.json.JSONObject;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import selenium.DomainHelper;

public class StoryBooksRestControllerTest {
    
    private Logger logger = Logger.getLogger(getClass());
    
    @Test
    public void testHandleGetRequest() {
        String jsonResponse = JsonLoader.loadJson(DomainHelper.getRestUrlV2() + "/content/storybooks");
        logger.info("jsonResponse: " + jsonResponse);
        JSONObject jsonObject = new JSONObject(jsonResponse);
        assertThat(jsonObject.has("result"), is(true));
        assertThat(jsonObject.get("result"), is("success"));
        assertThat(jsonObject.has("storyBooks"), is(true));
        assertThat(jsonObject.getJSONArray("storyBooks").length() > 0, is(true));
    }
}

@@ -81,24 +81,58 @@
 g4j.Logger;%0A
+import org.hamcrest.CoreMatchers;%0A
 import stati
@@ -159,18 +159,17 @@
 atchers.
-is
+*
 ;%0Aimport
@@ -662,32 +662,41 @@
 (jsonResponse);%0A
+        %0A
         assertTh
@@ -727,32 +727,32 @@
 t%22), is(true));%0A
-
         assertTh
@@ -792,24 +792,33 @@
 success%22));%0A
+        %0A
         asse
@@ -857,32 +857,32 @@
 s%22), is(true));%0A
-
         assertTh
@@ -943,20 +943,204 @@
  is(true));%0A
+        %0A        JSONObject storyBookJsonObject = jsonObject.getJSONArray(%22storyBooks%22).getJSONObject(0);%0A        assertThat(storyBookJsonObject.getString(%22title%22), not(nullValue()));%0A
     %7D%0A%7D%0A

Update StoryBooksRestControllerTest.java