package seedu.tasklist.storage;


import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;

import seedu.tasklist.commons.util.FileUtil;
import seedu.tasklist.model.ReadOnlyTaskList;
import seedu.tasklist.model.TaskList;
import seedu.tasklist.model.task.Task;
import seedu.tasklist.storage.XmlTaskListStorage;
import seedu.tasklist.testutil.TypicalTestTasks;

import static org.junit.Assert.*;

import java.io.IOException;

public class XmlTaskListStorageTest {
    private static String TEST_DATA_FOLDER = FileUtil.getPath("./src/test/data/XmlTaskListStorageTest/");

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Rule
    public TemporaryFolder testFolder = new TemporaryFolder();

    @Test
    public void readTaskList_nullFilePath_assertionFailure() throws Exception {
        thrown.expect(AssertionError.class);
        readTaskList(null);
    }

    private java.util.Optional<ReadOnlyTaskList> readTaskList(String filePath) throws Exception {
        return new XmlTaskListStorage(filePath).readTaskList(addToTestDataPathIfNotNull(filePath));
    }

    private String addToTestDataPathIfNotNull(String prefsFileInTestDataFolder) {
        return prefsFileInTestDataFolder != null
                ? TEST_DATA_FOLDER + prefsFileInTestDataFolder
                : null;
    }

    @Test
    public void read_missingFile_emptyResult() throws Exception {
        assertFalse(readTaskList("NonExistentFile.xml").isPresent());
    }
/*
    @Test
    public void readAndSaveTaskList_allInOrder_success() throws Exception {
        String filePath = testFolder.getRoot().getPath() + "TempTaskList.xml";
        TypicalTestTasks td = new TypicalTestTasks();
        TaskList original = td.getTypicalTaskList();
        XmlTaskListStorage xmlTaskListStorage = new XmlTaskListStorage(filePath);

        //Save in new file and read back
        xmlTaskListStorage.saveTaskList(original, filePath);
        ReadOnlyTaskList readBack = xmlTaskListStorage.readTaskList(filePath).get();
        assertEquals(original, new TaskList(readBack));

        //Modify data, overwrite exiting file, and read back
        original.addTask(new Task(TypicalTestTasks.task8));
        original.removeTask(new Task(TypicalTestTasks.task1));
        xmlTaskListStorage.saveTaskList(original, filePath);
        readBack = xmlTaskListStorage.readTaskList(filePath).get();
        assertEquals(original, new TaskList(readBack));

    }
*/
    @Test
    public void saveTaskList_nullTaskList_assertionFailure() throws IOException {
        thrown.expect(AssertionError.class);
        saveTaskList(null, "SomeFile.xml");
    }

    private void saveTaskList(ReadOnlyTaskList taskList, String filePath) throws IOException {
        new XmlTaskListStorage(filePath).saveTaskList(taskList, addToTestDataPathIfNotNull(filePath));
    }

    @Test
    public void saveTaskList_nullFilePath_assertionFailure() throws IOException {
        thrown.expect(AssertionError.class);
        saveTaskList(new TaskList(), null);
    }


}

@@ -1538,988 +1538,8 @@
   %7D%0A
-/*%0A    @Test%0A    public void readAndSaveTaskList_allInOrder_success() throws Exception %7B%0A        String filePath = testFolder.getRoot().getPath() + %22TempTaskList.xml%22;%0A        TypicalTestTasks td = new TypicalTestTasks();%0A        TaskList original = td.getTypicalTaskList();%0A        XmlTaskListStorage xmlTaskListStorage = new XmlTaskListStorage(filePath);%0A%0A        //Save in new file and read back%0A        xmlTaskListStorage.saveTaskList(original, filePath);%0A        ReadOnlyTaskList readBack = xmlTaskListStorage.readTaskList(filePath).get();%0A        assertEquals(original, new TaskList(readBack));%0A%0A        //Modify data, overwrite exiting file, and read back%0A        original.addTask(new Task(TypicalTestTasks.task8));%0A        original.removeTask(new Task(TypicalTestTasks.task1));%0A        xmlTaskListStorage.saveTaskList(original, filePath);%0A        readBack = xmlTaskListStorage.readTaskList(filePath).get();%0A        assertEquals(original, new TaskList(readBack));%0A%0A    %7D%0A*/
 %0A   

Clean old tests