From 9066849d25bc34c6aedb22ef3d960e42b163cd98 Mon Sep 17 00:00:00 2001 From: Rafael Toledo Date: Fri, 27 Oct 2017 17:09:12 -0200 Subject: [PATCH 1/4] Libraries and tooling update --- build.gradle | 12 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- requestmatcher/build.gradle | 52 ++++++++++--------- ...trumentedExceptionWitouhtEnqueuesTest.java | 1 - .../test/RequestMatcherRuleTest.java | 3 +- .../requestmatcher/IOReaderTest.java | 3 -- tools/linters.gradle | 8 +++ 7 files changed, 44 insertions(+), 37 deletions(-) diff --git a/build.gradle b/build.gradle index d586b93..53b767f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,25 +1,25 @@ buildscript { repositories { + google() jcenter() - maven { url "http://maven.google.com" } } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' + classpath 'com.android.tools.build:gradle:3.0.0' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' } } allprojects { repositories { + google() jcenter() - maven { url "http://maven.google.com" } } } ext { minSdkVersion = 15 - targetSdkVersion = 25 + targetSdkVersion = 27 versionCode = Integer.parseInt(VERSION_CODE) versionName = VERSION_NAME } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9550717..cb1528e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/requestmatcher/build.gradle b/requestmatcher/build.gradle index 2b6ee01..474a518 100644 --- a/requestmatcher/build.gradle +++ b/requestmatcher/build.gradle @@ -4,8 +4,8 @@ apply from: "$rootDir/tools/publish.gradle" apply from: "$rootDir/tools/jacoco.gradle" android { - compileSdkVersion 26 - buildToolsVersion "26.0.0" + compileSdkVersion 27 + buildToolsVersion '27.0.0' defaultConfig { minSdkVersion rootProject.ext.minSdkVersion @@ -25,40 +25,42 @@ android { } sourceSets { - androidTest.java.srcDirs += "src/test-common/java" - test.java.srcDirs += "src/test-common/java" + androidTest.java.srcDirs += 'src/test-common/java' + test.java.srcDirs += 'src/test-common/java' } } +final supportLibrary = '27.0.0' final junit = '4.12' -final jsonPathAssert = '2.2.0' +final jsonPathAssert = '2.4.0' final hamcrest = '1.3' -final okhttpVersion = '3.8.0' -final testRunner = '0.5' +final okhttpVersion = '3.9.0' +final astl = '1.0.1' dependencies { - provided "junit:junit:$junit" - provided "com.jayway.jsonpath:json-path-assert:$jsonPathAssert" - provided "org.hamcrest:hamcrest-all:$hamcrest" - provided "com.squareup.okhttp3:mockwebserver:$okhttpVersion" - provided "com.android.support.test:runner:$testRunner" + compileOnly "junit:junit:$junit" + compileOnly "com.jayway.jsonpath:json-path-assert:$jsonPathAssert" + compileOnly "org.hamcrest:hamcrest-all:$hamcrest" + compileOnly "com.squareup.okhttp3:mockwebserver:$okhttpVersion" + compileOnly "com.android.support.test:runner:$astl" - testCompile "junit:junit:$junit" - testCompile "com.jayway.jsonpath:json-path-assert:$jsonPathAssert" - testCompile "org.hamcrest:hamcrest-all:$hamcrest" - testCompile "com.squareup.okhttp3:mockwebserver:$okhttpVersion" - testCompile "com.squareup.okhttp3:okhttp:$okhttpVersion" - testCompile 'org.robolectric:robolectric:3.3.2' - testCompile 'org.mockito:mockito-all:1.10.19' + testImplementation "junit:junit:$junit" + testImplementation "com.jayway.jsonpath:json-path-assert:$jsonPathAssert" + testImplementation "org.hamcrest:hamcrest-all:$hamcrest" + testImplementation "com.squareup.okhttp3:mockwebserver:$okhttpVersion" + testImplementation "com.squareup.okhttp3:okhttp:$okhttpVersion" + testImplementation 'org.robolectric:robolectric:3.5' + testImplementation 'org.mockito:mockito-core:2.11.0' + testImplementation "com.android.support:support-annotations:$supportLibrary" - androidTestCompile "com.squareup.okhttp3:mockwebserver:$okhttpVersion" - androidTestCompile("com.jayway.jsonpath:json-path-assert:$jsonPathAssert") { + androidTestImplementation "com.squareup.okhttp3:mockwebserver:$okhttpVersion" + androidTestImplementation("com.jayway.jsonpath:json-path-assert:$jsonPathAssert") { exclude group: "org.ow2.asm" } - androidTestCompile "com.squareup.okhttp3:okhttp:$okhttpVersion" - androidTestCompile "com.android.support.test.espresso:espresso-core:2.2.2" - androidTestCompile "com.android.support.test:runner:0.5" - androidTestCompile 'com.android.support:support-annotations:25.4.0' + androidTestImplementation "com.squareup.okhttp3:okhttp:$okhttpVersion" + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + androidTestImplementation "com.android.support.test:runner:$astl" + androidTestImplementation "com.android.support:support-annotations:$supportLibrary" } diff --git a/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java b/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java index 89c4847..6f12a73 100644 --- a/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java +++ b/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java @@ -5,7 +5,6 @@ import org.junit.runner.RunWith; import br.com.concretesolutions.requestmatcher.InstrumentedTestRequestMatcherRule; -import br.com.concretesolutions.requestmatcher.LocalTestRequestMatcherRule; import br.com.concretesolutions.requestmatcher.RequestMatcherRule; @RunWith(AndroidJUnit4.class) diff --git a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/RequestMatcherRuleTest.java b/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/RequestMatcherRuleTest.java index e4882f1..158c33f 100644 --- a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/RequestMatcherRuleTest.java +++ b/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/RequestMatcherRuleTest.java @@ -410,7 +410,8 @@ public void failsForUnknownJsonPath() throws IOException { exceptionRule.expect(RequestAssertionException.class); exceptionRule.expectMessage( allOf( - containsString("is json with json path \"$..[*]\" and is json with json " + + containsString("is json with json path \"$\" evaluated to " + + "(an instance of java.util.Map or an instance of java.util.List) and is json with json " + "path \"$['unexisting']['path']\" evaluated to is \"value\")"), containsString(RequestMatchersGroup.JSON_MSG) )); diff --git a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/IOReaderTest.java b/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/IOReaderTest.java index 375fc49..208d183 100644 --- a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/IOReaderTest.java +++ b/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/IOReaderTest.java @@ -1,9 +1,6 @@ package br.com.concretesolutions.requestmatcher; import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; diff --git a/tools/linters.gradle b/tools/linters.gradle index 9ea03d2..0bbb954 100644 --- a/tools/linters.gradle +++ b/tools/linters.gradle @@ -10,6 +10,10 @@ task checkstyle(type: Checkstyle) { classpath = files() } +checkstyle { + toolVersion = '8.3' +} + task pmd(type: Pmd) { ruleSetFiles = files("${rootDir}/tools/linters/pmd-ruleset.xml") ruleSets = [] @@ -26,4 +30,8 @@ task pmd(type: Pmd) { } } +pmd { + toolVersion = '5.8.1' +} + check.dependsOn 'checkstyle', 'pmd' \ No newline at end of file From f128670ae59437acacf97c5d13b3f89da7445d89 Mon Sep 17 00:00:00 2001 From: Rafael Toledo Date: Fri, 27 Oct 2017 17:19:35 -0200 Subject: [PATCH 2/4] Remove unecessary manifest entries and resources folder --- requestmatcher/src/main/AndroidManifest.xml | 14 +------------- requestmatcher/src/main/res/values/strings.xml | 3 --- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 requestmatcher/src/main/res/values/strings.xml diff --git a/requestmatcher/src/main/AndroidManifest.xml b/requestmatcher/src/main/AndroidManifest.xml index 763e824..a27d97f 100644 --- a/requestmatcher/src/main/AndroidManifest.xml +++ b/requestmatcher/src/main/AndroidManifest.xml @@ -1,13 +1 @@ - - - - - - - - - + diff --git a/requestmatcher/src/main/res/values/strings.xml b/requestmatcher/src/main/res/values/strings.xml deleted file mode 100644 index db20f3e..0000000 --- a/requestmatcher/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Request Matcher - From c535c8b2e5e418f035816b2af0f5da685d47f585 Mon Sep 17 00:00:00 2001 From: Rafael Toledo Date: Fri, 27 Oct 2017 17:24:34 -0200 Subject: [PATCH 3/4] Rename package to br.com.concrete.requestmatcher --- .../test/InstrumentedExceptionInStatementTest.java | 6 +++--- .../InstrumentedExceptionWitouhtEnqueuesTest.java | 6 +++--- .../test/InstrumentedRequestMatcherRuleTest.java | 6 +++--- requestmatcher/src/main/AndroidManifest.xml | 2 +- .../requestmatcher/IOReader.java | 2 +- .../InstrumentedTestRequestMatcherRule.java | 2 +- .../LocalTestRequestMatcherRule.java | 2 +- .../requestmatcher/MatcherDispatcher.java | 6 +++--- .../requestmatcher/RequestMatcherRule.java | 4 ++-- .../requestmatcher/RequestMatchersGroup.java | 6 +++--- .../requestmatcher/RequestUtils.java | 2 +- .../exception/NoMatchersForRequestException.java | 4 ++-- .../requestmatcher/exception/OrderException.java | 2 +- .../exception/RequestAssertionException.java | 2 +- .../requestmatcher/matchers/IsMapWithSize.java | 2 +- .../requestmatcher/model/HttpMethod.java | 2 +- .../com/concrete/requestmatcher/test/BaseTest.java | 9 +++++++++ .../test/ExceptionInStatementTest.java | 10 +++++----- .../test/ExceptionWitouhtEnqueuesTest.java | 4 ++-- .../test/RequestMatcherRuleTest.java | 10 +++++----- .../requestmatcher/test/BaseTest.java | 9 --------- .../requestmatcher/IOReaderTest.java | 2 +- .../test/CustomRequestMatcherTest.java | 14 +++++++------- .../test/LocalExceptionInStatementTest.java | 6 +++--- .../test/LocalExceptionWitouhtEnqueuesTest.java | 6 +++--- .../test/LocalRequestMatcherRuleTest.java | 6 +++--- 26 files changed, 66 insertions(+), 66 deletions(-) rename requestmatcher/src/androidTest/java/br/com/{concretesolutions => concrete}/requestmatcher/test/InstrumentedExceptionInStatementTest.java (62%) rename requestmatcher/src/androidTest/java/br/com/{concretesolutions => concrete}/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java (63%) rename requestmatcher/src/androidTest/java/br/com/{concretesolutions => concrete}/requestmatcher/test/InstrumentedRequestMatcherRuleTest.java (62%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/IOReader.java (98%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/InstrumentedTestRequestMatcherRule.java (97%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/LocalTestRequestMatcherRule.java (97%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/MatcherDispatcher.java (94%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/RequestMatcherRule.java (98%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/RequestMatchersGroup.java (97%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/RequestUtils.java (97%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/exception/NoMatchersForRequestException.java (94%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/exception/OrderException.java (85%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/exception/RequestAssertionException.java (77%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/matchers/IsMapWithSize.java (97%) rename requestmatcher/src/main/java/br/com/{concretesolutions => concrete}/requestmatcher/model/HttpMethod.java (90%) create mode 100644 requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/BaseTest.java rename requestmatcher/src/test-common/java/br/com/{concretesolutions => concrete}/requestmatcher/test/ExceptionInStatementTest.java (91%) rename requestmatcher/src/test-common/java/br/com/{concretesolutions => concrete}/requestmatcher/test/ExceptionWitouhtEnqueuesTest.java (87%) rename requestmatcher/src/test-common/java/br/com/{concretesolutions => concrete}/requestmatcher/test/RequestMatcherRuleTest.java (98%) delete mode 100644 requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/BaseTest.java rename requestmatcher/src/test/java/br/com/{concretesolutions => concrete}/requestmatcher/IOReaderTest.java (95%) rename requestmatcher/src/test/java/br/com/{concretesolutions => concrete}/requestmatcher/test/CustomRequestMatcherTest.java (88%) rename requestmatcher/src/test/java/br/com/{concretesolutions => concrete}/requestmatcher/test/LocalExceptionInStatementTest.java (61%) rename requestmatcher/src/test/java/br/com/{concretesolutions => concrete}/requestmatcher/test/LocalExceptionWitouhtEnqueuesTest.java (53%) rename requestmatcher/src/test/java/br/com/{concretesolutions => concrete}/requestmatcher/test/LocalRequestMatcherRuleTest.java (52%) diff --git a/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionInStatementTest.java b/requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedExceptionInStatementTest.java similarity index 62% rename from requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionInStatementTest.java rename to requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedExceptionInStatementTest.java index b4b6c3e..e353129 100644 --- a/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionInStatementTest.java +++ b/requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedExceptionInStatementTest.java @@ -1,11 +1,11 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; import android.support.test.runner.AndroidJUnit4; import org.junit.runner.RunWith; -import br.com.concretesolutions.requestmatcher.InstrumentedTestRequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.InstrumentedTestRequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatcherRule; @RunWith(AndroidJUnit4.class) public class InstrumentedExceptionInStatementTest extends ExceptionInStatementTest { diff --git a/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java b/requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java similarity index 63% rename from requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java rename to requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java index 6f12a73..b469340 100644 --- a/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java +++ b/requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedExceptionWitouhtEnqueuesTest.java @@ -1,11 +1,11 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; import android.support.test.runner.AndroidJUnit4; import org.junit.runner.RunWith; -import br.com.concretesolutions.requestmatcher.InstrumentedTestRequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.InstrumentedTestRequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatcherRule; @RunWith(AndroidJUnit4.class) public class InstrumentedExceptionWitouhtEnqueuesTest extends ExceptionWitouhtEnqueuesTest { diff --git a/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedRequestMatcherRuleTest.java b/requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedRequestMatcherRuleTest.java similarity index 62% rename from requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedRequestMatcherRuleTest.java rename to requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedRequestMatcherRuleTest.java index 936f3f7..1ec5efe 100644 --- a/requestmatcher/src/androidTest/java/br/com/concretesolutions/requestmatcher/test/InstrumentedRequestMatcherRuleTest.java +++ b/requestmatcher/src/androidTest/java/br/com/concrete/requestmatcher/test/InstrumentedRequestMatcherRuleTest.java @@ -1,11 +1,11 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; import android.support.test.runner.AndroidJUnit4; import org.junit.runner.RunWith; -import br.com.concretesolutions.requestmatcher.InstrumentedTestRequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.InstrumentedTestRequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatcherRule; @RunWith(AndroidJUnit4.class) public class InstrumentedRequestMatcherRuleTest extends RequestMatcherRuleTest { diff --git a/requestmatcher/src/main/AndroidManifest.xml b/requestmatcher/src/main/AndroidManifest.xml index a27d97f..988bacb 100644 --- a/requestmatcher/src/main/AndroidManifest.xml +++ b/requestmatcher/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/IOReader.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/IOReader.java similarity index 98% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/IOReader.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/IOReader.java index e592d10..1b78918 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/IOReader.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/IOReader.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher; +package br.com.concrete.requestmatcher; import android.util.Log; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/InstrumentedTestRequestMatcherRule.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/InstrumentedTestRequestMatcherRule.java similarity index 97% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/InstrumentedTestRequestMatcherRule.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/InstrumentedTestRequestMatcherRule.java index 1142e11..9ceb1f5 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/InstrumentedTestRequestMatcherRule.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/InstrumentedTestRequestMatcherRule.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher; +package br.com.concrete.requestmatcher; import android.support.test.InstrumentationRegistry; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/LocalTestRequestMatcherRule.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/LocalTestRequestMatcherRule.java similarity index 97% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/LocalTestRequestMatcherRule.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/LocalTestRequestMatcherRule.java index 7c25499..0667276 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/LocalTestRequestMatcherRule.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/LocalTestRequestMatcherRule.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher; +package br.com.concrete.requestmatcher; import java.io.IOException; import java.io.InputStream; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/MatcherDispatcher.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/MatcherDispatcher.java similarity index 94% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/MatcherDispatcher.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/MatcherDispatcher.java index 458d0fc..a72e673 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/MatcherDispatcher.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/MatcherDispatcher.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher; +package br.com.concrete.requestmatcher; import java.util.Collections; import java.util.Set; @@ -7,8 +7,8 @@ import java.util.logging.Level; import java.util.logging.Logger; -import br.com.concretesolutions.requestmatcher.exception.NoMatchersForRequestException; -import br.com.concretesolutions.requestmatcher.exception.RequestAssertionException; +import br.com.concrete.requestmatcher.exception.NoMatchersForRequestException; +import br.com.concrete.requestmatcher.exception.RequestAssertionException; import okhttp3.mockwebserver.Dispatcher; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.RecordedRequest; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestMatcherRule.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatcherRule.java similarity index 98% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestMatcherRule.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatcherRule.java index ef0be8a..ce8b036 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestMatcherRule.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatcherRule.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher; +package br.com.concrete.requestmatcher; import org.junit.rules.TestRule; import org.junit.runner.Description; @@ -11,7 +11,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import br.com.concretesolutions.requestmatcher.exception.RequestAssertionException; +import br.com.concrete.requestmatcher.exception.RequestAssertionException; import okhttp3.HttpUrl; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestMatchersGroup.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatchersGroup.java similarity index 97% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestMatchersGroup.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatchersGroup.java index ea68e89..71d6d8c 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestMatchersGroup.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatchersGroup.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher; +package br.com.concrete.requestmatcher; import android.support.annotation.NonNull; @@ -7,10 +7,10 @@ import java.util.HashMap; import java.util.Map; -import br.com.concretesolutions.requestmatcher.model.HttpMethod; +import br.com.concrete.requestmatcher.model.HttpMethod; import okhttp3.mockwebserver.RecordedRequest; -import static br.com.concretesolutions.requestmatcher.matchers.IsMapWithSize.anEmptyMap; +import static br.com.concrete.requestmatcher.matchers.IsMapWithSize.anEmptyMap; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasEntry; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestUtils.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestUtils.java similarity index 97% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestUtils.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestUtils.java index fdb7fbf..af03392 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/RequestUtils.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestUtils.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher; +package br.com.concrete.requestmatcher; import java.util.HashMap; import java.util.List; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/NoMatchersForRequestException.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/NoMatchersForRequestException.java similarity index 94% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/NoMatchersForRequestException.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/NoMatchersForRequestException.java index c18637d..e9d4a8c 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/NoMatchersForRequestException.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/NoMatchersForRequestException.java @@ -1,6 +1,6 @@ -package br.com.concretesolutions.requestmatcher.exception; +package br.com.concrete.requestmatcher.exception; -import br.com.concretesolutions.requestmatcher.RequestMatchersGroup; +import br.com.concrete.requestmatcher.RequestMatchersGroup; import okhttp3.Headers; import okhttp3.mockwebserver.RecordedRequest; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/OrderException.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/OrderException.java similarity index 85% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/OrderException.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/OrderException.java index 465ad73..c6398db 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/OrderException.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/OrderException.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher.exception; +package br.com.concrete.requestmatcher.exception; import java.util.Locale; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/RequestAssertionException.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/RequestAssertionException.java similarity index 77% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/RequestAssertionException.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/RequestAssertionException.java index 532ca7d..712f674 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/exception/RequestAssertionException.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/exception/RequestAssertionException.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher.exception; +package br.com.concrete.requestmatcher.exception; public final class RequestAssertionException extends RuntimeException { diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/matchers/IsMapWithSize.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/matchers/IsMapWithSize.java similarity index 97% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/matchers/IsMapWithSize.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/matchers/IsMapWithSize.java index 9801009..9e595fa 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/matchers/IsMapWithSize.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/matchers/IsMapWithSize.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher.matchers; +package br.com.concrete.requestmatcher.matchers; import org.hamcrest.FeatureMatcher; diff --git a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/model/HttpMethod.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/model/HttpMethod.java similarity index 90% rename from requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/model/HttpMethod.java rename to requestmatcher/src/main/java/br/com/concrete/requestmatcher/model/HttpMethod.java index ed47b21..e8889da 100644 --- a/requestmatcher/src/main/java/br/com/concretesolutions/requestmatcher/model/HttpMethod.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/model/HttpMethod.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher.model; +package br.com.concrete.requestmatcher.model; import okhttp3.mockwebserver.RecordedRequest; diff --git a/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/BaseTest.java b/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/BaseTest.java new file mode 100644 index 0000000..d23368c --- /dev/null +++ b/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/BaseTest.java @@ -0,0 +1,9 @@ +package br.com.concrete.requestmatcher.test; + + +import br.com.concrete.requestmatcher.RequestMatcherRule; + +public abstract class BaseTest { + + protected abstract RequestMatcherRule getRequestMatcherRule(); +} diff --git a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/ExceptionInStatementTest.java b/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/ExceptionInStatementTest.java similarity index 91% rename from requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/ExceptionInStatementTest.java rename to requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/ExceptionInStatementTest.java index fc3580f..bae04b8 100644 --- a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/ExceptionInStatementTest.java +++ b/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/ExceptionInStatementTest.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; import org.junit.Before; import org.junit.Rule; @@ -10,10 +10,10 @@ import java.io.IOException; import java.util.concurrent.TimeUnit; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatchersGroup; -import br.com.concretesolutions.requestmatcher.exception.RequestAssertionException; -import br.com.concretesolutions.requestmatcher.model.HttpMethod; +import br.com.concrete.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatchersGroup; +import br.com.concrete.requestmatcher.exception.RequestAssertionException; +import br.com.concrete.requestmatcher.model.HttpMethod; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; diff --git a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/ExceptionWitouhtEnqueuesTest.java b/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/ExceptionWitouhtEnqueuesTest.java similarity index 87% rename from requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/ExceptionWitouhtEnqueuesTest.java rename to requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/ExceptionWitouhtEnqueuesTest.java index c2866de..a5c8dfb 100644 --- a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/ExceptionWitouhtEnqueuesTest.java +++ b/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/ExceptionWitouhtEnqueuesTest.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; import org.junit.Rule; import org.junit.Test; @@ -8,7 +8,7 @@ import java.io.IOException; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatcherRule; public abstract class ExceptionWitouhtEnqueuesTest extends BaseTest { diff --git a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/RequestMatcherRuleTest.java b/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/RequestMatcherRuleTest.java similarity index 98% rename from requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/RequestMatcherRuleTest.java rename to requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/RequestMatcherRuleTest.java index 158c33f..11526d1 100644 --- a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/RequestMatcherRuleTest.java +++ b/requestmatcher/src/test-common/java/br/com/concrete/requestmatcher/test/RequestMatcherRuleTest.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; import org.junit.Before; import org.junit.Rule; @@ -10,10 +10,10 @@ import java.io.IOException; import java.util.concurrent.TimeUnit; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatchersGroup; -import br.com.concretesolutions.requestmatcher.exception.RequestAssertionException; -import br.com.concretesolutions.requestmatcher.model.HttpMethod; +import br.com.concrete.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatchersGroup; +import br.com.concrete.requestmatcher.exception.RequestAssertionException; +import br.com.concrete.requestmatcher.model.HttpMethod; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; diff --git a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/BaseTest.java b/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/BaseTest.java deleted file mode 100644 index 85b9196..0000000 --- a/requestmatcher/src/test-common/java/br/com/concretesolutions/requestmatcher/test/BaseTest.java +++ /dev/null @@ -1,9 +0,0 @@ -package br.com.concretesolutions.requestmatcher.test; - - -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; - -public abstract class BaseTest { - - protected abstract RequestMatcherRule getRequestMatcherRule(); -} diff --git a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/IOReaderTest.java b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/IOReaderTest.java similarity index 95% rename from requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/IOReaderTest.java rename to requestmatcher/src/test/java/br/com/concrete/requestmatcher/IOReaderTest.java index 208d183..c595f93 100644 --- a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/IOReaderTest.java +++ b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/IOReaderTest.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher; +package br.com.concrete.requestmatcher; import org.junit.Test; diff --git a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/CustomRequestMatcherTest.java b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/CustomRequestMatcherTest.java similarity index 88% rename from requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/CustomRequestMatcherTest.java rename to requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/CustomRequestMatcherTest.java index f0dd219..55ce7c5 100644 --- a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/CustomRequestMatcherTest.java +++ b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/CustomRequestMatcherTest.java @@ -1,4 +1,4 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; import android.support.annotation.NonNull; @@ -17,12 +17,12 @@ import java.net.Socket; import java.util.concurrent.TimeUnit; -import br.com.concretesolutions.requestmatcher.BuildConfig; -import br.com.concretesolutions.requestmatcher.LocalTestRequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatchersGroup; -import br.com.concretesolutions.requestmatcher.exception.NoMatchersForRequestException; -import br.com.concretesolutions.requestmatcher.exception.RequestAssertionException; +import br.com.concrete.requestmatcher.BuildConfig; +import br.com.concrete.requestmatcher.LocalTestRequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatchersGroup; +import br.com.concrete.requestmatcher.exception.NoMatchersForRequestException; +import br.com.concrete.requestmatcher.exception.RequestAssertionException; import okhttp3.Headers; import okhttp3.MediaType; import okhttp3.OkHttpClient; diff --git a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalExceptionInStatementTest.java b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalExceptionInStatementTest.java similarity index 61% rename from requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalExceptionInStatementTest.java rename to requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalExceptionInStatementTest.java index 370919f..2110462 100644 --- a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalExceptionInStatementTest.java +++ b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalExceptionInStatementTest.java @@ -1,7 +1,7 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; -import br.com.concretesolutions.requestmatcher.LocalTestRequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.LocalTestRequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatcherRule; //@RunWith(RobolectricTestRunner.class) //@Config(constants = BuildConfig.class, sdk = 23) diff --git a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalExceptionWitouhtEnqueuesTest.java b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalExceptionWitouhtEnqueuesTest.java similarity index 53% rename from requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalExceptionWitouhtEnqueuesTest.java rename to requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalExceptionWitouhtEnqueuesTest.java index fd9e1dc..f852467 100644 --- a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalExceptionWitouhtEnqueuesTest.java +++ b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalExceptionWitouhtEnqueuesTest.java @@ -1,7 +1,7 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; -import br.com.concretesolutions.requestmatcher.LocalTestRequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.LocalTestRequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatcherRule; public class LocalExceptionWitouhtEnqueuesTest extends ExceptionWitouhtEnqueuesTest { diff --git a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalRequestMatcherRuleTest.java b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalRequestMatcherRuleTest.java similarity index 52% rename from requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalRequestMatcherRuleTest.java rename to requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalRequestMatcherRuleTest.java index 801e818..36e395b 100644 --- a/requestmatcher/src/test/java/br/com/concretesolutions/requestmatcher/test/LocalRequestMatcherRuleTest.java +++ b/requestmatcher/src/test/java/br/com/concrete/requestmatcher/test/LocalRequestMatcherRuleTest.java @@ -1,7 +1,7 @@ -package br.com.concretesolutions.requestmatcher.test; +package br.com.concrete.requestmatcher.test; -import br.com.concretesolutions.requestmatcher.LocalTestRequestMatcherRule; -import br.com.concretesolutions.requestmatcher.RequestMatcherRule; +import br.com.concrete.requestmatcher.LocalTestRequestMatcherRule; +import br.com.concrete.requestmatcher.RequestMatcherRule; public class LocalRequestMatcherRuleTest extends RequestMatcherRuleTest { From 8fc6033fc96200e41fc4cec95021437a52e8a0f5 Mon Sep 17 00:00:00 2001 From: Rafael Toledo Date: Fri, 27 Oct 2017 17:41:38 -0200 Subject: [PATCH 4/4] Add dynamic values when adding fixes --- .../requestmatcher/RequestMatcherRule.java | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatcherRule.java b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatcherRule.java index ce8b036..e9d38e8 100644 --- a/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatcherRule.java +++ b/requestmatcher/src/main/java/br/com/concrete/requestmatcher/RequestMatcherRule.java @@ -172,10 +172,11 @@ public IfRequestMatches addResponse(MockResponse response) * Adds a fixture to be used during the test case. * * @param fixturePath The path of the fixture inside the fixtures folder. + * @param values Optional dynamic values to be replaced in the fixture file * @return A dsl instance {@link IfRequestMatches} for chaining */ - public IfRequestMatches addFixture(String fixturePath) { - return addFixture(200, fixturePath); + public IfRequestMatches addFixture(String fixturePath, String... values) { + return addFixture(200, fixturePath, values); } /** @@ -183,13 +184,12 @@ public IfRequestMatches addFixture(String fixturePath) { * * @param fixturePath The path of the fixture inside the fixtures folder. * @param statusCode The status of the mocked response. + * @param values Optional dynamic values to be replaced in the fixture file * @return A dsl instance {@link IfRequestMatches} for chaining */ - public IfRequestMatches addFixture(int statusCode, String fixturePath) { + public IfRequestMatches addFixture(int statusCode, String fixturePath, String... values) { - final MockResponse mockResponse = new MockResponse() - .setResponseCode(statusCode) - .setBody(readFixture(fixturePath)); + final MockResponse mockResponse = createMockResponse(statusCode, fixturePath, values); if (guessMimeType) { final String mimeType = IOReader.mimeTypeFromExtension(fixturePath); @@ -213,13 +213,15 @@ public IfRequestMatches addFixture(int statusCode, String * * @param fixturePath The path of the fixture inside the fixtures fodler. * @param matcher The {@link RequestMatchersGroup} instance to use for matching. + * @param values Optional dynamic values to be replaced in the fixture file * @return A dsl instance {@link IfRequestMatches} for chaining */ public IfRequestMatches addFixture(String fixturePath, - T matcher) { + T matcher, + String... values) { return addResponse(new MockResponse() .setResponseCode(200) - .setBody(readFixture(fixturePath)), matcher); + .setBody(replaceAndValidate(readFixture(fixturePath), values)), matcher); } /** @@ -228,14 +230,38 @@ public IfRequestMatches addFixture(String fi * @param statusCode The status of the mocked response. * @param fixturePath The path of the fixture inside the fixtures fodler. * @param matcher The {@link RequestMatchersGroup} instance to use for matching. + * @param values Optional dynamic values to be replaced in the fixture file * @return A dsl instance {@link IfRequestMatches} for chaining */ public IfRequestMatches addFixture(int statusCode, String fixturePath, - T matcher) { + T matcher, + String... values) { return addResponse(new MockResponse() .setResponseCode(statusCode) - .setBody(readFixture(fixturePath)), matcher); + .setBody(replaceAndValidate(readFixture(fixturePath), values)), matcher); + } + + private MockResponse createMockResponse(int statusCode, String fixturePath, String... values) { + return new MockResponse() + .setResponseCode(statusCode) + .setBody(replaceAndValidate(readFixture(fixturePath), values)); + } + + private String replaceAndValidate(String fixture, String[] values) { + if (values == null) { + return fixture; + } + + for (int i = 0; i < values.length; i++) { + if (!fixture.contains("{" + i + "}")) { + fail("Could not replace dynamic value at position " + i); + } + + fixture = fixture.replace("{" + i + "}", values[i]); + } + + return fixture; } /**