diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/builder/JUnitMethodBodyBuilder.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/builder/JUnitMethodBodyBuilder.groovy index bcec159597..bd84b6ab41 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/builder/JUnitMethodBodyBuilder.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/builder/JUnitMethodBodyBuilder.groovy @@ -3,7 +3,6 @@ package io.codearte.accurest.builder import groovy.json.StringEscapeUtils import groovy.transform.PackageScope import groovy.transform.TypeChecked -import io.codearte.accurest.config.TestFramework import io.codearte.accurest.dsl.GroovyDsl import io.codearte.accurest.dsl.internal.ExecutionProperty import io.codearte.accurest.dsl.internal.Header diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/builder/JaxRsClientJUnitMethodBodyBuilder.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/builder/JaxRsClientJUnitMethodBodyBuilder.groovy index 67827a70b9..27c5d0f51a 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/builder/JaxRsClientJUnitMethodBodyBuilder.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/builder/JaxRsClientJUnitMethodBodyBuilder.groovy @@ -1,6 +1,5 @@ package io.codearte.accurest.builder -import io.codearte.accurest.config.TestFramework import io.codearte.accurest.dsl.GroovyDsl import io.codearte.accurest.dsl.internal.Header import io.codearte.accurest.dsl.internal.QueryParameter diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/builder/MethodBodyBuilder.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/builder/MethodBodyBuilder.groovy index e8b9efb6e0..a78488d441 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/builder/MethodBodyBuilder.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/builder/MethodBodyBuilder.groovy @@ -20,7 +20,6 @@ import io.codearte.accurest.util.JsonToJsonPathsConverter import io.codearte.accurest.util.MapConverter import static io.codearte.accurest.util.ContentUtils.extractValue -import static io.codearte.accurest.util.ContentUtils.getGroovyMultipartFileParameterContent import static io.codearte.accurest.util.ContentUtils.recognizeContentTypeFromContent import static io.codearte.accurest.util.ContentUtils.recognizeContentTypeFromHeader @@ -187,7 +186,7 @@ abstract class MethodBodyBuilder { protected void processText(BlockBuilder blockBuilder, String property, String value) { if (value.startsWith('$')) { - value = value.substring(1).replaceAll('\\$value', "responseBody$property") + value = stripFirstChar(value).replaceAll('\\$value', "responseBody$property") blockBuilder.addLine(value) addColonIfRequired(blockBuilder) } else { @@ -195,6 +194,10 @@ abstract class MethodBodyBuilder { } } + private String stripFirstChar(String s) { + return s.substring(1); + } + protected void processBodyElement(BlockBuilder blockBuilder, String property, Object value) { } @@ -210,7 +213,7 @@ abstract class MethodBodyBuilder { } protected String trimRepeatedQuotes(String toTrim) { - return toTrim.startsWith('"') ? toTrim.replaceAll('"', '') : toTrim // TODO: implement for JUnit + return toTrim.startsWith('"') ? toTrim.replaceAll('"', '') : toTrim } protected Object extractServerValueFromBody(bodyValue) { diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameter.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameter.groovy index 153fa6f297..c0ca01c97b 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameter.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/QueryParameter.groovy @@ -1,10 +1,10 @@ -package io.codearte.accurest.dsl.internal; +package io.codearte.accurest.dsl.internal -import groovy.transform.CompileStatic; -import groovy.transform.EqualsAndHashCode; +import groovy.transform.CompileStatic +import groovy.transform.EqualsAndHashCode import groovy.transform.ToString -import static io.codearte.accurest.util.ValidateUtils.validateServerValueIsAvailable; +import static io.codearte.accurest.util.ValidateUtils.validateServerValueIsAvailable @EqualsAndHashCode(includeFields = true) @ToString(includePackage = false, includeFields = true, ignoreNulls = true, includeNames = true) diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/UrlPath.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/UrlPath.groovy index 68d9bc0f7d..4b77520cc3 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/UrlPath.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/dsl/internal/UrlPath.groovy @@ -1,8 +1,8 @@ package io.codearte.accurest.dsl.internal -import groovy.transform.CompileStatic; +import groovy.transform.CompileStatic import groovy.transform.EqualsAndHashCode -import groovy.transform.ToString; +import groovy.transform.ToString @ToString(includePackage = false, includeFields = true, includeNames = true) @EqualsAndHashCode(includeFields = true) diff --git a/accurest-core/src/main/groovy/io/codearte/accurest/file/ContractFileScanner.groovy b/accurest-core/src/main/groovy/io/codearte/accurest/file/ContractFileScanner.groovy index 1e1e27c310..8c0ea132ec 100644 --- a/accurest-core/src/main/groovy/io/codearte/accurest/file/ContractFileScanner.groovy +++ b/accurest-core/src/main/groovy/io/codearte/accurest/file/ContractFileScanner.groovy @@ -2,7 +2,6 @@ package io.codearte.accurest.file import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ListMultimap -import com.google.common.collect.Multimap import org.apache.commons.io.FilenameUtils import java.nio.file.FileSystem diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcMethodBodyBuilderSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcMethodBodyBuilderSpec.groovy index d2390e5cca..ab3a0ae4c3 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcMethodBodyBuilderSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/builder/MockMvcMethodBodyBuilderSpec.groovy @@ -1,9 +1,7 @@ package io.codearte.accurest.builder import io.codearte.accurest.dsl.GroovyDsl -import io.codearte.accurest.dsl.WireMockStubStrategy import io.codearte.accurest.dsl.WireMockStubVerifier -import io.codearte.accurest.file.Contract import spock.lang.Issue import spock.lang.Shared import spock.lang.Specification diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/file/ContractFileScannerSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/file/ContractFileScannerSpec.groovy index e02e06cc56..30a5def61c 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/file/ContractFileScannerSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/file/ContractFileScannerSpec.groovy @@ -1,7 +1,6 @@ package io.codearte.accurest.file import com.google.common.collect.ListMultimap -import com.google.common.collect.Multimap import spock.lang.Specification import java.nio.file.Path diff --git a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/SampleJerseyProjectSpec.groovy b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/SampleJerseyProjectSpec.groovy index 9784abcb05..4c8c4026a1 100755 --- a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/SampleJerseyProjectSpec.groovy +++ b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/SampleJerseyProjectSpec.groovy @@ -6,7 +6,6 @@ import spock.lang.Stepwise import java.nio.file.Files import java.nio.file.Path -import static java.nio.charset.StandardCharsets.UTF_8 import static java.nio.charset.StandardCharsets.UTF_8 @Stepwise @@ -19,7 +18,8 @@ class SampleJerseyProjectSpec extends IntegrationSpec { void setup() { copyResources("functionalTest/sampleJerseyProject", "") - runTasksSuccessfully('clean') //delete accidental output when previously importing SimpleBoot into Idea to tweak it + runTasksSuccessfully('clean') + //delete accidental output when previously importing SimpleBoot into Idea to tweak it } def "should pass basic flow for Spock"() { diff --git a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/SampleProjectSpec.groovy b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/SampleProjectSpec.groovy index 4ff481157f..9bb3c390f9 100755 --- a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/SampleProjectSpec.groovy +++ b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/SampleProjectSpec.groovy @@ -2,12 +2,10 @@ package io.codearte.accurest.plugin import nebula.test.IntegrationSpec import spock.lang.Stepwise -import spock.lang.Unroll import java.nio.file.Files import java.nio.file.Path -import static java.nio.charset.StandardCharsets.UTF_8 import static java.nio.charset.StandardCharsets.UTF_8 @Stepwise diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/com/blogspot/toomuchcoding/frauddetection/Application.java b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/com/blogspot/toomuchcoding/frauddetection/Application.java index 2089bda142..99a72fbf26 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/com/blogspot/toomuchcoding/frauddetection/Application.java +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/main/java/com/blogspot/toomuchcoding/frauddetection/Application.java @@ -1,6 +1,5 @@ package com.blogspot.toomuchcoding.frauddetection; -import org.glassfish.jersey.client.HttpUrlConnectorProvider; import org.glassfish.jersey.server.ResourceConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/java/com/blogspot/toomuchcoding/MvcTest.java b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/java/com/blogspot/toomuchcoding/MvcTest.java index d13134ecc8..d36d31e510 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/java/com/blogspot/toomuchcoding/MvcTest.java +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/fraudDetectionService/src/test/java/com/blogspot/toomuchcoding/MvcTest.java @@ -1,4 +1,5 @@ package com.blogspot.toomuchcoding; + import com.blogspot.toomuchcoding.frauddetection.Application; import com.blogspot.toomuchcoding.frauddetection.FraudRestApplication; import org.eclipse.jetty.server.Server; @@ -14,7 +15,6 @@ import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.UriBuilder; - import java.net.URI; import static org.springframework.util.SocketUtils.findAvailableTcpPort; diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/java/com/blogspot/toomuchcoding/MvcTest.java b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/java/com/blogspot/toomuchcoding/MvcTest.java index f8d460e160..084a65ebf5 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/java/com/blogspot/toomuchcoding/MvcTest.java +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/src/test/java/com/blogspot/toomuchcoding/MvcTest.java @@ -1,8 +1,6 @@ package com.blogspot.toomuchcoding; -import com.blogspot.toomuchcoding.frauddetection.FraudDetectionController; import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc; -import spock.lang.Specification; import org.junit.Before; public class MvcTest {