// Path: src/main/java/net/ozwolf/mockserver/raml/handlers/ZipArchiveHandler.java
// public class ZipArchiveHandler implements RamlResourceHandler {
//     private final File targetDirectory;
//     private final File specificationFile;
// 
//     /**
//      * Create a new ZIP archive remote resource handler.
//      *
//      * @param targetDirectory   The directory to unpack the ZIP archive into.
//      * @param specificationFile The root RAML specification file to expect (sans path)
//      */
//     public ZipArchiveHandler(File targetDirectory, File specificationFile) {
//         this.targetDirectory = targetDirectory;
//         this.specificationFile = specificationFile;
//     }
// 
//     /**
//      * Retrieve the specification file from the remote resource.
//      *
//      * @param file The downloaded file resource
//      * @return The RAML specification file
//      * @throws java.lang.IllegalAccessError       Target directory could not be created.
//      * @throws java.lang.IllegalArgumentException The target directory is not a directory
//      * @throws java.lang.IllegalStateException    The target directory could not be written to or the specification file was not found.
//      */
//     @Override
//     public File handle(File file) {
//         try {
//             String targetPath = FilenameUtils.separatorsToUnix(targetDirectory.getPath());
//             if (!targetDirectory.exists() && !targetDirectory.mkdirs())
//                 throw new IllegalAccessError(String.format("Could not create [ %s ] directory.", targetPath));
// 
//             if (targetDirectory.exists() && !targetDirectory.isDirectory())
//                 throw new IllegalArgumentException(String.format("[ %s ] is not a directory.", targetPath));
// 
//             if (targetDirectory.exists() && !targetDirectory.canWrite())
//                 throw new IllegalStateException(String.format("Cannot write to [ %s ].", targetPath));
// 
//             ZipFile zipFile = new ZipFile(file);
//             zipFile.extractAll(targetDirectory.getPath());
// 
//             if (!specificationFile.exists() || !specificationFile.canRead())
//                 throw new IllegalStateException(String.format("Could not find or access [ %s ].", FilenameUtils.separatorsToUnix(specificationFile.getPath())));
// 
//             return specificationFile;
//         } catch (ZipException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     /**
//      * Create a resource handler that expects a ZIP archive as the remote resource.  Will unpack the zip archive into the target directory and will return a File object to the named specification file.
//      *
//      * @param targetDirectory       The directory to unpack the ZIP archive to.
//      * @param specificationFileName The name of the root RAML specification file (sans pathing)
//      * @return The pointer to the RAML specification file.
//      */
//     public static RamlResourceHandler handler(String targetDirectory, String specificationFileName) {
//         return new ZipArchiveHandler(new File(targetDirectory), Paths.get(targetDirectory, specificationFileName).toFile());
//     }
// }
// 
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static File zipFixture(String path) throws ZipException {
//     File source = new File(path);
//     File target = new File("target/archives/zip-archive-test.zip");
//     if (target.exists() && !target.delete())
//         throw new RuntimeException("Unable to delete old zip file target");
// 
//     if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
//         throw new RuntimeException("Unable to create directories for zip file target");
// 
//     ZipFile zipFile = new ZipFile(target);
//     ZipParameters parameters = new ZipParameters();
//     parameters.setIncludeRootFolder(false);
//     zipFile.createZipFileFromFolder(source, parameters, false, -1);
// 
//     return target;
// }


import net.lingala.zip4j.exception.ZipException;
import net.ozwolf.mockserver.raml.handlers.ZipArchiveHandler;
import org.junit.Test;
import org.raml.model.Raml;
import java.io.File;
import static net.ozwolf.mockserver.raml.util.Fixtures.zipFixture;
import static org.assertj.core.api.Assertions.assertThat;
package net.ozwolf.mockserver.raml.specification;




public class RemoteSpecificationTest {
    @Test
    public void shouldLoadRamlFromRemoteLocationAndUseProvidedFileHandler() throws ZipException {
// Path: src/main/java/net/ozwolf/mockserver/raml/handlers/ZipArchiveHandler.java
// public class ZipArchiveHandler implements RamlResourceHandler {
//     private final File targetDirectory;
//     private final File specificationFile;
// 
//     /**
//      * Create a new ZIP archive remote resource handler.
//      *
//      * @param targetDirectory   The directory to unpack the ZIP archive into.
//      * @param specificationFile The root RAML specification file to expect (sans path)
//      */
//     public ZipArchiveHandler(File targetDirectory, File specificationFile) {
//         this.targetDirectory = targetDirectory;
//         this.specificationFile = specificationFile;
//     }
// 
//     /**
//      * Retrieve the specification file from the remote resource.
//      *
//      * @param file The downloaded file resource
//      * @return The RAML specification file
//      * @throws java.lang.IllegalAccessError       Target directory could not be created.
//      * @throws java.lang.IllegalArgumentException The target directory is not a directory
//      * @throws java.lang.IllegalStateException    The target directory could not be written to or the specification file was not found.
//      */
//     @Override
//     public File handle(File file) {
//         try {
//             String targetPath = FilenameUtils.separatorsToUnix(targetDirectory.getPath());
//             if (!targetDirectory.exists() && !targetDirectory.mkdirs())
//                 throw new IllegalAccessError(String.format("Could not create [ %s ] directory.", targetPath));
// 
//             if (targetDirectory.exists() && !targetDirectory.isDirectory())
//                 throw new IllegalArgumentException(String.format("[ %s ] is not a directory.", targetPath));
// 
//             if (targetDirectory.exists() && !targetDirectory.canWrite())
//                 throw new IllegalStateException(String.format("Cannot write to [ %s ].", targetPath));
// 
//             ZipFile zipFile = new ZipFile(file);
//             zipFile.extractAll(targetDirectory.getPath());
// 
//             if (!specificationFile.exists() || !specificationFile.canRead())
//                 throw new IllegalStateException(String.format("Could not find or access [ %s ].", FilenameUtils.separatorsToUnix(specificationFile.getPath())));
// 
//             return specificationFile;
//         } catch (ZipException e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     /**
//      * Create a resource handler that expects a ZIP archive as the remote resource.  Will unpack the zip archive into the target directory and will return a File object to the named specification file.
//      *
//      * @param targetDirectory       The directory to unpack the ZIP archive to.
//      * @param specificationFileName The name of the root RAML specification file (sans pathing)
//      * @return The pointer to the RAML specification file.
//      */
//     public static RamlResourceHandler handler(String targetDirectory, String specificationFileName) {
//         return new ZipArchiveHandler(new File(targetDirectory), Paths.get(targetDirectory, specificationFileName).toFile());
//     }
// }
// 
// Path: src/test/java/net/ozwolf/mockserver/raml/util/Fixtures.java
// public static File zipFixture(String path) throws ZipException {
//     File source = new File(path);
//     File target = new File("target/archives/zip-archive-test.zip");
//     if (target.exists() && !target.delete())
//         throw new RuntimeException("Unable to delete old zip file target");
// 
//     if (!target.getParentFile().exists() && !target.getParentFile().mkdirs())
//         throw new RuntimeException("Unable to create directories for zip file target");
// 
//     ZipFile zipFile = new ZipFile(target);
//     ZipParameters parameters = new ZipParameters();
//     parameters.setIncludeRootFolder(false);
//     zipFile.createZipFileFromFolder(source, parameters, false, -1);
// 
//     return target;
// }


// Path: src/test/java/net/ozwolf/mockserver/raml/specification/RemoteSpecificationTest.java
import net.lingala.zip4j.exception.ZipException;
import net.ozwolf.mockserver.raml.handlers.ZipArchiveHandler;
import org.junit.Test;
import org.raml.model.Raml;
import java.io.File;
import static net.ozwolf.mockserver.raml.util.Fixtures.zipFixture;
import static org.assertj.core.api.Assertions.assertThat;

package net.ozwolf.mockserver.raml.specification;




public class RemoteSpecificationTest {
    @Test
    public void shouldLoadRamlFromRemoteLocationAndUseProvidedFileHandler() throws ZipException {
        File zip = zipFixture("src/test/resources/apispecs-test");