-
Notifications
You must be signed in to change notification settings - Fork 1.1k
result #1252
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
base: master
Are you sure you want to change the base?
result #1252
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| .idea/* | ||
| *.iml | ||
| target/* | ||
| *.log |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Configuration status="info"> | ||
| <Appenders> | ||
| <Console name="Console" target="SYSTEM_OUT"> | ||
| <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||
| </Console> | ||
| <File name="File" fileName="logs/app.log"> | ||
| <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> | ||
| </File> | ||
| </Appenders> | ||
| <Loggers> | ||
| <Root level="info"> | ||
| <AppenderRef ref="Console"/> | ||
| <AppenderRef ref="File"/> | ||
| </Root> | ||
| </Loggers> | ||
| </Configuration> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| package mate.academy.exception; | ||
|
|
||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
|
|
||
| public class AuthenticationException extends Exception { | ||
| private static final Logger logger = LogManager.getLogger(AuthenticationException.class); | ||
|
|
||
| public AuthenticationException(String message) { | ||
| super(message); | ||
| logger.error(message); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,14 +2,17 @@ | |
|
|
||
| import mate.academy.exception.AuthenticationException; | ||
| import mate.academy.model.User; | ||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
|
|
||
| public class AuthenticationServiceImpl implements AuthenticationService { | ||
| private static final Logger logger = LogManager.getLogger(AuthenticationServiceImpl.class); | ||
|
|
||
| @Override | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing log4j2.xml configuration file with File and Console appenders (Task requirement #1) |
||
| public User login(String login, String password) throws AuthenticationException { | ||
| //TODO: add corresponding log message about method login was called | ||
| User user = findByLogin(login); | ||
| if (!user.getPassword().equals(password)) { | ||
| throw new AuthenticationException("Username or password are incorrect"); | ||
| logger.error("Login or password are incorrect. login={}", login); | ||
| } | ||
| return user; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,16 +4,21 @@ | |
| import java.util.List; | ||
| import mate.academy.model.Order; | ||
| import mate.academy.model.Product; | ||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
|
|
||
| public class OrderServiceImpl implements OrderService { | ||
| private static final Logger logger = LogManager.getLogger(OrderServiceImpl.class); | ||
|
|
||
| @Override | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checklist item #1 violation: This TODO comment should be completed. Add a log message like |
||
| public Order completeOrder(Long userId) { | ||
| // TODO: add log message about method completeOrder was called | ||
| List<Product> products = getAllProductsFromShoppingCart(userId); | ||
| Order order = new Order(products, userId); | ||
| // NOTE: In production ready code this order identifier should be generated by DB | ||
| // For test purpose we simplify this and return dummy data | ||
| order.setOrderId(1L); | ||
| logger.info("Method login failed. Params: products={}, userId={}", | ||
| products, userId); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The log message says 'Method login failed' but this is the |
||
| return order; | ||
| } | ||
|
|
||
|
|
@@ -24,7 +29,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 from DB is fetched successful"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This log message should include the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This log message is missing the |
||
| return products; | ||
| } | ||
| } | ||
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.
TODO not completed. Per checklist item #1, all TODO comments must be removed. This TODO requires adding a log message about method login being called with parameters included (e.g.,
logger.debug("Method login was called. Params: login={}", login);)