// Path: sorter/src/main/java/sortpom/exception/FailureException.java
// public class FailureException extends RuntimeException {
//     public FailureException(String msg, Throwable cause) {
//         super(msg, cause);
//     }
// 
//     public FailureException(String msg) {
//         super(msg);
//     }
// }


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import refutils.ReflectionHelper;
import sortpom.exception.FailureException;
import java.io.File;
import java.io.IOException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
package sortpom.util;




class FileUtilExceptionsTest {

    private File backupFileTemp;
    private File pomFileTemp;

    @BeforeEach
    void setup() throws IOException {
        pomFileTemp = File.createTempFile("pom", ".xml", new File("target"));
        pomFileTemp.deleteOnExit();
        backupFileTemp = File.createTempFile("backupFile", ".xml", new File("target"));
        backupFileTemp.deleteOnExit();
    }

    @Test
    void whenOldBackupFileCannotBeDeletedAnExceptionShouldBeThrown() {
        FileUtil fileUtil = createFileUtil();
        doNotAccessRealBackupFile(fileUtil);

        //Set backup file to a directory (which raises DirectoryNotEmptyException)
        new ReflectionHelper(fileUtil).setField("backupFile", backupFileTemp.getParentFile());

        final Executable testMethod = fileUtil::backupFile;

// Path: sorter/src/main/java/sortpom/exception/FailureException.java
// public class FailureException extends RuntimeException {
//     public FailureException(String msg, Throwable cause) {
//         super(msg, cause);
//     }
// 
//     public FailureException(String msg) {
//         super(msg);
//     }
// }


// Path: sorter/src/test/java/sortpom/util/FileUtilExceptionsTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import refutils.ReflectionHelper;
import sortpom.exception.FailureException;
import java.io.File;
import java.io.IOException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;

package sortpom.util;




class FileUtilExceptionsTest {

    private File backupFileTemp;
    private File pomFileTemp;

    @BeforeEach
    void setup() throws IOException {
        pomFileTemp = File.createTempFile("pom", ".xml", new File("target"));
        pomFileTemp.deleteOnExit();
        backupFileTemp = File.createTempFile("backupFile", ".xml", new File("target"));
        backupFileTemp.deleteOnExit();
    }

    @Test
    void whenOldBackupFileCannotBeDeletedAnExceptionShouldBeThrown() {
        FileUtil fileUtil = createFileUtil();
        doNotAccessRealBackupFile(fileUtil);

        //Set backup file to a directory (which raises DirectoryNotEmptyException)
        new ReflectionHelper(fileUtil).setField("backupFile", backupFileTemp.getParentFile());

        final Executable testMethod = fileUtil::backupFile;

        final FailureException thrown = assertThrows(FailureException.class, testMethod);