-
Notifications
You must be signed in to change notification settings - Fork 282
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
ELY-2641 : Simplify assersions in MaskCommandTest#testMissingSaltAnd iteration method #1961
ELY-2641 : Simplify assersions in MaskCommandTest#testMissingSaltAnd iteration method #1961
Conversation
Thank you @nidhiazad for the PR! |
@PrarthonaPaul I think the issue only involves changing statements in |
Awesome, thank you @SoniaZaldana |
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 good to me!
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.
thanks for your contribution @nidhiazad
assertTrue("Message about invalid iteration parameter must be present", ("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.").equals(retValLines[1])); | ||
assertTrue("Message about invalid salt parameter must be present", retValLines[2].contains("MASK-")); | ||
assertEquals("Message about invalid salt parameter must be present", true, retValLines[0].contains("Invalid \"salt\" parameter. Generated value")); | ||
assertEquals("Message about invalid iteration parameter must be present", true, ("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.").equals(retValLines[1])); |
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.
this statement is passing true
as the expected value and then passes this line:("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.").equals(retValLines[1])
as the actual value to the assertEquals
function to confirm that they are equal. we can simplify this by just passing ("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.")
as the expected value and retValLines[1]
as the actual value to the assertEquals
function and the function will compare to check if the 2 strings are equal.
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.
okay, thanks. Fixing this.
assertTrue("Message about invalid salt parameter must be present", retValLines[2].contains("MASK-")); | ||
assertEquals("Message about invalid salt parameter must be present", true, retValLines[0].contains("Invalid \"salt\" parameter. Generated value")); | ||
assertEquals("Message about invalid iteration parameter must be present", true, ("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.").equals(retValLines[1])); | ||
assertEquals("Message about invalid salt parameter must be present",true, retValLines[2].contains("MASK-")); |
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.
same as above, i think we can keep the original statement that asserts retValLines[2].contains("MASK-")
is true, rather than asserting that statement is equal to true
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.
thanks @nidhiazad. rather than using assertEquals
for all 3 statements, i think the first and last statement can be kept with assertTrue, instead of asserting that retValLines[2].contains("MASK-")
is true
assertEquals("Message about invalid salt parameter must be present",true, retValLines[2].contains("MASK-")); | |
assertTrue("Message about invalid salt parameter must be present", retValLines[2].contains("MASK-")); |
assertTrue("Message about invalid salt parameter must be present", retValLines[0].contains("Invalid \"salt\" parameter. Generated value")); | ||
assertTrue("Message about invalid iteration parameter must be present", ("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.").equals(retValLines[1])); | ||
assertTrue("Message about invalid salt parameter must be present", retValLines[2].contains("MASK-")); | ||
assertEquals("Message about invalid salt parameter must be present", true, retValLines[0].contains("Invalid \"salt\" parameter. Generated value")); |
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 think we can keep the original statement that asserts retValLines[0].contains("Invalid \"salt\" parameter. Generated value")
is true, rather than asserting that statement is equal to true
updated the code. Please review and let me know if anything needs to be done. |
assertTrue("Message about invalid salt parameter must be present", retValLines[0].contains("Invalid \"salt\" parameter. Generated value")); | ||
assertTrue("Message about invalid iteration parameter must be present", ("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.").equals(retValLines[1])); | ||
assertTrue("Message about invalid salt parameter must be present", retValLines[2].contains("MASK-")); | ||
assertEquals("Invalid \"salt\" parameter. Generated value", retValLines[0]); |
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.
for this case, we want to keep the original statement that retValLines[0]
contains the string "Invalid \"salt\" parameter. Generated value"
but it is not equal to it
assertTrue("Message about invalid iteration parameter must be present", ("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.").equals(retValLines[1])); | ||
assertTrue("Message about invalid salt parameter must be present", retValLines[2].contains("MASK-")); | ||
assertEquals("Invalid \"salt\" parameter. Generated value", retValLines[0]); | ||
assertEquals("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.",retValLines[1]); |
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.
for all 3 statements, we can keep the original messages that indicaet why this assertion should pass:
assertEquals("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.",retValLines[1]); | |
assertEquals("Message about invalid salt parameter must be present", "Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.",retValLines[1]); |
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.
@ashley-abdelsayed98 I am passing message,expected,actual in the assertEquals method for all the three statements now. This is how it needs to be done. Sorry about the previous commits. Hope so this one is correct. Please let me know if any alteration is required.
That's right! This
Yes this test is specifically for the method |
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.
thanks for the changes @nidhiazad !
assertTrue("Message about invalid salt parameter must be present", retValLines[0].contains("Invalid \"salt\" parameter. Generated value")); | ||
assertTrue("Message about invalid iteration parameter must be present", ("Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.").equals(retValLines[1])); | ||
assertTrue("Message about invalid salt parameter must be present", retValLines[2].contains("MASK-")); | ||
assertEquals("Message about invalid salt parameter must be present","Invalid \"salt\" parameter. Generated value", retValLines[0]); |
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 think this test will still fail because retValLines[0]
does not equal "Invalid \"salt\" parameter. Generated value"
, but rather it just contains it as a substring
assertTrue("Message about invalid salt parameter must be present", retValLines[2].contains("MASK-")); | ||
assertEquals("Message about invalid salt parameter must be present","Invalid \"salt\" parameter. Generated value", retValLines[0]); | ||
assertEquals("Message about invalid iteration parameter must be present","Invalid \"iteration\" parameter. Default value \"" + defaultIteration + "\" will be used.",retValLines[1]); | ||
assertEquals("Message about invalid salt parameter must be present","MASK-",retValLines[2]); |
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.
same as above, i think this test will fail because retValLines[2]
does not equal "MASK-"
, but rather it just contains it as a substring
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 have submitted the new changes and verified by running mvn clean install -Dtest=MaskCommandTest. The test is passing now.
@nidhiazad Just a minor, in the You can try to run the project with |
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.
Hi @nidhiazad, thanks for the changes. They look good!
Could you please squash your commits? Let me know if you need any help with that.
@nidhiazad The changes look great now! It just need squashing of the commits into a single commit. If you need any help, please let us know |
3d0d312
to
b9bf6dc
Compare
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, thank you @nidhiazad!
@nidhiazad Thank you! |
https://issues.redhat.com/browse/ELY-2641
Simplify assersions in MaskCommandTest#testMissingSaltAndIteration method