package com.eyekabob.jaxrs;

import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static junit.framework.Assert.*;

public class EventTest {
    private Event eventService;

    @Before
    public void before() {
        eventService = new Event();
    }

    @After
    public void after() {
        eventService = null;
    }

    @Test
    public void testGetResponseNoIDNoSearch() throws Exception {
        String result = eventService.getResponse(null, null);
        JSONObject jsonResult = new JSONObject(result);
        assertTrue(jsonResult.has("error"));

        result = eventService.getResponse("", null);
        jsonResult = new JSONObject(result);
        assertTrue(jsonResult.has("error"));

        result = eventService.getResponse(null, "");
        jsonResult = new JSONObject(result);
        assertTrue(jsonResult.has("error"));

        result = eventService.getResponse("", "");
        jsonResult = new JSONObject(result);
        assertTrue(jsonResult.has("error"));
    }

    @Test
    public void testGetResponseByID() throws Exception {
        String result = eventService.getResponseByID("anID");
        JSONObject jsonResult = new JSONObject(result);
        assertTrue(jsonResult.has("event"));

        JSONObject event = jsonResult.getJSONObject("event");
        assertTrue(event.has("id"));

        assertEquals("anID", event.get("id"));
    }

    @Test
    public void testGetResponseBySearchTerm() throws Exception {
        String result = eventService.getResponseBySearchTerm("aSearchTerm");
        JSONObject jsonResult = new JSONObject(result);
        assertTrue(jsonResult.has("search"));
        assertEquals("aSearchTerm", jsonResult.get("search"));

        assertTrue(jsonResult.has("events"));
        JSONArray resultEvents = jsonResult.getJSONArray("events");
        assertEquals(0, resultEvents.length());
    }
}

@@ -1071,32 +1071,1339 @@
 rror%22));%0A    %7D%0A%0A
+    @Test%0A    public void testGetResponseID() throws Exception %7B%0A        String result = eventService.getResponse(%22anID%22, null);%0A        JSONObject jsonResult = new JSONObject(result);%0A        assertTrue(jsonResult.has(%22event%22));%0A%0A        JSONObject event = jsonResult.getJSONObject(%22event%22);%0A        assertTrue(event.has(%22id%22));%0A%0A        assertEquals(%22anID%22, event.get(%22id%22));%0A    %7D%0A%0A    @Test%0A    public void testGetResponseSearch() throws Exception %7B%0A        String result = eventService.getResponse(null, %22aSearchTerm%22);%0A        JSONObject jsonResult = new JSONObject(result);%0A        assertTrue(jsonResult.has(%22search%22));%0A        assertEquals(%22aSearchTerm%22, jsonResult.get(%22search%22));%0A%0A        assertTrue(jsonResult.has(%22events%22));%0A        JSONArray resultEvents = jsonResult.getJSONArray(%22events%22);%0A        assertEquals(0, resultEvents.length());%0A    %7D%0A%0A    @Test%0A    public void testGetResponseIDSearch() throws Exception %7B%0A        String result = eventService.getResponse(%22anID%22, %22aSearchTerm%22);%0A        JSONObject jsonResult = new JSONObject(result);%0A        assertTrue(jsonResult.has(%22event%22));%0A        assertFalse(jsonResult.has(%22search%22));%0A%0A        JSONObject event = jsonResult.getJSONObject(%22event%22);%0A        assertTrue(event.has(%22id%22));%0A%0A        assertEquals(%22anID%22, event.get(%22id%22));%0A    %7D%0A%0A
     @Test%0A    pu

Add more event web service tests