BAEL-6848: Set a Parameter in a HttpServletRequest in Java#14700
BAEL-6848: Set a Parameter in a HttpServletRequest in Java#14700theangrydev merged 1 commit intoeugenp:masterfrom
Conversation
...servlets-2/src/test/java/com/baeldung/setparam/SanitizeParametersRequestWrapperUnitTest.java
Outdated
Show resolved
Hide resolved
...javax-servlets-2/src/test/java/com/baeldung/setparam/SetParameterRequestWrapperUnitTest.java
Outdated
Show resolved
Hide resolved
| firstCallValues[0] = NEW_VALUE; | ||
| String[] secondCallValues = wrapper.getParameterValues("input"); | ||
| assertNotEquals(firstCallValues, secondCallValues); | ||
| assertThat(firstCallValues).isNotEqualTo(secondCallValues); |
There was a problem hiding this comment.
I believe @KevinGilmore might have been trying to suggest you to do something like this:
| assertThat(firstCallValues).isNotEqualTo(secondCallValues); | |
| assertThat(secondCallValues).doesNotContain(NEW_VALUE); |
There was a problem hiding this comment.
isNotEqualTo is correct.
We are asserting whether the 2nd call of getParaemterValues() is not equal to the modified value from the 1st call.
There was a problem hiding this comment.
I understand that isNotEqualTo correctly asserts that the 2nd call is not equal to the modified value from the 1st call
However, this is not really using any of the power of AssertJ to make the intention of the assertion clearer, which is what I think Kevin was trying to get you to take a look at
Logically, you are modifying with NEW_VALUE and then you want to assert that this change was not effective
By explicitly checking for NEW_VALUE being absent, the intention of the assertion is clearer
There was a problem hiding this comment.
Assertion updated
| firstCallValues[0] = NEW_VALUE; | ||
| String[] secondCallValues = wrapper.getParameterValues("input"); | ||
| assertNotEquals(firstCallValues, secondCallValues); | ||
| assertThat(firstCallValues).isNotEqualTo(secondCallValues); |
There was a problem hiding this comment.
I believe @KevinGilmore might have been trying to suggest you to do something like this:
| assertThat(firstCallValues).isNotEqualTo(secondCallValues); | |
| assertThat(secondCallValues).doesNotContain(NEW_VALUE); |
There was a problem hiding this comment.
isNotEqualTo is correct.
We are asserting whether the 2nd call of getParaemterValues() is not equal to the modified value from the 1st call.
There was a problem hiding this comment.
Assertion updated
6aaf11d to
3405dd5
Compare
3405dd5 to
07e0abf
Compare
Fix tests in BAEL-6848