// Path: testsrc/de/neuland/firefly/TestUtils.java
// public class TestUtils {
//     public static void unwrapException(RuntimeException e) throws Throwable {
//         if (e.getCause() != null) {
//             throw e.getCause();
//         } else {
//             throw e;
//         }
//     }
// 
//     public static <T> T loadXML(Class<T> type, String xmlFile) {
//         T result = XMLUtil.loadXML(type, getFileFromClasspath(xmlFile));
//         assertNotNull(result);
//         return result;
//     }
// 
//     public static File getFileFromClasspath(String filename) {
//         URL currentClassPathFolder = TestUtils.class.getClassLoader().getResource("");
//         File result = new File(currentClassPathFolder.getFile(), filename);
//         assertTrue(result.exists());
//         return result;
//     }
// }


import de.neuland.firefly.TestUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
    public void shoulduseDefaultOnPreconditionFail() throws Exception {
        // given
        String xmlFile = "resources/changes/v1/changeDescription-details.xml";
        //
        XMLChange change = loadXML(xmlFile, 0);
        // then
        assertEquals(XMLPreconditionBehaviour.HALT, change.getOnPreconditionFail());
    }

    @Test
    public void shouldParseChangeContent() throws Exception {
        // given
        String xmlFile = "resources/changes/v1/changeDescription-details.xml";
        // when
        XMLChange change = loadXML(xmlFile, 1);
        // then
        assertEquals("print(ctx.getBeanDefinitionNames());", change.getChangeContent());
    }

    @Test
    public void shouldOverwriteToString() throws Exception {
        // given
        String xmlFile = "resources/changes/v1/changeDescription-details.xml";
        // when
        XMLChange change = loadXML(xmlFile, 0);
        // then
        assertTrue(change.toString().contains(FILE));
    }

    private XMLChange loadXML(String xmlFile, int changeIndex) {
// Path: testsrc/de/neuland/firefly/TestUtils.java
// public class TestUtils {
//     public static void unwrapException(RuntimeException e) throws Throwable {
//         if (e.getCause() != null) {
//             throw e.getCause();
//         } else {
//             throw e;
//         }
//     }
// 
//     public static <T> T loadXML(Class<T> type, String xmlFile) {
//         T result = XMLUtil.loadXML(type, getFileFromClasspath(xmlFile));
//         assertNotNull(result);
//         return result;
//     }
// 
//     public static File getFileFromClasspath(String filename) {
//         URL currentClassPathFolder = TestUtils.class.getClassLoader().getResource("");
//         File result = new File(currentClassPathFolder.getFile(), filename);
//         assertTrue(result.exists());
//         return result;
//     }
// }


// Path: testsrc/de/neuland/firefly/changes/v1/XMLChangeTest.java
import de.neuland.firefly.TestUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

    public void shoulduseDefaultOnPreconditionFail() throws Exception {
        // given
        String xmlFile = "resources/changes/v1/changeDescription-details.xml";
        //
        XMLChange change = loadXML(xmlFile, 0);
        // then
        assertEquals(XMLPreconditionBehaviour.HALT, change.getOnPreconditionFail());
    }

    @Test
    public void shouldParseChangeContent() throws Exception {
        // given
        String xmlFile = "resources/changes/v1/changeDescription-details.xml";
        // when
        XMLChange change = loadXML(xmlFile, 1);
        // then
        assertEquals("print(ctx.getBeanDefinitionNames());", change.getChangeContent());
    }

    @Test
    public void shouldOverwriteToString() throws Exception {
        // given
        String xmlFile = "resources/changes/v1/changeDescription-details.xml";
        // when
        XMLChange change = loadXML(xmlFile, 0);
        // then
        assertTrue(change.toString().contains(FILE));
    }

    private XMLChange loadXML(String xmlFile, int changeIndex) {
        XMLChangeDescription changeDescription = TestUtils.loadXML(XMLChangeDescription.class, xmlFile);