/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Kenneth Ham
 *
 * 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.epictodo.controller.json;

import com.epictodo.model.Task;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class StorageTest {
    private static final String file_name = "storage_test";
    private Storage _storage = new Storage();
    private Task _task = new Task("Project Meeting", "2103 project meeting", 2);
    private Task task_2 = new Task("Board Meeting", "Board of directors meeting", 2);
    private ArrayList<Task> task_list;
    private ArrayList<Task> expected_task;

    @Before
    public void initialize() throws IOException {
        task_list = new ArrayList<Task>();
        expected_task = Storage.loadDbFile(file_name);

        task_list.add(_task);
        task_list.add(task_2);

        _storage.saveToJson(file_name, task_list);
    }

    @After
    public void tearDown() throws Exception {
        File _file = new File(file_name);
        _file.delete();
    }

    @Test
    public void saveToJsonTest() throws IOException {
        boolean _result = _storage.saveToJson(file_name, task_list);
        assertTrue(_result);
    }

    @Test
    public void loadDbTest() throws IOException {
        assertEquals(expected_task.get(0).getTaskName(), task_list.get(0).getTaskName());
    }
}

@@ -1177,16 +1177,96 @@
 .json;%0A%0A
+import com.epictodo.model.DeadlineTask;%0Aimport com.epictodo.model.FloatingTask;%0A
 import c
@@ -1285,24 +1285,24 @@
 model.Task;%0A
-
 import org.j
@@ -1612,12 +1612,11 @@
 rage
-_tes
+.tx
 t%22;%0A
@@ -1820,32 +1820,263 @@
 s meeting%22, 2);%0A
+    private DeadlineTask deadline_task = new DeadlineTask(%22CS2103 V0.3%22, %22Complete V0.3 for testing%22, 4, %22301014%22, %221900%22);%0A    private FloatingTask floating_task = new FloatingTask(%22CS2103 Project%22, %22V0.3 incomplete version%22, 4);%0A
     private Arra
@@ -2333,16 +2333,16 @@
 _task);%0A
-
         
@@ -2363,16 +2363,92 @@
 task_2);
+%0A        task_list.add(deadline_task);%0A        task_list.add(floating_task);
 %0A%0A      

Revert "Revert "V0.3.7: [updated] StorageTest to test Task, DeadlineTask, FloatingTask.""