1
- //package loginAndSignUpUseCase;
2
- //
3
- //import dataAccess.CommonUserDataAccess;
4
- //import dataAccess.DBGateway;
5
- //import dataAccess.IUserDataAccess;
6
- //import entities.CommonUserFactory;
7
- //import entities.UserFactory;
8
- //import org.junit.jupiter.api.BeforeEach;
9
- //import org.junit.jupiter.api.Test;
10
- //import loginAndSignupUseCase.*;
11
- //import org.junit.jupiter.api.Test;
12
- //import org.testing.annotations.Test;
13
- //
14
- //import static org.junit.jupiter.api.Assertions.*;
15
- //import java.io.IOException;
16
- //
17
- //import static org.junit.Assert.*;
18
- //import static org.testng.AssertJUnit.*;
19
- //
20
- //class UserRegisterInteractorTest {
21
- // UserRegisterOutputBoundary presenter = new UserRegisterOutputBoundary() {
22
- //
23
- // UserFactory userFactory = new CommonUserFactory();
24
- // UserRegisterInputBoundary interactor = new UserRegisterInteractor(
25
- // userRepository, presenter, userFactory);
26
- //
27
- // UserRegisterRequestModel inputData = new UserRegisterRequestModel(
28
- // "Richard", "Virgin123", "Virgin123", "BuiltDifferent");
29
- //
30
- // UserRegisterRequestModel inputData2 = new UserRegisterRequestModel(
31
- // "Branson", "Virgin123", "Virgin123", "");
32
- //
33
- // interactor.create(inputData);
34
- // interactor.create(inputData2);
35
-
36
- // IFlashcardDataAccess flashcardGateway = new FlashcardDataAccess(
37
- // "src/test/java/quizUseCase/testData/Flashcards.csv");
38
- // IFlashcardSetDataAccess flashcardSetGateway = new FlashcardSetDataAccess(
39
- // "src/test/java/quizUseCase/testData/FlashcardSets.csv");
40
- // IUserDataAccess userGateway = new CommonUserDataAccess(
41
- // "src/test/java/quizUseCase/testData/Users.csv");
42
- //
43
- // DBGateway gateway = new DBGateway(flashcardGateway, flashcardSetGateway, userGateway);
44
- //
45
- // @Test
46
- // void login() throws IOException {
47
- //
48
- // UserLoginOutputBoundary presenter = new UserLoginOutputBoundary() {
49
- // @Override
50
- // public UserLoginResponseModel prepareSuccessView(UserLoginResponseModel user) {
51
- // assertEquals("Richard", user.getSignedInUsername());
52
- // assertEquals(true, user.getIsAdmin());
53
- // assertEquals({}, user.getFlashcardSet());
54
- // return null;
55
- // }
56
- //
57
- // @Override
58
- // public UserLoginResponseModel prepareFailView(String error) {
59
- // fail("Use case failure is unexpected.");
60
- // return null;
61
- // }
62
- // };
63
- //
64
- // UserLoginInputBoundary interactor = new UserLoginInteractor(
65
- // userRepository, presenter, userFactory);
66
- //
67
- // }
68
- //
69
- // @Test
70
- // void create2() throws IOException {
71
- //
72
- //
73
- // }
74
- //
75
- //}
1
+ package loginAndSignUpUseCase ;
2
+
3
+ import dataAccess .*;
4
+ import org .junit .jupiter .api .Assertions ;
5
+ import org .junit .jupiter .api .Test ;
6
+ import static org .junit .Assert .fail ;
7
+ import java .io .IOException ;
8
+ import loginAndSignupUseCase .loginAndSignupUseCaseScreens .UserLoginPresenter ;
9
+ import loginAndSignupUseCase .UserLoginOutputBoundary ;
10
+ import loginAndSignupUseCase .UserLoginInputBoundary ;
11
+ import loginAndSignupUseCase .UserLoginResponseModel ;
12
+ import loginAndSignupUseCase .UserLoginRequestModel ;
13
+ import loginAndSignupUseCase .UserLoginInteractor ;
14
+
15
+ class UserLoginInteractorTest {
16
+
17
+ // 1) UserLoginInteractorTest and prerequisite objects
18
+
19
+ IUserDataAccess userGateway = new CommonUserDataAccess (
20
+ "src/test/java/loginAndSignUpUseCase/testData/Users.csv" );
21
+
22
+
23
+ DBGateway gateway = new DBGateway (null , null , userGateway );
24
+
25
+ UserLoginInteractorTest () throws IOException {
26
+ }
27
+
28
+ @ Test
29
+ void create () throws IOException {
30
+ UserLoginOutputBoundary presenter = new UserLoginPresenter () {
31
+ @ Override
32
+ public UserLoginResponseModel prepareSuccessView (UserLoginResponseModel user ) {
33
+
34
+ Assertions .assertEquals ("Steve" , user .getSignedInUsername ());
35
+ Assertions .assertFalse (user .getIsAdmin ());
36
+ //assertEquals(Map, user.getFlashcardSets());
37
+ return null ;
38
+ }
39
+
40
+ @ Override
41
+ public UserLoginResponseModel prepareFailView (String error ) {
42
+ fail ("Use case failure is unexpected." );
43
+ return null ;
44
+ }
45
+ };
46
+ UserLoginInputBoundary interactor = new UserLoginInteractor (
47
+ gateway , presenter );
48
+
49
+ // 2) Input data — Normally created by the Controller.
50
+ UserLoginRequestModel inputData = new UserLoginRequestModel (
51
+ "Steve" , "Apple123" );
52
+
53
+ // 3) Run the use case
54
+ interactor .login (inputData );
55
+ }
56
+
57
+ @ Test
58
+ void create2 () throws IOException {
59
+ UserLoginOutputBoundary presenter = new UserLoginPresenter () {
60
+ @ Override
61
+ public UserLoginResponseModel prepareSuccessView (UserLoginResponseModel user ) {
62
+
63
+ Assertions .assertEquals ("Richard" , user .getSignedInUsername ());
64
+ Assertions .assertTrue (user .getIsAdmin ());
65
+ //assertEquals({}, user.getFlashcardSets());
66
+ return null ;
67
+ }
68
+
69
+ @ Override
70
+ public UserLoginResponseModel prepareFailView (String error ) {
71
+ fail ("Use case failure is unexpected." );
72
+ return null ;
73
+ }
74
+ };
75
+ UserLoginInputBoundary interactor = new UserLoginInteractor (
76
+ gateway , presenter );
77
+
78
+ // 2) Input data — Normally created by the Controller.
79
+ UserLoginRequestModel inputData = new UserLoginRequestModel (
80
+ "Richard" , "Virgin123" );
81
+
82
+ // 3) Run the use case
83
+ interactor .login (inputData );
84
+ }
85
+ }
0 commit comments