// Path: src/main/java/com/xebialabs/overcast/Resources.java
// public final class Resources {
//     private Resources() {}
// 
//     public static URL getResource(String resourceName) {
//         ClassLoader loader = Thread.currentThread().getContextClassLoader();
//         if (loader == null) {
//             loader = Resources.class.getClassLoader();
//         }
//         URL url = loader.getResource(resourceName);
//         checkArgument(url != null, "resource %s not found.", resourceName);
//         return url;
//     }
// 
// }
// 
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
//     public enum AccessMode {
//         /** The source is accessed with the permissions of the user inside the guest. This is the default. */
//         PASSTHROUGH,
//         /** The source is accessed with the permissions of the hypervisor (QEMU process). */
//         MAPPED,
//         /**
//          * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
//          * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
//          */
//         SQUASH,
//     }
// 
//     public String source;
//     public String target;
//     public AccessMode accessMode;
//     public boolean readOnly;
// 
//     public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
//         checkNotNullOrEmpty(source);
//         checkNotNullOrEmpty(target);
// 
//         this.source = source;
//         this.target = target;
//         this.accessMode = accessMode;
//         this.readOnly = readOnly;
//     }
// 
//     @Override
//     public String toString() {
//         return "Filesystem{" +
//                 "source='" + source + '\'' +
//                 ", target='" + target + '\'' +
//                 ", accessMode=" + accessMode +
//                 ", readOnly=" + readOnly +
//                 '}';
//     }
// }


import java.util.Collections;
import java.util.Map;
import com.xebialabs.overcast.Resources;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
/**
 *    Copyright 2012-2021 Digital.ai
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package com.xebialabs.overcast.support.libvirt.jdom;





public class FilesystemXmlTest {

    public Document getXml(String file) throws Exception {
        SAXBuilder saxBuilder = new SAXBuilder();
        return saxBuilder.build(Resources.getResource(file));
    }

    @Test
    public void shouldReadNoFilesystems() throws Exception {
        Document domainXml = getXml("libvirt-xml/simple-domain.xml");
        Map<String, Filesystem> fs = FilesystemXml.getFilesystems(domainXml);
        assertThat(fs, equalTo(Collections.EMPTY_MAP));
    }

    @Test
    public void shouldReadFilesystems() throws Exception {
        Document domainXml = getXml("libvirt-xml/domain-with-filesystem.xml");

// Path: src/main/java/com/xebialabs/overcast/Resources.java
// public final class Resources {
//     private Resources() {}
// 
//     public static URL getResource(String resourceName) {
//         ClassLoader loader = Thread.currentThread().getContextClassLoader();
//         if (loader == null) {
//             loader = Resources.class.getClassLoader();
//         }
//         URL url = loader.getResource(resourceName);
//         checkArgument(url != null, "resource %s not found.", resourceName);
//         return url;
//     }
// 
// }
// 
// Path: src/main/java/com/xebialabs/overcast/support/libvirt/Filesystem.java
// public class Filesystem {
//     public enum AccessMode {
//         /** The source is accessed with the permissions of the user inside the guest. This is the default. */
//         PASSTHROUGH,
//         /** The source is accessed with the permissions of the hypervisor (QEMU process). */
//         MAPPED,
//         /**
//          * Similar to {@link AccessMode#PASSTHROUGH}, the exception is that failure of privileged operations like
//          * 'chown' are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root.
//          */
//         SQUASH,
//     }
// 
//     public String source;
//     public String target;
//     public AccessMode accessMode;
//     public boolean readOnly;
// 
//     public Filesystem(String source, String target, AccessMode accessMode, boolean readOnly) {
//         checkNotNullOrEmpty(source);
//         checkNotNullOrEmpty(target);
// 
//         this.source = source;
//         this.target = target;
//         this.accessMode = accessMode;
//         this.readOnly = readOnly;
//     }
// 
//     @Override
//     public String toString() {
//         return "Filesystem{" +
//                 "source='" + source + '\'' +
//                 ", target='" + target + '\'' +
//                 ", accessMode=" + accessMode +
//                 ", readOnly=" + readOnly +
//                 '}';
//     }
// }


// Path: src/test/java/com/xebialabs/overcast/support/libvirt/jdom/FilesystemXmlTest.java
import java.util.Collections;
import java.util.Map;
import com.xebialabs.overcast.Resources;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import com.xebialabs.overcast.support.libvirt.Filesystem;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;

/**
 *    Copyright 2012-2021 Digital.ai
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package com.xebialabs.overcast.support.libvirt.jdom;





public class FilesystemXmlTest {

    public Document getXml(String file) throws Exception {
        SAXBuilder saxBuilder = new SAXBuilder();
        return saxBuilder.build(Resources.getResource(file));
    }

    @Test
    public void shouldReadNoFilesystems() throws Exception {
        Document domainXml = getXml("libvirt-xml/simple-domain.xml");
        Map<String, Filesystem> fs = FilesystemXml.getFilesystems(domainXml);
        assertThat(fs, equalTo(Collections.EMPTY_MAP));
    }

    @Test
    public void shouldReadFilesystems() throws Exception {
        Document domainXml = getXml("libvirt-xml/domain-with-filesystem.xml");

        Map<String, Filesystem> fs = FilesystemXml.getFilesystems(domainXml);