org.gradle.testkit.runner.TaskOutcome Java Examples
The following examples show how to use
org.gradle.testkit.runner.TaskOutcome.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 6 votes |
@Test public void canRunTaskGenerateDrivenAdapterWithParameters() { canRunTaskGenerateStructureWithOutParameters(); String task = "generateDrivenAdapter"; String valueDrivenAdapter = "jpa"; runner.withArguments(task, "--type=" + valueDrivenAdapter); runner.withProjectDir(projectDir); BuildResult result = runner.build(); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/jpa-repository/build.gradle").exists()); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/jpa-repository/src/main/java/co/com/bancolombia/jpa/JPARepository.java").exists()); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/jpa-repository/src/main/java/co/com/bancolombia/jpa/JPARepositoryAdapter.java").exists()); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/jpa-repository/src/main/java/co/com/bancolombia/jpa/helper/AdapterOperations.java").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/java/co/com/bancolombia/config/JpaConfig.java").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #2
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 6 votes |
@Test public void canRunTaskGenerateDrivenAdapterEventBusTest() { canRunTaskGenerateStructureWithOutParameters(); String task = "generateDrivenAdapter"; String valueDrivenAdapter = "ASYNCEVENTBUS"; runner.withArguments(task, "--type=" + valueDrivenAdapter); runner.withProjectDir(projectDir); BuildResult result = runner.build(); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/async-event-bus/build.gradle").exists()); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/async-event-bus/src/main/java/co/com/bancolombia/event/ReactiveEventsGateway.java").exists()); assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/bancolombia/model/event/gateways/EventsGateway.java").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #3
Source File: UnMockTaskTest.java From unmock-plugin with Apache License 2.0 | 6 votes |
@Test public void unMockTaskIsNotUpToDateIfNewKeepClassAdded() { BuildResult firstResult = newGradleRunner().build(); assertSame(firstResult.task(":unMock").getOutcome(), TaskOutcome.SUCCESS); writeFile(BUILD_GRADLE_CONTENTS + "unMock {\n" + " keep \"android.net.Uri\"\n" + "}", buildGradle); BuildResult secondResult = newGradleRunner().build(); assertSame(secondResult.task(":unMock").getOutcome(), TaskOutcome.SUCCESS); }
Example #4
Source File: StageAppYamlExtensionTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testGetExtraFilesDirectoriesAsInputFiles_indirectFunctional() throws IOException { TestProject testProject = new TestProject(testProjectDir.getRoot()) .addAppYamlBuildFileWithExtraFilesDirectories() .addAppYaml("java11"); Files.write( testProject.getProjectRoot().toPath().resolve("src/main/extras/test1.txt"), "hello".getBytes(Charsets.UTF_8)); BuildResult firstRun = testProject.applyGradleRunner("appengineStage"); Assert.assertEquals(TaskOutcome.SUCCESS, firstRun.task(":appengineStage").getOutcome()); BuildResult secondRunNoChange = testProject.applyGradleRunner("appengineStage"); Assert.assertEquals( TaskOutcome.UP_TO_DATE, secondRunNoChange.task(":appengineStage").getOutcome()); Files.write( testProject.getProjectRoot().toPath().resolve("src/main/extras/test2.txt"), "hello".getBytes(Charsets.UTF_8)); BuildResult runWithNewFileAdded = testProject.applyGradleRunner("appengineStage"); Assert.assertEquals( TaskOutcome.SUCCESS, runWithNewFileAdded.task(":appengineStage").getOutcome()); }
Example #5
Source File: UnMockTaskTest.java From unmock-plugin with Apache License 2.0 | 5 votes |
@Test public void unMockTaskIsUpToDateOnSecondRun() { BuildResult firstResult = newGradleRunner().build(); BuildResult secondResult = newGradleRunner().build(); assertSame(firstResult.task(":unMock").getOutcome(), TaskOutcome.SUCCESS); assertSame(secondResult.task(":unMock").getOutcome(), TaskOutcome.UP_TO_DATE); }
Example #6
Source File: FormatTaskTests.java From spring-javaformat with Apache License 2.0 | 5 votes |
@Test public void checkOk() throws IOException { BuildResult result = this.gradleBuild.source("src/test/resources/format").build("format"); assertThat(result.task(":formatMain").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); File formattedFile = new File(this.gradleBuild.getProjectDir(), "src/main/java/simple/Simple.java"); String formattedContent = new String(Files.readAllBytes(formattedFile.toPath())); assertThat(formattedContent).contains("class Simple {"); }
Example #7
Source File: JavaFXPluginSmokeTest.java From javafx-gradle-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test void smokeTest() { var result = GradleRunner.create() .withProjectDir(new File("test-project")) .withGradleVersion("6.0.1") .withArguments("clean", "build", "run", "--stacktrace") .forwardOutput() .build(); assertEquals(TaskOutcome.SUCCESS, result.task(":modular:run").getOutcome(), "Failed build!"); assertEquals(TaskOutcome.SUCCESS, result.task(":non-modular:run").getOutcome(), "Failed build!"); assertEquals(TaskOutcome.SUCCESS, result.task(":transitive:run").getOutcome(), "Failed build!"); }
Example #8
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canRunTaskGenerateStructureWithOutParameters() { String task = "ca"; runner.withArguments(task); runner.withProjectDir(projectDir); BuildResult result = runner.build(); // Verify the result assertTrue(new File("build/functionalTest/README.md").exists()); assertTrue(new File("build/functionalTest/.gitignore").exists()); assertTrue(new File("build/functionalTest/build.gradle").exists()); assertTrue(new File("build/functionalTest/lombok.config").exists()); assertTrue(new File("build/functionalTest/main.gradle").exists()); assertTrue(new File("build/functionalTest/settings.gradle").exists()); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/").exists()); assertTrue(new File("build/functionalTest/infrastructure/entry-points").exists()); assertTrue(new File("build/functionalTest/infrastructure/helpers").exists()); assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/bancolombia/model").exists()); assertTrue(new File("build/functionalTest/domain/model/src/test/java/co/com/bancolombia/model").exists()); assertTrue(new File("build/functionalTest/domain/model/build.gradle").exists()); assertTrue(new File("build/functionalTest/domain/usecase/src/main/java/co/com/bancolombia/usecase").exists()); assertTrue(new File("build/functionalTest/domain/usecase/src/test/java/co/com/bancolombia/usecase").exists()); assertTrue(new File("build/functionalTest/domain/usecase/build.gradle").exists()); assertTrue(new File("build/functionalTest/applications/app-service/build.gradle").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/java/co/com/bancolombia/MainApplication.java").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/java/co/com/bancolombia/config").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/resources/application.yaml").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/resources/log4j2.properties").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/test/java/co/com/bancolombia").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #9
Source File: SimpleCodeGenerationTest.java From gradle-plugins with MIT License | 5 votes |
@Test @Ignore public void testBuild() { try { File resource = new File(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("test-code-generator.jar")).toURI()); FileUtils.copyFile(resource, new File(getTemporaryDirectory(), "test-code-generator.jar")); createGradleConfiguration() .applyPlugin("java") .applyPlugin("io.freefair.code-generator") .addDependency("codeGenerator", "files('test-code-generator.jar')") .write(); new File(getTemporaryDirectory(), "src/code-generator/main").mkdirs(); new File(getTemporaryDirectory(), "build").mkdirs(); } catch (Exception e) { throw new RuntimeException(e); } BuildResult generateCode = executeTask("generateCode"); System.out.println(generateCode.getOutput()); assertThat(Objects.requireNonNull(generateCode.task(":generateCode")).getOutcome(), is(equalTo(TaskOutcome.SUCCESS))); String javaClass = readJavaClassFromDirectory("build/generated-src/generator/main/", "io.freefair.gradle.codegen.test", "TestClass"); System.out.println(javaClass); assertThat(javaClass, not(isEmptyString())); }
Example #10
Source File: JoinfacesPluginIT.java From joinfaces with Apache License 2.0 | 5 votes |
@ParameterizedTest @ValueSource(strings = {"5.1.1", "5.4.1", "5.6.2"}) public void build(String gradleVersion, @TempDir Path projectDir) throws IOException { Files.write(projectDir.resolve("settings.gradle"), Collections.singleton("rootProject.name = 'dummy'")); Files.write(projectDir.resolve("build.gradle"), Arrays.asList( "plugins {", " id 'java'", " id 'groovy'", " id 'scala'", " id 'org.joinfaces'", "}", "repositories { mavenCentral() }", "dependencies {", " compile 'org.apache.myfaces.core:myfaces-impl:2.3.2'", "}" )); BuildResult buildResult = GradleRunner.create() .withProjectDir(projectDir.toFile()) .withPluginClasspath() .withArguments("jar", "-s", "--info") .withDebug(true) .withGradleVersion(gradleVersion) .build(); BuildTask scanClasspath = buildResult.task(":scanJoinfacesClasspath"); assertThat(scanClasspath).isNotNull(); assertThat(scanClasspath.getOutcome()).isEqualTo(TaskOutcome.SUCCESS); File jarFile = projectDir.resolve("build/libs/dummy.jar").toFile(); assertThat(jarFile).isFile(); try (ZipFile zipFile = new ZipFile(jarFile)) { assertThat(zipFile.getEntry("META-INF/joinfaces/org.apache.myfaces.ee.MyFacesContainerInitializer.classes")).isNotNull(); assertThat(zipFile.getEntry("META-INF/joinfaces/org.apache.myfaces.spi.AnnotationProvider.classes")).isNotNull(); } }
Example #11
Source File: HelloSassExampleTest.java From GradleSassPlugin with Apache License 2.0 | 5 votes |
@Test public void checkBuiltFiles() { BuildResult result = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withArguments("mainSass") .withPluginClasspath() .build(); assertEquals("check that ':mainSass' task succeeded", result.task(":mainSass").getOutcome(),TaskOutcome.SUCCESS); Path mainSassBuildRoot = Paths.get(testProjectDir.getRoot().getPath(), "build", "sass", "main"); assertTrue(mainSassBuildRoot.resolve(Paths.get("main.css")).toFile().exists()); assertTrue(mainSassBuildRoot.resolve(Paths.get("relPath","foo.css")).toFile().exists()); }
Example #12
Source File: IncrementalTasksTest.java From GradleSassPlugin with Apache License 2.0 | 5 votes |
@Test public void testFooDeletion() { BuildResult result = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withArguments("mainSass") .withPluginClasspath() .build(); assertEquals("check that ':mainSass' task succeeded", result.task(":mainSass").getOutcome(), TaskOutcome.SUCCESS); Path mainSassBuildRoot = Paths.get(testProjectDir.getRoot().getPath(), "build", "sass", "main"); assertTrue(mainSassBuildRoot.resolve(Paths.get("main.css")).toFile().exists()); assertTrue(mainSassBuildRoot.resolve(Paths.get("foo.css")).toFile().exists()); fooScss.delete(); BuildResult result2 = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withArguments("mainSass") .withPluginClasspath() .build(); assertEquals("check that ':mainSass' task succeeded", result2.task(":mainSass").getOutcome(), TaskOutcome.SUCCESS); assertTrue(mainSassBuildRoot.resolve(Paths.get("main.css")).toFile().exists()); assertFalse(mainSassBuildRoot.resolve(Paths.get("foo.css")).toFile().exists()); }
Example #13
Source File: BuildResultAssert.java From curiostack with MIT License | 5 votes |
/** Asserts that the {@code tasks} succeeded during the build. */ public BuildResultAssert tasksDidSucceed(Iterable<String> tasks) { tasksDidRun(tasks); SoftAssertions.assertSoftly( softly -> { for (var task : tasks) { BuildTask result = actual.task(task); softly .assertThat(result.getOutcome()) .as("Task %s did not succeed", task) .isEqualTo(TaskOutcome.SUCCESS); } }); return this; }
Example #14
Source File: UnMockTaskTest.java From unmock-plugin with Apache License 2.0 | 5 votes |
@Test public void unMockTaskIsNotUpToDateIfOutputJarIsDeleted() { BuildResult firstResult = newGradleRunner().build(); assertSame(firstResult.task(":unMock").getOutcome(), TaskOutcome.SUCCESS); GFileUtils.forceDelete(new File(testProjectDir.getRoot(), "build/intermediates/unmocked-android" + testProjectDir.getRoot() .getName() + ".jar")); BuildResult secondResult = newGradleRunner().build(); assertSame(secondResult.task(":unMock").getOutcome(), TaskOutcome.SUCCESS); }
Example #15
Source File: SimpleCodeGenerationTest.java From gradle-plugins with MIT License | 5 votes |
@Test @Ignore public void testBuild() { try { File resource = new File(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("test-code-generator.jar")).toURI()); FileUtils.copyFile(resource, new File(getTemporaryDirectory(), "test-code-generator.jar")); createGradleConfiguration() .applyPlugin("java") .applyPlugin("io.freefair.code-generator") .addDependency("codeGenerator", "files('test-code-generator.jar')") .write(); new File(getTemporaryDirectory(), "src/code-generator/main").mkdirs(); new File(getTemporaryDirectory(), "build").mkdirs(); } catch (Exception e) { throw new RuntimeException(e); } BuildResult generateCode = executeTask("generateCode"); System.out.println(generateCode.getOutput()); assertThat(Objects.requireNonNull(generateCode.task(":generateCode")).getOutcome(), is(equalTo(TaskOutcome.SUCCESS))); String javaClass = readJavaClassFromDirectory("build/generated-src/generator/main/", "io.freefair.gradle.codegen.test", "TestClass"); System.out.println(javaClass); assertThat(javaClass, not(isEmptyString())); }
Example #16
Source File: ThePluginCompilesJavaccToExpectedDirectoryStory.java From javaccPlugin with MIT License | 5 votes |
@Test public void givenASimpleProjectWithEmptyInputDirectoryWhenExecuteCompileJavaccTaskThenTaskIsSkipped() throws IOException, URISyntaxException { CompilationSteps steps = new CompilationSteps(); steps.givenAProjectNamed("simpleTestWithEmptyInputDirectory"); steps.withArguments(CLEAN, COMPILE_JAVACC).execute(); BuildResult buildResult = steps.withArguments(COMPILE_JAVACC).execute(); steps.thenAssertTaskStatus(buildResult, ":compileJavacc", TaskOutcome.UP_TO_DATE); }
Example #17
Source File: ByteBuddyPluginTest.java From byte-buddy with Apache License 2.0 | 5 votes |
private static File makePluginJar() throws IOException { File pluginFolder = TEMPORARY_FOLDER.newFolder("test-byte-buddy-plugin"); store("plugins { id 'java' }\n" + "repositories {\n" + " mavenLocal()\n" + " mavenCentral()\n" + "}\n" + "dependencies {\n" + " compile 'net.bytebuddy:byte-buddy:" + BYTE_BUDDY_VERSION + "'\n" + "}\n", new File(pluginFolder, "build.gradle")); File pluginRoot = new File(pluginFolder, "src/main/java/net/bytebuddy/test"); assertThat(pluginRoot.mkdirs(), is(true)); store("package net.bytebuddy.test;\n" + "\n" + "import net.bytebuddy.build.Plugin;\n" + "import net.bytebuddy.description.type.TypeDescription;\n" + "import net.bytebuddy.dynamic.ClassFileLocator;\n" + "import net.bytebuddy.dynamic.DynamicType;\n" + "import net.bytebuddy.implementation.FixedValue;\n" + "\n" + "import static net.bytebuddy.matcher.ElementMatchers.named;\n" + "\n" + "public class SimplePlugin implements Plugin {\n" + " public boolean matches(TypeDescription target) {\n" + " return target.getName().equals(\"net.bytebuddy.test.Sample\");\n" + " }\n" + " public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator) {\n" + " return builder.method(named(\"foo\")).intercept(FixedValue.value(\"qux\"));\n" + " }\n" + " public void close() { }\n" + "}\n", new File(pluginRoot, "SimplePlugin.java")); BuildResult result = GradleRunner.create() .withProjectDir(pluginFolder) .withArguments("jar") .build(); assertThat(result.task(":jar").getOutcome(), is(TaskOutcome.SUCCESS)); return new File(pluginFolder, "build/libs/test-byte-buddy-plugin.jar"); }
Example #18
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canRunTaskGeneratePipelineAzureDevOpsTest() { canRunTaskGenerateStructureWithOutParameters(); String task = "generatePipeline"; String valuePipeline = "AZURE"; runner.withArguments(task, "--type=" + valuePipeline); runner.withProjectDir(projectDir); BuildResult result = runner.build(); assertTrue(new File("build/functionalTest/deployment/cleanarchitecture_azure_build.yaml").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #19
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canRunTaskGenerateStructureWithParameters() { String task = "cleanArchitecture"; String packageName = "co.com.test"; String projectName = "ProjectName"; runner.withArguments(task, "--name=" + projectName, "--package=" + packageName); runner.withProjectDir(projectDir); BuildResult result = runner.build(); // Verify the result assertTrue(new File("build/functionalTest/README.md").exists()); assertTrue(new File("build/functionalTest/.gitignore").exists()); assertTrue(new File("build/functionalTest/build.gradle").exists()); assertTrue(new File("build/functionalTest/lombok.config").exists()); assertTrue(new File("build/functionalTest/main.gradle").exists()); assertTrue(new File("build/functionalTest/settings.gradle").exists()); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/").exists()); assertTrue(new File("build/functionalTest/infrastructure/entry-points").exists()); assertTrue(new File("build/functionalTest/infrastructure/helpers").exists()); assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/test/model").exists()); assertTrue(new File("build/functionalTest/domain/model/src/test/java/co/com/test/model").exists()); assertTrue(new File("build/functionalTest/domain/model/build.gradle").exists()); assertTrue(new File("build/functionalTest/domain/usecase/src/main/java/co/com/test/usecase").exists()); assertTrue(new File("build/functionalTest/domain/usecase/src/test/java/co/com/test/usecase").exists()); assertTrue(new File("build/functionalTest/domain/usecase/build.gradle").exists()); assertTrue(new File("build/functionalTest/applications/app-service/build.gradle").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/java/co/com/test/MainApplication.java").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/java/co/com/test/config").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/resources/application.yaml").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/resources/log4j2.properties").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/test/java/co/com/test").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #20
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canRunTaskGenerateModelWithParameters() { String task = "generateModel"; String modelName = "testModel"; // Run the build runner.withArguments(task, "--name=" + modelName); runner.withProjectDir(projectDir); BuildResult result = runner.build(); assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/bancolombia/model/testmodel/gateways/TestModelRepository.java").exists()); assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/bancolombia/model/testmodel/TestModel.java").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #21
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canRunTaskGenerateUseCaseWithParameters() { canRunTaskGenerateStructureWithOutParameters(); String task = "generateUseCase"; String useCaseName = "business"; // Setup the test buildÂș runner.withArguments(task, "--name=" + useCaseName); runner.withProjectDir(projectDir); BuildResult result = runner.build(); assertTrue(new File("build/functionalTest/domain/usecase/src/main/java/co/com/bancolombia/usecase/business/BusinessUseCase.java").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #22
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canRunTaskGenerateEntryPointCaseWithParameters() { canRunTaskGenerateStructureWithOutParameters(); String task = "generateEntryPoint"; String valueEntryPoint = "restmvc"; runner.withArguments(task, "--type=" + valueEntryPoint); runner.withProjectDir(projectDir); BuildResult result = runner.build(); assertTrue(new File("build/functionalTest/infrastructure/entry-points/api-rest/src/main/java/co/com/bancolombia/api/ApiRest.java").exists()); assertTrue(new File("build/functionalTest/infrastructure/entry-points/api-rest/build.gradle").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #23
Source File: CheckTaskTests.java From spring-javaformat with Apache License 2.0 | 5 votes |
@Test public void whenFirstInvocationFailsThenSecondInvocationFails() throws IOException { GradleBuild gradleBuild = this.gradleBuild.source("src/test/resources/check-bad"); BuildResult result = gradleBuild.buildAndFail("check"); assertThat(result.task(":checkFormatMain").getOutcome()).isEqualTo(TaskOutcome.FAILED); result = gradleBuild.buildAndFail("check"); assertThat(result.task(":checkFormatMain").getOutcome()).isEqualTo(TaskOutcome.FAILED); }
Example #24
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canRunTaskvalidateStructureWithOutParameters() { canRunTaskGenerateStructureWithOutParameters(); String task = "validateStructure"; runner.withArguments(task); runner.withProjectDir(projectDir); BuildResult result = runner.build(); // Verify the result assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #25
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void createTasks() { runner.withArguments("tasks"); runner.withProjectDir(projectDir); BuildResult result = runner.build(); // Verify the result assertTrue(result.getOutput().contains("cleanArchitecture")); assertTrue(result.getOutput().contains("generateModel")); assertTrue(result.getOutput().contains("validateStructure")); assertEquals(result.task(":tasks").getOutcome(), TaskOutcome.SUCCESS); }
Example #26
Source File: SwaggerHubUploadTest.java From swaggerhub-gradle-plugin with Apache License 2.0 | 5 votes |
private TaskOutcome runBuild(SwaggerHubRequest request) throws IOException { createBuildFile(request); BuildResult result = GradleRunner.create() .withPluginClasspath() .withProjectDir(testProjectDir.getRoot()) .withArguments(UPLOAD_TASK, "--stacktrace") .build(); return result.task(":" + UPLOAD_TASK).getOutcome(); }
Example #27
Source File: CheckTaskTests.java From spring-javaformat with Apache License 2.0 | 5 votes |
@Test public void whenFirstInvocationSucceedsAndSourceIsModifiedThenSecondInvocationSucceeds() throws IOException { copyFolder(new File("src/test/resources/check-ok").toPath(), this.temp.getRoot().toPath()); GradleBuild gradleBuild = this.gradleBuild.source(this.temp.getRoot()); BuildResult result = gradleBuild.build("check"); assertThat(result.task(":checkFormatMain").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); Files.write(new File(this.temp.getRoot(), "src/main/java/simple/Simple.java").toPath(), Collections.singletonList("// A change to the file"), StandardOpenOption.APPEND); result = gradleBuild.build("--debug", "check"); assertThat(result.task(":checkFormatMain").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); }
Example #28
Source File: CheckTaskTests.java From spring-javaformat with Apache License 2.0 | 5 votes |
@Test public void whenFirstInvocationSucceedsThenSecondInvocationIsUpToDate() throws IOException { GradleBuild gradleBuild = this.gradleBuild.source("src/test/resources/check-ok"); BuildResult result = gradleBuild.build("check"); assertThat(result.task(":checkFormatMain").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); result = gradleBuild.build("check"); assertThat(result.task(":checkFormatMain").getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE); }
Example #29
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canDeleteModule() { // Arrange canRunTaskGenerateDrivenAdapterWithParameters(); // Act runner.withArguments("deleteModule", "--module=jpa-repository"); runner.withProjectDir(projectDir); BuildResult result = runner.build(); // Assert assertFalse(new File("build/functionalTest/infrastructure/driven-adapters/jpa-repository").exists()); assertEquals(result.task(":deleteModule").getOutcome(), TaskOutcome.SUCCESS); }
Example #30
Source File: OpenAPIStyleValidatorGradlePluginFunctionalTest.java From openapi-style-validator with Apache License 2.0 | 4 votes |
@Test public void validateWithOptionsMustBeASuccess() throws IOException { // Setup the test build File projectDir = new File("build/functionalTest"); Files.createDirectories(projectDir.toPath()); writeString(new File(projectDir, "openapi.yaml"), "openapi: 3.0.1\n" + "info:\n" + " title: ping test\n" + " version: '1.0'\n" + "servers:\n" + " - url: 'http://localhost:9999/'\n" + "paths:\n" + " /ping:\n" + " post:\n" + " operationId: pingGet\n" + " responses:\n" + " '201':\n" + " description: OK"); writeString(new File(projectDir, "settings.gradle"), ""); writeString(new File(projectDir, "build.gradle"), "plugins {\n" + " id('org.openapitools.openapistylevalidator')\n" + "}\n" + "\n" + "openAPIStyleValidator {\n" + " // set the input file option:\n" + " inputFile = file('openapi.yaml')\n" + "\n" + " // customize the validation options:\n" + " validateInfoLicense = false\n" + " validateInfoDescription = false\n" + " validateInfoContact = false\n" + " validateOperationDescription = false\n" + " validateOperationTag = false\n" + " validateOperationSummary = false\n" + "}"); // Run the build GradleRunner runner = GradleRunner.create(); runner.forwardOutput(); runner.withPluginClasspath(); runner.withArguments("openAPIStyleValidator"); runner.withProjectDir(projectDir); BuildResult result = runner.build(); // Verify the result assertEquals(TaskOutcome.SUCCESS, result.task(":openAPIStyleValidator").getOutcome()); }