/**
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 Miikka Andersson
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

package com.example.avjindersinghsekhon.minimaltodo;

import junit.framework.TestCase;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Date;

/**
 * JUnit tests to verify functionality of ToDoItem class.
 */
public class TestTodoItem extends TestCase {
    private final String TEXT_BODY = "This is some text";

     /**
      * Check we can construct a ToDoItem object using the three parameter constructor
      */
    public void testThreeParameterConstructor() {
        ToDoItem toDoItem = getToDoItem();
        assertEquals(TEXT_BODY, toDoItem.getToDoText());
    }

     /**
      * Ensure we can marshall ToDoItem objects to Json
      */
    public void testObjectMarshallingToJson() {
        ToDoItem toDoItem = getToDoItem();

        try {
            JSONObject json = toDoItem.toJSON();
            assertEquals(TEXT_BODY, json.getString("todotext"));
        } catch (JSONException e) {
            fail("Exception thrown during test execution: " + e.getMessage());
        }
    }

    /**
    * Ensure we can create ToDoItem objects from Json data by using the json constructor
    */
    public void testObjectUnmarshallingFromJson() {
        ToDoItem originalItem = getToDoItem();

        try {
            JSONObject json = originalItem.toJSON();
            ToDoItem itemFromJson = new ToDoItem(json);

            assertEquals(originalItem.getToDoText(), itemFromJson.getToDoText());
            assertEquals(originalItem.getIdentifier(), itemFromJson.getIdentifier());

        } catch (JSONException e) {
            fail("Exception thrown during test execution: " + e.getMessage());
        }
    }

    private ToDoItem getToDoItem() {
        return new ToDoItem(TEXT_BODY);
    }
}

@@ -1293,32 +1293,8 @@
 t;%0A%0A
-import java.util.Date;%0A%0A
 /**%0A
@@ -1455,16 +1455,42 @@
 ome text
+ and special chars %C3%A4%C3%B6%C3%BC ~%C2%B2!
 %22;%0A%0A    
@@ -1557,24 +1557,8 @@
 the 
-three parameter 
 cons
@@ -1598,60 +1598,200 @@
 test
-ThreeParameterConstructor() %7B%0A        ToDoItem toDoI
+Constructor() %7B%0A        // empty constructor%0A        ToDoItem item = new ToDoItem();%0A        assertEquals(ToDoItem.DEFAULT_TEXT, item.getToDoText());%0A        // constructor with text%0A        i
 tem 
@@ -1839,21 +1839,17 @@
 T_BODY, 
-toDoI
+i
 tem.getT
@@ -1982,24 +1982,45 @@
 lingToJson()
+ throws JSONException
  %7B%0A        T
@@ -2057,32 +2057,16 @@
 ();%0A
-%0A        try %7B%0A 
         
    J
@@ -2053,35 +2053,32 @@
 Item();%0A        
-   
 JSONObject json 
@@ -2090,36 +2090,32 @@
 oItem.toJSON();%0A
-    
         assertEq
@@ -2163,133 +2163,8 @@
 ));%0A
-        %7D catch (JSONException e) %7B%0A            fail(%22Exception thrown during test execution: %22 + e.getMessage());%0A        %7D%0A
     
@@ -2319,16 +2319,37 @@
 omJson()
+ throws JSONException
  %7B%0A     
@@ -2394,32 +2394,16 @@
 ();%0A
-%0A        try %7B%0A 
         
    J
@@ -2394,27 +2394,24 @@
 ();%0A        
-   
 JSONObject j
@@ -2435,28 +2435,24 @@
 m.toJSON();%0A
-    
         ToDo
@@ -2491,28 +2491,24 @@
 (json);%0A
-%0A   
         
  assertE
@@ -2491,33 +2491,32 @@
 (json);%0A        
- 
 assertEquals(ori
@@ -2528,264 +2528,24 @@
 Item
-.getToDoText(), itemFromJson.getToDoText());%0A            assertEquals(originalItem.getIdentifier(), itemFromJson.getIdentifier());%0A%0A        %7D catch (JSONException e) %7B%0A            fail(%22Exception thrown during test execution: %22 + e.getMessage());%0A        %7D
+, itemFromJson);
 %0A   

Remove unneeded exception catching and test special charss.