/**
*	IMDBHandlerTest.java
*
*	@author Johan Brook
*	@copyright (c) 2012 Johan Brook
*	@license MIT
*/

package se.chalmers.watchmetest.net;

import org.json.JSONArray;
import org.json.JSONObject;

import se.chalmers.watchme.net.IMDBHandler;
import junit.framework.TestCase;

public class IMDBHandlerTest extends TestCase {

	IMDBHandler imdb;
	
	protected void setUp() throws Exception {
		super.setUp();
		
		this.imdb = new IMDBHandler();
	}
	
	
	public void testGetMovies() {
		JSONArray json = this.imdb.getMoviesByTitle("casino royale");
		assertNotNull(json);
		assertTrue(json.length() > 0);
	}
	
	public void testGetMovie() {
		JSONArray json = this.imdb.getMoviesByTitle("casino royale");
		
		JSONObject movie = json.optJSONObject(0);
		assertNotNull(movie);
	}
	
	public void testGetNonExistingMovie() {
		JSONArray json = this.imdb.getMoviesByTitle("awdkaowidoawijdwoaijdawoidjaowid");
		assertNull(json);
	}
}

@@ -235,16 +235,62 @@
 andler;%0A
+import se.chalmers.watchme.utils.MovieHelper;%0A
 import j
@@ -961,10 +961,369 @@
 on);%0A%09%7D%0A
+%09%0A%09public void testParseStringToJSON() %7B%0A%09%09String json = %22%5B%7Bkey: %5C%22val%5C%22%7D%5D%22;%0A%09%09String json2 = %22%7Bkey: %5C%22val%5C%22%7D%22;%0A%09%09%0A%09%09JSONObject res = IMDBHandler.parseStringToJSON(json);%0A%09%09JSONObject res2 = IMDBHandler.parseStringToJSON(json2);%0A%09%09%0A%09%09assertNotNull(res);%0A%09%09assertNotNull(res2);%0A%09%09assertNotNull(res.optString(%22key%22));%0A%09%09assertNotNull(res2.optString(%22key%22));%0A%09%7D%0A
 %7D%0A

Add test for JSON parse method