// Path: src/main/java/org/moe/gradle/utils/FileUtils.java
// public class FileUtils {
//     public static void deleteFileOrFolder(final @NotNull Path path) throws IOException {
//         Require.nonNull(path);
// 
//         if (!path.toFile().exists()) {
//             return;
//         }
//         Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
//             @Override
//             public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs)
//                     throws IOException {
//                 Files.delete(file);
//                 return CONTINUE;
//             }
// 
//             @Override
//             public FileVisitResult postVisitDirectory(final Path dir, final IOException e)
//                     throws IOException {
//                 if (e != null) throw e;
//                 Files.delete(dir);
//                 return CONTINUE;
//             }
//         });
//     }
// 
//     public static void deleteFileOrFolder(final @NotNull File file) throws IOException {
//         Require.nonNull(file);
// 
//         deleteFileOrFolder(Paths.get(file.toURI()));
//     }
// 
//     @NotNull
//     public static String read(@NotNull File file) {
//         Require.nonNull(file);
// 
//         String string;
//         try {
//             string = new String(Files.readAllBytes(Paths.get(file.toURI())));
//         } catch (IOException e) {
//             throw new GradleException("Failed to read " + file, e);
//         }
//         return string;
//     }
// 
//     public static void write(@NotNull File file, @NotNull String string) {
//         Require.nonNull(file);
//         Require.nonNull(string);
// 
//         try {
//             Files.write(Paths.get(file.toURI()), string.getBytes(),
//                     StandardOpenOption.CREATE,
//                     StandardOpenOption.WRITE,
//                     StandardOpenOption.TRUNCATE_EXISTING);
//         } catch (IOException e) {
//             throw new GradleException("Failed to write " + file, e);
//         }
//     }
// 
//     @NotNull
//     public static File getRelativeTo(@NotNull File base, @NotNull File other) {
//         Require.nonNull(base);
//         Require.nonNull(other);
// 
//         return Paths.get(base.getAbsolutePath()).relativize(Paths.get(other.getAbsolutePath())).toFile();
//     }
// 
//     @NotNull
//     public static String getNameAsArtifact(@NotNull File file, @NotNull String version) {
//         Require.nonNull(file);
//         Require.nonNull(version);
// 
//         final String name = file.getName();
//         final int idx = name.indexOf('.');
//         if (idx == -1) {
//             throw new GradleException("Unexpected state");
// 
//         } else {
//             final String baseName = name.substring(0, idx);
//             final String ext = name.substring(idx + 1);
//             return "multi-os-engine:" + baseName + ":" + version + "@" + ext;
//         }
//     }
// 
//     public static void classAndJarInputIterator(
//             @NotNull FileCollection fileCollection,
//             @NotNull Consumer<InputStream> consumer
//     ) {
//         FileUtilsKt.classAndJarInputIterator(fileCollection, (path, inputStream) -> {
//             consumer.accept(inputStream);
//             return Unit.INSTANCE;
//         });
//     }
// }


import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.junit.Test;
import org.moe.generator.project.MOEProjectComposer;
import org.moe.generator.project.MOEProjectComposer.MOEProjectComposerException;
import org.moe.generator.project.MOEProjectComposer.Template;
import org.moe.gradle.utils.FileUtils;
import java.io.File;
import java.io.IOException;
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;
import static org.junit.Assert.*;
/*
Copyright (C) 2017 Migeran

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 org.moe.gradle;




public class UIActionsAndOutletsTest extends AbstractPluginTest {

    protected String getTestResourcesFolder() {
        return "ui-actions-and-outlets";
    }

    @Test
    public void testGeneratedCode() throws MOEProjectComposerException, IOException {
        new MOEProjectComposer()
                .setMoeVersion("0.0.0")
                .setOrganizationID("org.moe")
                .setOrganizationName("Multi-OS Engine")
                .setPackageName("org.moe")
                .setProjectName("Test")
                .setTargetDirectory(testProjectDir.getRoot())
                .setTemplate(Template.IOS_JAVA_SINGLE_VIEW)
                .setSubproject(true)
                .compose();

        copyJavaSourceFile("IgnoredController.java");
        copyJavaSourceFile("InvalidController.java");
        copyJavaSourceFile("UnmappedController.java");
        copyJavaSourceFile("ValidController.java");

        final File buildGradleFile = new File(testProjectDir.getRoot(), "build.gradle");
// Path: src/main/java/org/moe/gradle/utils/FileUtils.java
// public class FileUtils {
//     public static void deleteFileOrFolder(final @NotNull Path path) throws IOException {
//         Require.nonNull(path);
// 
//         if (!path.toFile().exists()) {
//             return;
//         }
//         Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
//             @Override
//             public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs)
//                     throws IOException {
//                 Files.delete(file);
//                 return CONTINUE;
//             }
// 
//             @Override
//             public FileVisitResult postVisitDirectory(final Path dir, final IOException e)
//                     throws IOException {
//                 if (e != null) throw e;
//                 Files.delete(dir);
//                 return CONTINUE;
//             }
//         });
//     }
// 
//     public static void deleteFileOrFolder(final @NotNull File file) throws IOException {
//         Require.nonNull(file);
// 
//         deleteFileOrFolder(Paths.get(file.toURI()));
//     }
// 
//     @NotNull
//     public static String read(@NotNull File file) {
//         Require.nonNull(file);
// 
//         String string;
//         try {
//             string = new String(Files.readAllBytes(Paths.get(file.toURI())));
//         } catch (IOException e) {
//             throw new GradleException("Failed to read " + file, e);
//         }
//         return string;
//     }
// 
//     public static void write(@NotNull File file, @NotNull String string) {
//         Require.nonNull(file);
//         Require.nonNull(string);
// 
//         try {
//             Files.write(Paths.get(file.toURI()), string.getBytes(),
//                     StandardOpenOption.CREATE,
//                     StandardOpenOption.WRITE,
//                     StandardOpenOption.TRUNCATE_EXISTING);
//         } catch (IOException e) {
//             throw new GradleException("Failed to write " + file, e);
//         }
//     }
// 
//     @NotNull
//     public static File getRelativeTo(@NotNull File base, @NotNull File other) {
//         Require.nonNull(base);
//         Require.nonNull(other);
// 
//         return Paths.get(base.getAbsolutePath()).relativize(Paths.get(other.getAbsolutePath())).toFile();
//     }
// 
//     @NotNull
//     public static String getNameAsArtifact(@NotNull File file, @NotNull String version) {
//         Require.nonNull(file);
//         Require.nonNull(version);
// 
//         final String name = file.getName();
//         final int idx = name.indexOf('.');
//         if (idx == -1) {
//             throw new GradleException("Unexpected state");
// 
//         } else {
//             final String baseName = name.substring(0, idx);
//             final String ext = name.substring(idx + 1);
//             return "multi-os-engine:" + baseName + ":" + version + "@" + ext;
//         }
//     }
// 
//     public static void classAndJarInputIterator(
//             @NotNull FileCollection fileCollection,
//             @NotNull Consumer<InputStream> consumer
//     ) {
//         FileUtilsKt.classAndJarInputIterator(fileCollection, (path, inputStream) -> {
//             consumer.accept(inputStream);
//             return Unit.INSTANCE;
//         });
//     }
// }


// Path: src/test/java/org/moe/gradle/UIActionsAndOutletsTest.java
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.junit.Test;
import org.moe.generator.project.MOEProjectComposer;
import org.moe.generator.project.MOEProjectComposer.MOEProjectComposerException;
import org.moe.generator.project.MOEProjectComposer.Template;
import org.moe.gradle.utils.FileUtils;
import java.io.File;
import java.io.IOException;
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;
import static org.junit.Assert.*;

/*
Copyright (C) 2017 Migeran

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 org.moe.gradle;




public class UIActionsAndOutletsTest extends AbstractPluginTest {

    protected String getTestResourcesFolder() {
        return "ui-actions-and-outlets";
    }

    @Test
    public void testGeneratedCode() throws MOEProjectComposerException, IOException {
        new MOEProjectComposer()
                .setMoeVersion("0.0.0")
                .setOrganizationID("org.moe")
                .setOrganizationName("Multi-OS Engine")
                .setPackageName("org.moe")
                .setProjectName("Test")
                .setTargetDirectory(testProjectDir.getRoot())
                .setTemplate(Template.IOS_JAVA_SINGLE_VIEW)
                .setSubproject(true)
                .compose();

        copyJavaSourceFile("IgnoredController.java");
        copyJavaSourceFile("InvalidController.java");
        copyJavaSourceFile("UnmappedController.java");
        copyJavaSourceFile("ValidController.java");

        final File buildGradleFile = new File(testProjectDir.getRoot(), "build.gradle");
        String gradle = FileUtils.read(buildGradleFile);