-
Notifications
You must be signed in to change notification settings - Fork 34
Series sales: add validation to ensure that buyer and seller aren't the same #1007
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
Series sales: add validation to ensure that buyer and seller aren't the same #1007
Conversation
Generated by 🚫 Danger |
//) | ||
@FieldsMismatch( | ||
first = "sellerId", | ||
second ="buyerId" |
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 annotation works.
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.
The reason why it doesn't work for you is that you can't create a participant that is a buyer and a seller at the same time. There 2 possible ways to test it:
- modify manually HTML code of the page to be able to choose Eicca twice
- modify Eicca's properties directly in database (so she will appear in both select boxes)
There was one doubt moment to me else. I did creation of two new users
with the similar names and used them like a buyer and seller . I supposed
that we need to check their names to validate from. In this case the
validator doesn't work. is it correct test case ? And if so, we need to get
the real name of users from DB ( i guess ) and match them.
Or i didn't clear catch the task?
Thanks
|
@KrivenkoAlexander I've updated PR's title and body. Also, you can add [WIP] to the PR's title, it means that "Work In Progress" and it isn't ready for a merge. |
When you said "users" you mean "participants"? Because they're different -- users may login to the site and their information is stored in the "users" table while "participants" aren't real users, they can be "buyers" or "sellers" and their information are stored in the "transaction_participant" table. This task is focused around participants.
Unfortunately, no, we don't care about their names. The one that is only important is their IDs because only IDs are uniquely identifies them. Thank you for the questions! Next time I'll put more information to the task descriptions. |
a7d77af
to
0e50a9b
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.
Yes, that is what I meant! See my comments also.
@@ -33,6 +34,10 @@ | |||
|
|||
@Getter | |||
@Setter | |||
@FieldsMatch( |
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.
Please, use another validator -- @FieldsMismatch
(it also fixes the tests that are broken because you changed the behavior of the @FieldsMatch
validator to the opposite).
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.
yes, mixed up the annotation
@@ -33,6 +34,10 @@ | |||
|
|||
@Getter |
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.
Please, add a comment before this annotation:
// @todo #503 Add integration test to ensure that seller and buyer are different
This "magick" comment will create the next issue for us, so that we won't forget to add integration tests later.
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.
done
@@ -33,6 +34,10 @@ | |||
|
|||
@Getter | |||
@Setter | |||
@FieldsMatch( | |||
first = "sellerId", | |||
second = "buyerId" |
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.
We need to also add non-default message. Example:
mystamps/src/main/java/ru/mystamps/web/feature/account/ActivateAccountForm.java
Lines 33 to 36 in 4741948
@FieldsMismatch( first = "login", second = "password", message = "{password.login.match}", password.login.match = Password and login must be different password.login.match = Пароль и логин не должны совпадать
In this case, the message will be
seller.buyer.match = Seller and buyer must be different
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.
done
0e50a9b
to
18331c1
Compare
Codecov Report
@@ Coverage Diff @@
## master #1007 +/- ##
============================================
+ Coverage 79.94% 80.01% +0.06%
- Complexity 488 489 +1
============================================
Files 35 35
Lines 1466 1466
Branches 188 188
============================================
+ Hits 1172 1173 +1
Misses 277 277
+ Partials 17 16 -1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1007 +/- ##
=========================================
Coverage 79.94% 79.94%
Complexity 488 488
=========================================
Files 35 35
Lines 1466 1466
Branches 188 188
=========================================
Hits 1172 1172
Misses 277 277
Partials 17 17 Continue to review full report at Codecov.
|
day.invalid = Некорректный день месяца | ||
month.invalid = Некорректный номер месяца | ||
series.too-early-release-year = Год выпуска серии не может быть раньше {value} | ||
javax.validation.constraints.NotNull.message = \u041F\u043E\u043B\u0435 \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E \u0434\u043B\u044F \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F |
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, leave this file in Russian? We have the native2ascii maven plugin which encodes to ascii automatically on every build.
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.
Sorry, but it's not clear to me . I didn't add these lines to this Ru properties ... I added only one string
seller.buyer.match = Продавец и покупатель не должны совпадать
Should i delete it? If i delete it the checkstyle will raise the violation about missing of this line . Is it ok ?
Thanks
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.
As far as i understand you our plugin translates our messages in English , right ?
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 didn't add these lines to this Ru properties ... I added only one string
Yes, it wasn't you but it was your IDE. Perhaps, there should be a way to configure it to disable such behavior. Have you enable "Transparent native-to-ascii conversion for properties files"? See https://www.jetbrains.com/help/idea/properties-files.html#encoding
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.
Should i delete it?
No, please, leave it. The issue isn't about you added one line but it's about your IDE convert the content of a whole file to another charset. It shouldn't do that.
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.
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 that everything has set by default ...
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.
What do you have for Default encoding for properties files? UTF-8?
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.
@KrivenkoAlexander I've just checked my IDEA settings and it turned out that "Transparent native-to-ascii conversion" should be turned off! :-) I'll update instruction, thank you!
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 switched off this setting right now
@@ -49,6 +49,8 @@ login.repetition_chars = Login must not contain repetition of hyphen, dot or und | |||
password.mismatch = Password mismatch | |||
password.login.match = Password and login must be different | |||
|
|||
seller.buyer.match = Seller and buyer must be different | |||
|
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'd rather put it right after password.login.match
.
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.
done
first = "sellerId", | ||
second = "buyerId", | ||
message = "{seller.buyer.match}" | ||
) |
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.
As the annotation with all its argument isn't too long, could you write it as a one line, please?
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.
done
Could you review my solution and merge it if it is ok. And i am ready for new task . |
|
The next task is #504 but it edits the same file and should be based on the changes from this PR. |
bf9475b
to
d024054
Compare
Let's try again. :) I have changed the settings . I hope it will fix this problem. |
d024054
to
2e23223
Compare
No, it didn't. Check yourself -- open tab "Files changed" and scroll down to the Let's fix it step-by-step:
|
…d it just to create new PR no more .
2e23223
to
f07e6fc
Compare
Right now looks good. Am i right that my problem was that i didn't revert back my changes and tried to change the setting of IDEA? I should do reverting every time when i need to change config in IDEA, right? |
Merged in 36cf5c3 |
Addressed to #503