-
Notifications
You must be signed in to change notification settings - Fork 34
#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
Conversation
Generated by 🚫 Danger |
eca01fb
to
bd91048
Compare
|
||
public MailServiceImpl( | ||
JavaMailSender mailer, | ||
MessageSource messageSource, | ||
String adminEmail, | ||
Locale adminLang, | ||
String robotEmail, | ||
boolean testMode) { | ||
boolean testMode, | ||
ReportService reportService) { |
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.
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), |
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.
Are you sure that it won't fail because of the @PreAuthorize
? Have you test it?
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, 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
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.
How do i can run these test ?
I tried run "mvn test" , but i get no error.
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 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) |
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.
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.
85d47cc
to
15ed38f
Compare
15ed38f
to
f972bf7
Compare
Merged in 00d021f commit. Thank you! |
Addressed to #620