Skip to content

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

Conversation

KrivenkoAlexander
Copy link
Contributor

@KrivenkoAlexander KrivenkoAlexander commented Feb 21, 2019

Addressed to #503

@mystamps-bot
Copy link

mystamps-bot commented Feb 21, 2019

1 Message
📖 @KrivenkoAlexander thank you for the PR! All quality checks have been passed! Next step is to wait when @php-coder will review this code

Generated by 🚫 Danger

//)
@FieldsMismatch(
first = "sellerId",
second ="buyerId"
Copy link
Owner

Choose a reason for hiding this comment

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

This annotation works.

Copy link
Owner

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:

  1. modify manually HTML code of the page to be able to choose Eicca twice
  2. modify Eicca's properties directly in database (so she will appear in both select boxes)

@KrivenkoAlexander
Copy link
Contributor Author

KrivenkoAlexander commented Feb 21, 2019 via email

@php-coder php-coder changed the title First attempt to make improvements of validation : it is draft . [WIP] Series sales: add validation to ensure that buyer and seller aren't the same Feb 21, 2019
@php-coder
Copy link
Owner

@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.

@php-coder
Copy link
Owner

I did creation of two new users with the similar names and used them like a buyer and seller .

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.

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 ?

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.

@KrivenkoAlexander KrivenkoAlexander force-pushed the gh503_Series_sales_form_diff_buyer_and_seller branch from a7d77af to 0e50a9b Compare February 21, 2019 20:25
Copy link
Owner

@php-coder php-coder left a 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(
Copy link
Owner

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).

Copy link
Contributor Author

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
Copy link
Owner

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.

Copy link
Contributor Author

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"
Copy link
Owner

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:

  1. @FieldsMismatch(
    first = "login",
    second = "password",
    message = "{password.login.match}",
  2. password.login.match = Password and login must be different
  3. password.login.match = Пароль и логин не должны совпадать

In this case, the message will be

seller.buyer.match = Seller and buyer must be different

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@php-coder php-coder changed the title [WIP] Series sales: add validation to ensure that buyer and seller aren't the same Series sales: add validation to ensure that buyer and seller aren't the same Feb 21, 2019
@KrivenkoAlexander KrivenkoAlexander force-pushed the gh503_Series_sales_form_diff_buyer_and_seller branch from 0e50a9b to 18331c1 Compare February 22, 2019 13:00
@codecov
Copy link

codecov bot commented Feb 22, 2019

Codecov Report

Merging #1007 into master will increase coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
...ture/series/importing/SeriesImportServiceImpl.java 97.91% <0%> (+1.04%) 31% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b25cb6...18331c1. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 22, 2019

Codecov Report

Merging #1007 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ff7854...f07e6fc. Read the comment docs.

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
Copy link
Owner

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.

Copy link
Contributor Author

@KrivenkoAlexander KrivenkoAlexander Feb 23, 2019

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

Copy link
Contributor Author

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 ?

Copy link
Owner

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

Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

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 ...

Copy link
Contributor Author

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?

Copy link
Owner

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!

Copy link
Contributor Author

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

Copy link
Owner

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.

Copy link
Contributor Author

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}"
)
Copy link
Owner

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@KrivenkoAlexander
Copy link
Contributor Author

Could you review my solution and merge it if it is ok. And i am ready for new task .
Thank you for sharing of links about validator and spring framework . They help me and i appreciate this.
Thanks.

@php-coder
Copy link
Owner

Could you review my solution and merge it if it is ok. And i am ready for new task .

  1. You've changed the editor settings but the file is still in a bad shape. Could you modify it? ValidationMessages_ru.properties should have the similar small change as ValidationMessages.properties -- just one line of text in Russian.
  2. please, squash the commits into one

@php-coder
Copy link
Owner

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.

@KrivenkoAlexander KrivenkoAlexander changed the title Series sales: add validation to ensure that buyer and seller aren't the same [WIP]:Series sales: add validation to ensure that buyer and seller aren't the same Feb 24, 2019
@KrivenkoAlexander KrivenkoAlexander force-pushed the gh503_Series_sales_form_diff_buyer_and_seller branch from bf9475b to d024054 Compare February 24, 2019 08:39
@KrivenkoAlexander
Copy link
Contributor Author

KrivenkoAlexander commented Feb 24, 2019

Let's try again. :) I have changed the settings . I hope it will fix this problem.

@KrivenkoAlexander KrivenkoAlexander force-pushed the gh503_Series_sales_form_diff_buyer_and_seller branch from d024054 to 2e23223 Compare February 24, 2019 10:30
@php-coder php-coder changed the title [WIP]:Series sales: add validation to ensure that buyer and seller aren't the same Series sales: add validation to ensure that buyer and seller aren't the same Feb 24, 2019
@php-coder
Copy link
Owner

Let's try again. :) I have changed the settings . I hope it will fix this problem.

No, it didn't. Check yourself -- open tab "Files changed" and scroll down to the ValidationMessages_ru.properties file -- the whole content was edited.

Let's fix it step-by-step:

  1. turn off "Transparent native-to-ascii conversion" in IDEA
  2. revert the change for that file: git checkout HEAD^ -- src/main/resources/ru/mystamps/i18n/ValidationMessages_ru.properties
  3. open that file in IDEA again and add a line with translation
  4. commit your changes: git commit -a --amend
  5. check your fix: git show src/main/resources/ru/mystamps/i18n/ValidationMessages_ru.properties
  6. push: git push --force-with-lease

@KrivenkoAlexander KrivenkoAlexander force-pushed the gh503_Series_sales_form_diff_buyer_and_seller branch from 2e23223 to f07e6fc Compare February 24, 2019 12:02
@KrivenkoAlexander
Copy link
Contributor Author

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?
Thanks.

@php-coder
Copy link
Owner

Merged in 36cf5c3
Thank you!

@php-coder php-coder closed this Feb 24, 2019
@KrivenkoAlexander KrivenkoAlexander deleted the gh503_Series_sales_form_diff_buyer_and_seller branch February 25, 2019 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants