-
Notifications
You must be signed in to change notification settings - Fork 195
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
#865 Added RqFromTest and HttpServletRequestFake #941
Conversation
Job #941 is now in scope, role is |
This pull request #941 is assigned to @marceloamadeu/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @paulodamaso/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer; there will be no monetary reward for this job |
Codecov Report
@@ Coverage Diff @@
## master #941 +/- ##
============================================
- Coverage 74.1% 72.29% -1.82%
Complexity 971 971
============================================
Files 222 224 +2
Lines 4785 4905 +120
Branches 361 364 +3
============================================
Hits 3546 3546
- Misses 1089 1209 +120
Partials 150 150
Continue to review full report at Codecov.
|
@marceloamadeu ping |
@marceloamadeu can I help you with anything? |
@marceloamadeu ping |
1 similar comment
@marceloamadeu ping |
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.
@fabriciofx Please take a look at the comment.
) | ||
) | ||
).printBody(), | ||
Matchers.containsString(content) |
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.
@fabriciofx Why use static matcher? I suggest using org.hamcrest.core.StringContains
MatcherAssert.assertThat( | ||
"Can't get the request method", | ||
new HttpServletRequestFake(new RqFake()).getMethod(), | ||
Matchers.equalTo("GET") |
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.
@fabriciofx I also suggest using new IsEqual <> ("GET")
instead of
Matchers.equalTo ("GET")
) | ||
) | ||
).printHead(), | ||
Matchers.startsWith( |
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.
@fabriciofx It is possible to replace org.hamcrest.core.StringStartsWith
?
) | ||
).printHead(), | ||
Matchers.startsWith( | ||
Joiner.on("\r\n").join( |
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.
@fabriciofx Why not use org.cactoos.text.JoinedText
? (Example: https://github.com/yegor256/takes/blob/master/src/test/java/org/takes/tk/TkHtmlTest.java)
@marceloamadeu Please, can you check out again? |
@fabriciofx Tks!!! |
@rultor merge |
@marceloamadeu Thanks for your request. @paulodamaso Please confirm this. |
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.
@fabriciofx Thank for the PR, take a look at the comments please
final String header = names.nextElement(); | ||
head.add( | ||
head.add(new HttpHead(this.sreq).toString()); | ||
final Collection<String> names = Collections.list( |
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.
@fabriciofx Let's use something from cactoos
here, I think that ListOf
should do the trick.
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.
@paulodamaso Unfortunately, ListOf
doesn't work with Enumeration
therefore I must use Collections.list
. Ah, I've opened a issue into cactoos
project to create a new constructor to ListOf
to support Enumeration
but it was denied (because is too old).
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.
@fabriciofx I've seen the issue in cactoos
... Well, as they decided to not support Enumeration
we should let it as is then, thanks.
) | ||
).getHeaders("testheader") | ||
), | ||
Matchers.hasItems("someValue") |
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.
@fabriciofx Avoid using static matchers, use IsCollectionContaining
or something similar here.
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.
@paulodamaso IsCollectionContaining
usage is something like: IsCollectionContaining.hasItems("bla")
. I think just the same, but if you want, I can change 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.
@fabriciofx No, I'm talking about new IsIteratorContaining(Macther)
form, avoiding the static method usage.
public void headerNames() { | ||
MatcherAssert.assertThat( | ||
"Can't get the header names", | ||
Collections.list( |
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.
@fabriciofx Same comment as above
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.
@paulodamaso Same above too. The method returns an Enumeration
and ListOf
doesn't support it.
) | ||
).getHeaderNames() | ||
), | ||
Matchers.hasItems("host", "anyheader", "crazyheader") |
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.
@fabriciofx Same comment about IsCollectionContaining
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.
@fabriciofx Same above.
MatcherAssert.assertThat( | ||
"Can't get the request method", | ||
new HttpServletRequestFake(new RqFake()).getMethod(), | ||
new IsEqual<>("GET") |
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.
@fabriciofx Please use RqMethod.GET
instead of "GET"
here
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.
@paulodamaso Done.
* @since 1.15 | ||
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines) | ||
*/ | ||
@SuppressWarnings("PMD.AvoidDuplicateLiterals") |
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.
@fabriciofx I think that you could create constants for the repeated values in this test and avoid using this supression WDYT?
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.
@paulodamaso Can I use the same constant to all tests? It will works only in this case...
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.
@fabriciofx Or you could use final variables inside your test methods, for example, 'final String get = "GET /a-test"' and final String foo = "foo: bar"
for header()
and use this variables in the test. You don't need to use constants because values are not shared between the tests.
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.
@fabriciofx Take a look at the comments, please. Also, I've noticed that the test methods signatures don't follow what explained in https://www.yegor256.com/2014/04/27/typical-mistakes-in-java-code.html#test-method-names , please fix them
) | ||
).getHeaders("testheader") | ||
), | ||
Matchers.hasItems("someValue") |
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.
@fabriciofx No, I'm talking about new IsIteratorContaining(Macther)
form, avoiding the static method usage.
* @since 1.15 | ||
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines) | ||
*/ | ||
@SuppressWarnings("PMD.AvoidDuplicateLiterals") |
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.
@fabriciofx Or you could use final variables inside your test methods, for example, 'final String get = "GET /a-test"' and final String foo = "foo: bar"
for header()
and use this variables in the test. You don't need to use constants because values are not shared between the tests.
@paulodamaso Done. Please, check it again. And, if it's ok, merge 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.
@fabriciofx Just one more comment, please
import javax.servlet.ServletInputStream; | ||
|
||
/** | ||
* ServletInputStreamOf. |
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.
@fabriciofx Please enrich this javadoc so we can know what this class is about.
@paulodamaso Done. Please, check out. |
@fabriciofx Thanks! |
@rultor merge |
@paulodamaso OK, I'll try to merge now. You can check the progress of the merge here |
@paulodamaso Done! FYI, the full log is here (took me 20min) |
@ypshenychka/z please review this job completed by @marceloamadeu/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed |
Code review was too long (12 days), architects (@paulodamaso) were penalized, see §55 |
The job #941 is now out of scope |
Payment to |
@marceloamadeu According to our QA Rules:
Please correct your code review comments by indicating an addressee in the beginning. |
@ypshenychka Adjusted. |
@ypshenychka ping |
@marceloamadeu thanks |
@0crat quality acceptable |
@ypshenychka The project doesn't have enough funds, can't make a payment |
Order was finished, quality is "acceptable": +15 point(s) just awarded to @marceloamadeu/z |
Quality review completed: +8 point(s) just awarded to @ypshenychka/z |
As per #865. Created:
RqFromTest
HttpServletRequestFake
andServletInputStreamOf
to support itHttpServletResquetFakTest