|
3 | 3 | import java.time.LocalDate;
|
4 | 4 | import java.time.LocalDateTime;
|
5 | 5 | import mate.academy.exception.AuthenticationException;
|
| 6 | +import mate.academy.exception.DataProcessingException; |
6 | 7 | import mate.academy.exception.RegistrationException;
|
7 | 8 | import mate.academy.lib.Injector;
|
8 | 9 | import mate.academy.model.CinemaHall;
|
|
13 | 14 | import mate.academy.service.CinemaHallService;
|
14 | 15 | import mate.academy.service.MovieService;
|
15 | 16 | import mate.academy.service.MovieSessionService;
|
16 |
| -import mate.academy.service.UserService; |
17 | 17 |
|
18 | 18 | public class Main {
|
19 |
| - public static void main(String[] args) throws RegistrationException, AuthenticationException { |
| 19 | + public static void main(String[] args) throws RegistrationException { |
20 | 20 | Injector injector = Injector.getInstance("mate.academy");
|
21 | 21 | MovieService movieService =
|
22 | 22 | (MovieService) injector.getInstance(MovieService.class);
|
@@ -62,19 +62,27 @@ public static void main(String[] args) throws RegistrationException, Authenticat
|
62 | 62 | System.out.println(movieSessionService.findAvailableSessions(
|
63 | 63 | fastAndFurious.getId(), LocalDate.now()));
|
64 | 64 |
|
65 |
| - UserService userService = (UserService) injector.getInstance(UserService.class); |
66 | 65 | AuthenticationService authenticationService =
|
67 | 66 | (AuthenticationService) injector.getInstance(AuthenticationService.class);
|
68 | 67 | System.out.println("register method started");
|
69 |
| - User registeredUser = authenticationService.register("bob@gmail.com", "123456789qwerty!"); |
70 |
| - System.out.println("register method finished"); |
71 |
| - System.out.println(registeredUser.toString()); |
| 68 | + try { |
| 69 | + User registeredUser = authenticationService |
| 70 | + .register("bob@gmail.com", "123456789qwerty!"); |
| 71 | + System.out.println("register method finished"); |
| 72 | + System.out.println(registeredUser.toString()); |
| 73 | + } catch (RegistrationException e) { |
| 74 | + throw new DataProcessingException("Error registering user", e); |
| 75 | + } |
72 | 76 |
|
73 | 77 | System.out.println("-----------------");
|
74 | 78 |
|
75 | 79 | System.out.println("login method started");
|
76 |
| - User loginedUser = authenticationService.login("bob@gmail.com", "123456789qwerty!"); |
77 |
| - System.out.println("login method finished"); |
78 |
| - System.out.println(loginedUser.toString()); |
| 80 | + try { |
| 81 | + User loginedUser = authenticationService.login("bob@gmail.com", "123456789qwerty!"); |
| 82 | + System.out.println("login method finished"); |
| 83 | + System.out.println(loginedUser.toString()); |
| 84 | + } catch (AuthenticationException e) { |
| 85 | + throw new DataProcessingException("Error logining user", e); |
| 86 | + } |
79 | 87 | }
|
80 | 88 | }
|
0 commit comments