package seedu.ezdo.commons.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.io.File;

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

public class FileUtilTest {

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

    @Test
    public void getPath() {

        // valid case
        assertEquals("folder" + File.separator + "sub-folder", FileUtil.getPath("folder/sub-folder"));

        // null parameter -> assertion failure
        thrown.expect(AssertionError.class);
        FileUtil.getPath(null);

        // no forwards slash -> assertion failure
        thrown.expect(AssertionError.class);
        FileUtil.getPath("folder");
    }

    @Test
    public void createFile_noExists_false() throws Exception {
        File mock = mock(File.class);
        when(mock.exists()).thenReturn(true);
        assertFalse(FileUtil.createFile(mock));
    }

}

@@ -217,16 +217,44 @@
 io.File;
+%0Aimport java.io.IOException;
 %0A%0Aimport
@@ -1080,10 +1080,309 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void createDirs_missingDir_throwsIOException() throws Exception %7B%0A        thrown.expect(IOException.class);%0A        File dir = mock(File.class);%0A        when(dir.exists()).thenReturn(false);%0A        when(dir.mkdirs()).thenReturn(false);%0A        FileUtil.createDirs(dir);%0A    %7D%0A%0A
 %7D%0A

Add test to FileUtilTest