-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Task accomplished #1071
base: master
Are you sure you want to change the base?
Task accomplished #1071
Conversation
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.
Great job on your implementation! 🎉 The core functionality of your code is intact, and the issues identified are mostly minor and related to improving clarity and professionalism in your logging messages. Here are a few suggestions to enhance your code further:
-
Log Message Clarity: Consider updating the misleading log message in
OrderServiceImpl.java
to reflect that the data is generated for testing rather than fetched from a database. -
Grammar Correction: In
AuthenticationServiceImpl.java
, correct the grammar in the exception message to 'Username or password is incorrect'. -
Informative Error Logs: Enhance the error log message to provide more context, such as including the username involved in the authentication failure.
-
Typo Fix: Correct the typo in
Main.java
to improve the readability and professionalism of your logs.
These improvements will make your code even more robust and maintainable. Keep up the great work! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
public static void main(String[] args) { | ||
AuthenticationService authenticationService = new AuthenticationServiceImpl(); | ||
User user; | ||
try { | ||
logger.info("User try ro authenticate"); |
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 a typo in the log message: 'User try ro authenticate'. It should be 'User tries to authenticate' or 'User is trying to authenticate'.
user = authenticationService.login("bob", "1234"); | ||
} catch (AuthenticationException e) { | ||
e.printStackTrace(); | ||
logger.error("Authentication error, {}", String.valueOf(e)); |
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 error log message could be more informative. Consider including more context about the error, such as 'Authentication failed for user bob: {}', to make it clearer what the error relates to.
@Override | ||
public User login(String login, String password) throws AuthenticationException { | ||
//TODO: add corresponding log message about method login was called | ||
logger.info("Method login was called with params: Login= {}",login); | ||
User user = findByLogin(login); | ||
if (!user.getPassword().equals(password)) { | ||
throw new AuthenticationException("Username or password are incorrect"); |
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 exception message 'Username or password are incorrect' should be 'Username or password is incorrect' for grammatical correctness.
@@ -24,7 +28,7 @@ private List<Product> getAllProductsFromShoppingCart(Long userId) { | |||
Product macBook = new Product("MacBook Air 2020", BigDecimal.valueOf(1399)); | |||
Product xiaomi = new Product("Xiaomi 12", BigDecimal.valueOf(499)); | |||
List<Product> products = List.of(iphone, macBook, xiaomi); | |||
// TODO: add log message about successful fetched data from DB | |||
logger.info("Data successfully found in the database"); |
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 log message 'Data successfully found in the database' is misleading because the data is not actually fetched from a database. Consider changing it to 'Dummy data generated for testing' to accurately reflect the current implementation.
No description provided.