From 209f3ce2a0dee678d9601bb69547be7add0841ea Mon Sep 17 00:00:00 2001 From: Marcin Zajaczkowski Date: Tue, 24 Feb 2015 13:13:43 +0100 Subject: [PATCH] Test suffix is used also in class name (not only in file name) --- .../src/main/groovy/io/coderate/accurest/FileSaver.groovy | 3 +-- .../src/main/groovy/io/coderate/accurest/TestGenerator.groovy | 2 +- .../test/groovy/io/codearte/accurest/TestGeneratorSpec.groovy | 4 ++-- .../io/codearte/accurest/plugin/BasicFunctionalSpec.groovy | 4 ++-- .../test/resources/functionalTest/bootSimple/settings.gradle | 1 + 5 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/settings.gradle diff --git a/accurest-core/src/main/groovy/io/coderate/accurest/FileSaver.groovy b/accurest-core/src/main/groovy/io/coderate/accurest/FileSaver.groovy index e0fcf760c8..2d20399d8a 100644 --- a/accurest-core/src/main/groovy/io/coderate/accurest/FileSaver.groovy +++ b/accurest-core/src/main/groovy/io/coderate/accurest/FileSaver.groovy @@ -28,8 +28,7 @@ class FileSaver { Path testBaseDir = Paths.get(targetDirectory.absolutePath, NamesUtil.packageToDirectory(packageName)) Files.createDirectories(testBaseDir) - Path classPath = Paths.get(testBaseDir.toString(), capitalize(fileName) + framework.classNameSuffix + framework.classExtension) - .toAbsolutePath() + Path classPath = Paths.get(testBaseDir.toString(), capitalize(fileName) + framework.classExtension).toAbsolutePath() log.info("Creating new class file [$classPath]") Files.write(classPath, classBytes, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING) } diff --git a/accurest-core/src/main/groovy/io/coderate/accurest/TestGenerator.groovy b/accurest-core/src/main/groovy/io/coderate/accurest/TestGenerator.groovy index 8cfd7a7ac4..f8a7e25496 100644 --- a/accurest-core/src/main/groovy/io/coderate/accurest/TestGenerator.groovy +++ b/accurest-core/src/main/groovy/io/coderate/accurest/TestGenerator.groovy @@ -62,7 +62,7 @@ class TestGenerator { return new File(configProperties.contractsDslDir, it) } if (filesToClass.size()) { - def className = afterLast(includedDirectoryRelativePath, File.separator) + def className = afterLast(includedDirectoryRelativePath, File.separator) + configProperties.targetFramework.classNameSuffix def classBytes = generator.buildClass(filesToClass, className, packageNameForClass).bytes saver.saveClassFile(className, packageNameForClass, classBytes) counter.incrementAndGet() diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/TestGeneratorSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/TestGeneratorSpec.groovy index f9f0233cbe..84eb77ab58 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/TestGeneratorSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/TestGeneratorSpec.groovy @@ -32,7 +32,7 @@ class TestGeneratorSpec extends Specification { when: testGenerator.generateTestClasses("com.ofg") then: - 1 * classGenerator.buildClass(_, 'different', _) >> "qwerty" + 1 * classGenerator.buildClass(_, 'differentSpec', _) >> "qwerty" } def "should ignore file"() { @@ -46,6 +46,6 @@ class TestGeneratorSpec extends Specification { when: testGenerator.generateTestClasses("com.ofg") then: - 1 * classGenerator.buildClass({ it.size() == 1 }, 'other', _) >> "sample.groovy" + 1 * classGenerator.buildClass({ it.size() == 1 }, 'otherSpec', _) >> "sample.groovy" } } diff --git a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/BasicFunctionalSpec.groovy b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/BasicFunctionalSpec.groovy index a494d2d837..16c48b2516 100644 --- a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/BasicFunctionalSpec.groovy +++ b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/BasicFunctionalSpec.groovy @@ -13,7 +13,7 @@ class BasicFunctionalSpec extends IntegrationSpec { then: fileExists('build.gradle') when: - def result = runTasksSuccessfully('check') + def result = runTasksSuccessfully('clean', 'check') //clean to remove accidental output when importing SimpleBoot into Idea then: result.wasExecuted(":generateWiremockClientStubs") result.wasExecuted(":generateAccurest") @@ -25,7 +25,7 @@ class BasicFunctionalSpec extends IntegrationSpec { fileExists("build/production/bootSimple-stubs/repository/mappings/pairId/colleratePlacesFromTweet.json") and: "generated tests executed" - fileExists("build/test-results/TEST-accurest.PairId.xml") + fileExists("build/test-results/TEST-accurest.PairIdSpec.xml") } def "should generate valid client json stubs for simple input"() { diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/settings.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/settings.gradle new file mode 100644 index 0000000000..d227b869a2 --- /dev/null +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/settings.gradle @@ -0,0 +1 @@ +rootProject.name='bootSimple'