Skip to content

#620_refactoring_method #624

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

Closed
wants to merge 1 commit into from
Closed

Conversation

bodom91
Copy link
Contributor

@bodom91 bodom91 commented Aug 3, 2017

Addressed to #620

@bodom91 bodom91 requested a review from php-coder August 3, 2017 09:32
@mystamps-bot
Copy link

mystamps-bot commented Aug 3, 2017

1 Message
📖 @bodom91 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

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 75.055% when pulling bd91048 on bodom91:gh620_new_place into eb57501 on php-coder:master.


public MailServiceImpl(
JavaMailSender mailer,
MessageSource messageSource,
String adminEmail,
Locale adminLang,
String robotEmail,
boolean testMode) {
boolean testMode,
ReportService reportService) {
Copy link
Owner

Choose a reason for hiding this comment

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

Let's make it the first argument.

@@ -104,7 +104,7 @@ public void sendDailyStatisticsToAdmin(AdminDailyReport report) {
sendMail(
adminEmail,
getSubjectOfDailyStatisticsMail(report),
prepareDailyStatistics(report),
reportService.prepareDailyStatistics(report),
Copy link
Owner

Choose a reason for hiding this comment

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

Are you sure that it won't fail because of the @PreAuthorize? Have you test it?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, it doesn't work:

2017-08-03 22:13:56.007 ERROR 19147 --- [cTaskExecutor-4] .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected error occurred invoking async method 'public void ru.mystamps.web.service.MailServiceImpl.sendDailyStatisticsToAdmin(ru.mystamps.web.service.dto.AdminDailyReport)'.

org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext

Copy link
Contributor Author

@bodom91 bodom91 Aug 4, 2017

Choose a reason for hiding this comment

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

How do i can run these test ?
I tried run "mvn test" , but i get no error.

Copy link
Owner

Choose a reason for hiding this comment

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

There is no test for that. You can modify CronServiceImpl:

-private static final String EVERY_DAY_AT_00_00 = "0 0 0 * * *";
+private static final String EVERY_DAY_AT_00_00 = "* * * * * *";

this will run sendDailyStatistics() every second. Now start the server and look at the console.

(Note that when you fix this error it will still fail because there is no SMTP server configured.)

}

@Override
@PreAuthorize(HasAuthority.VIEW_DAILY_STATS)
Copy link
Owner

@php-coder php-coder Aug 3, 2017

Choose a reason for hiding this comment

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

To workaround issue with permissions, let's remove this @PreAuthorize and leave a comment (before @Override):

// This method should have @PreAuthorize(VIEW_DAILY_STATS) but we can't put it here because it
// breaks MailServiceImpl.sendDailyStatisticsToAdmin() method that is being executed by cron.

@bodom91 bodom91 force-pushed the gh620_new_place branch 3 times, most recently from 85d47cc to 15ed38f Compare August 7, 2017 07:02
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 75.055% when pulling f972bf7 on bodom91:gh620_new_place into d55ae61 on php-coder:master.

@php-coder
Copy link
Owner

Merged in 00d021f commit.

Thank you!

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.

4 participants