|
2 | 2 |
|
3 | 3 | import java.time.LocalDate;
|
4 | 4 | import java.time.LocalDateTime;
|
| 5 | +import mate.academy.exception.AuthenticationException; |
| 6 | +import mate.academy.exception.RegistrationException; |
5 | 7 | import mate.academy.lib.Injector;
|
6 | 8 | import mate.academy.model.CinemaHall;
|
7 | 9 | import mate.academy.model.Movie;
|
8 | 10 | import mate.academy.model.MovieSession;
|
| 11 | +import mate.academy.service.AuthenticationService; |
9 | 12 | import mate.academy.service.CinemaHallService;
|
10 | 13 | import mate.academy.service.MovieService;
|
11 | 14 | import mate.academy.service.MovieSessionService;
|
@@ -57,5 +60,37 @@ public static void main(String[] args) {
|
57 | 60 | System.out.println(movieSessionService.get(yesterdayMovieSession.getId()));
|
58 | 61 | System.out.println(movieSessionService.findAvailableSessions(
|
59 | 62 | fastAndFurious.getId(), LocalDate.now()));
|
| 63 | + |
| 64 | + String correctEmail = "correct@email.com"; |
| 65 | + String incorrectEmail = "incorrect@email.com"; |
| 66 | + String correctPassword = "correctPassword"; |
| 67 | + String incorrectPassword = "incorrectPassword"; |
| 68 | + AuthenticationService authenticationService = |
| 69 | + (AuthenticationService) injector.getInstance(AuthenticationService.class); |
| 70 | + |
| 71 | + try { |
| 72 | + authenticationService.register(correctEmail, correctPassword); |
| 73 | + } catch (RegistrationException e) { |
| 74 | + throw new RuntimeException(e); |
| 75 | + } |
| 76 | + |
| 77 | + try { |
| 78 | + authenticationService.login(incorrectEmail, correctPassword); |
| 79 | + } catch (AuthenticationException e) { |
| 80 | + throw new RuntimeException(e); |
| 81 | + } |
| 82 | + |
| 83 | + try { |
| 84 | + authenticationService.login(correctEmail, incorrectPassword); |
| 85 | + } catch (AuthenticationException e) { |
| 86 | + throw new RuntimeException(e); |
| 87 | + } |
| 88 | + |
| 89 | + try { |
| 90 | + authenticationService.login(correctEmail, correctPassword); |
| 91 | + System.out.println("login successful"); |
| 92 | + } catch (AuthenticationException e) { |
| 93 | + throw new RuntimeException(e); |
| 94 | + } |
60 | 95 | }
|
61 | 96 | }
|
0 commit comments