-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock: manage headers using RequestHeaders #706
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started reviewing it, but the format changes make it hard to me to see the full scope of the changes, could you please run mvn clean install
to reformat this PR?
@@ -42,7 +41,7 @@ private Builder(HttpMethod method, String url) { | |||
this.url = url; | |||
} | |||
|
|||
public Builder headers(Map<String, Collection<String>> headers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please keep the original headers with @Deprecated
?
|
||
@RequestLine("PATCH /repos/{owner}/{repo}/contributors") | ||
List<Contributor> patchContributors(@Param("owner") String owner, @Param("repo") String repo); | ||
|
||
@RequestLine("POST /repos/{owner}/{repo}/contributors") | ||
@Body("%7B\"login\":\"{login}\",\"type\":\"{type}\"%7D") | ||
Contributor create(@Param("owner") String owner, | ||
@Param("repo") String repo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you changed the formatting for many classes.... could you please rollback?
running mvn clean install
should do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, of course. I'll plug the eclipse formatter plugin to my IDE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I just would like to see this remaining format and java 6 changes reverted.
Ping me when ready to merge
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.Matchers.startsWith; | ||
import static org.junit.Assert.assertThat; | ||
import java.nio.charset.StandardCharsets; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i'll undo. I've made this to launch test from IntelliJ directly, because test and source don't get the same language level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, master is now java 8 =)
@@ -238,7 +236,8 @@ public Request verifyOne(HttpMethod method, String url) { | |||
|
|||
List<Request> result = requests.get(requestKey); | |||
if (result.size() != times) { | |||
throw new VerificationAssertionError("Wanted: '%s' to be invoked: '%s' times but got: '%s'!", | |||
throw new VerificationAssertionError( | |||
"Wanted: '%s' to be invoked: '%s' times but got: '%s'!", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still see a bunch of No-Op
changes...
Would be nice to reduce the number of thoose
private MockClient mockClient; | ||
|
||
@Before | ||
public void setup() throws IOException { | ||
try (InputStream input = getClass().getResourceAsStream("/fixtures/contributors.json")) { | ||
InputStream input = getClass().getResourceAsStream("/fixtures/contributors.json"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to undo it.
@velo Sounds good to you ? |
Perfect! |
* feat(feign-mock): add RequestHeaders class to manage headers * feat(feign-mock): use google code style formatting * feat(feign-mock): remove system.out * feat(RequestKey): add deprecated headers builder + format code * feat(feign-mock): format pom correctly * feat(feign-mock): format pom correctly * fix(feign-mock): undo some typo and no-op change
* feat(feign-mock): add RequestHeaders class to manage headers * feat(feign-mock): use google code style formatting * feat(feign-mock): remove system.out * feat(RequestKey): add deprecated headers builder + format code * feat(feign-mock): format pom correctly * feat(feign-mock): format pom correctly * fix(feign-mock): undo some typo and no-op change
Add the new class
RequestHeaders
in order to improve management of request headers when testing.So instead of doing this:
we can do :
or
Moreover, when a request do not match, we will now print the expected headers instead of the numbers of headers.
Before:
Expected Request [GET /myrequest: with 2 headers and no charset], but was Request [GET /myrequest: with 0 headers and no charset]
After:
Expected Request [GET /myrequest: with my-header=[val], my-header-2=[val2,val3] headers and no charset], but was Request [GET /myrequest: with no headers and no charset]