Skip to content
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.

Fixes AwsHttpHeadersTestCase #187

Merged
merged 4 commits into from
Jan 25, 2017
Merged

Fixes AwsHttpHeadersTestCase #187

merged 4 commits into from
Jan 25, 2017

Conversation

SherifWaly
Copy link
Contributor

@SherifWaly SherifWaly commented Jan 23, 2017

This PR is for #177

@coveralls
Copy link

coveralls commented Jan 23, 2017

Coverage Status

Coverage remained the same at 84.203% when pulling 222380f on SherifWaly:#177 into 9a02a62 on opencharles:master.

Copy link
Member

@amihaiemil amihaiemil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly It looks very nice. I have only
2 comments about the code :)

public void performsRequest() throws IOException {
Map<String, String> headers = new HashMap<String, String>();
public void addsHeaders() throws IOException {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-type", "json");
headers.put("HeaderName", "HeaderValue");
AwsHttpHeaders<String> awsh = new AwsHttpHeaders<>(
new AwsHttpRequest.FakeAwsHttpRequest(), headers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly This unit test is good, but it misses a case: the one where the original request already has some headers. We should check that AwsHttpHeaders adds, but does not replace.

So, the original request here should have a header already.
You can do it like this:

        AwsHttpRequest<String> fake = new AwsHttpRequest.FakeAwsHttpRequest();
        fake.request().addHeader("previously-here", "value");
        AwsHttpHeaders<String> awsh = new AwsHttpHeaders<>(fake, headers);

and modify the asserts: received.size() should be 3, not 2, plus add an assert for the previous header, to see that it's still there.

new AwsHttpRequest.FakeAwsHttpRequest(),
new HashMap<String, String>()
);
assertTrue(awsh.perform().equals("performed fake request"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SherifWaly As you see in this issue, we want to start using hamcrest matchers instead of simple asserts (see there the explanation).

Can you change the asserts to matcher asserts? It's not hard at all and the gain is big. See this test class for examples.

Any questions, please ask.

@amihaiemil
Copy link
Member

@SherifWaly Can you please modify the PR's title and description? The title should briefly say what the changes are (e.g. Fixes AwsHttpHeadersTestCase) and in the description you should link the issue that the PR is solving (e.g. "This PR is for #177").

This is because we want traceability of changes. It's one of the reasons we make the changes on opened issues and separate branches, but if we don't link them to each other, they will eventually get lost and nobody will know what's with them :D

@SherifWaly SherifWaly changed the title #177 Fixes AwsHttpHeadersTestCase Jan 24, 2017
@coveralls
Copy link

coveralls commented Jan 24, 2017

Coverage Status

Coverage remained the same at 84.203% when pulling 5b51bbb on SherifWaly:#177 into 9a02a62 on opencharles:master.

@coveralls
Copy link

coveralls commented Jan 24, 2017

Coverage Status

Coverage remained the same at 84.203% when pulling 29c2a72 on SherifWaly:#177 into 9a02a62 on opencharles:master.

@SherifWaly
Copy link
Contributor Author

@amihaiemil Please review the last commit after adding an extra check and using hamcrest matchers for testing :)

@amihaiemil
Copy link
Member

@SherifWaly looks good :)

@amihaiemil
Copy link
Member

@rultor merge pls

@rultor
Copy link
Contributor

rultor commented Jan 25, 2017

@rultor merge pls

@amihaiemil OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 29c2a72 into opencharles:master Jan 25, 2017
@rultor
Copy link
Contributor

rultor commented Jan 25, 2017

@rultor merge pls

@amihaiemil Done! FYI, the full log is here (took me 1min)

@SherifWaly SherifWaly deleted the #177 branch January 25, 2017 13:36
@SherifWaly SherifWaly restored the #177 branch January 25, 2017 15:36
@SherifWaly SherifWaly deleted the #177 branch January 25, 2017 16:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants