Skip to content

Commit 6311246

Browse files
authored
Merge pull request #62 from CSC207-2022F-UofT/feature-1-and-2-login-and-signup
Added Testing for Login interactor
2 parents 52ec1b2 + 5c913e5 commit 6311246

File tree

58 files changed

+880
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+880
-326
lines changed

src/main/java/Main.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import com.formdev.flatlaf.FlatIntelliJLaf;
21
import com.formdev.flatlaf.FlatDarculaLaf;
32

4-
import loginAndSignupUseCase.loginAndSignupUseCaseScreens.WelcomeScreen;
3+
import login_and_signup_use_case.login_and_signup_use_case_screens.WelcomeScreen;
54
import java.io.IOException;
65

76
/**

src/main/java/MainPage/FlashcardSetDataPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import EditorMainPage.EditorMainPage;
44
import dataAccess.DBGateway;
55
import delete_flashcardset_use_case.*;
6-
import loginAndSignupUseCase.UserLoginResponseModel;
6+
import login_and_signup_use_case.UserLoginResponseModel;
77
import quizUseCase.*;
88
import quizUseCase.screens.QuizSettingsScreen;
99
import studyMode.*;

src/main/java/MainPage/HomePage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import create_flashcardset_use_case.*;
44
import dataAccess.*;
55
import entities.FlashcardSetFactory;
6-
import loginAndSignupUseCase.UserLoginResponseModel;
7-
import loginAndSignupUseCase.loginAndSignupUseCaseScreens.WelcomeScreen;
6+
import login_and_signup_use_case.UserLoginResponseModel;
7+
import login_and_signup_use_case.login_and_signup_use_case_screens.WelcomeScreen;
88
import search_use_case.*;
99

1010
import javax.swing.*;

src/main/java/MainPage/ListOfFlashcardSetsDataPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
import dataAccess.DBGateway;
5-
import loginAndSignupUseCase.UserLoginResponseModel;
5+
import login_and_signup_use_case.UserLoginResponseModel;
66

77
import javax.swing.*;
88
import java.awt.*;

src/main/java/create_flashcardset_use_case/CreationScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package create_flashcardset_use_case;
22

3-
import loginAndSignupUseCase.UserLoginResponseModel;
3+
import login_and_signup_use_case.UserLoginResponseModel;
44

55
import javax.swing.*;
66
import java.awt.*;

src/main/java/delete_flashcardset_use_case/DeletionScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package delete_flashcardset_use_case;
22

33

4-
import loginAndSignupUseCase.UserLoginResponseModel;
4+
import login_and_signup_use_case.UserLoginResponseModel;
55

66
import javax.swing.*;
77
import java.awt.*;

src/main/java/entities/CommonUser.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,39 @@
22

33
import java.util.ArrayList;
44

5+
/**
6+
* A user that has their username, password, whether they have admin access, and the list of all the ids
7+
* of the flashcard sets that belong to them
8+
*<p>
9+
* Enterprise Business Rules
10+
* @author Aryan Chablani
11+
*/
12+
513
public class CommonUser implements User{
614

715
private String username;
8-
916
private String password;
1017
private boolean isAdmin;
1118
final String ADMIN_KEY = "BuiltDifferent";
1219
final ArrayList<Integer> flashcardSetIds;
1320

21+
/**
22+
* Constructor for Common User
23+
* Precondition: No common user for this username exists yet
24+
* @param username the username of the user
25+
* @param password the password of the user
26+
* @param isAdmin whether the user is an admin or not
27+
* @return a CommonUser object
28+
* Post Condition: A common user will be instantiated.
29+
*/
1430
public CommonUser(String username, String password, boolean isAdmin){
1531
this.username = username;
1632
this.password = password;
1733
this.isAdmin = isAdmin;
1834
this.flashcardSetIds = new ArrayList<>();
1935
}
2036

37+
//GETTERS AND SETTERS
2138
@Override
2239
public String getUsername() {
2340
return username;
@@ -36,11 +53,6 @@ public void setPassword(String password) {
3653
this.password = password;
3754
}
3855

39-
@Override
40-
public boolean passwordIsValid() {
41-
return password != null && password.length() > 5;
42-
}
43-
4456
@Override
4557
public boolean getIsAdmin() {
4658
return isAdmin;
@@ -55,6 +67,20 @@ public ArrayList<Integer> getFlashcardSetIds() {
5567
return flashcardSetIds;
5668
}
5769

70+
/**
71+
* Checks whether the password is valid by not being nothing and greater in length by 5
72+
* @return whether the password is valid
73+
*/
74+
@Override
75+
public boolean passwordIsValid() {
76+
return password != null && password.length() > 5;
77+
}
78+
79+
/**
80+
* Checks whether the admin key entered is similar to the actual admin key in the business rules
81+
* @param adminKey the username of the use
82+
* @return whether the admin is the same as the one stored in the enterprise rules
83+
*/
5884
@Override
5985
public boolean adminKeyValid(String adminKey) {
6086
return adminKey.equals(ADMIN_KEY);

src/main/java/entities/CommonUserFactory.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
package entities;
22

3+
/**
4+
* A class to call the constructor of the CommonUser and create a Common User object to ensure Clean Architecture
5+
*<p>
6+
* Enterprise Business Rules
7+
* @author Aryan Chablani
8+
*/
9+
310
public class CommonUserFactory implements UserFactory {
411

12+
/**
13+
* A factory to create a Common User object
14+
* Precondition: No common user for this username exists yet
15+
* @param username the username of the use
16+
* @param password the password of the use
17+
* @param isAdmin whether the user is an admin or not
18+
* @return a CommonUser object
19+
* Post Condition: A common user will be instantiated.
20+
*/
521
@Override
622
public User create(String username, String password, boolean isAdmin) {
723
return new CommonUser(username, password, isAdmin);

src/main/java/entities/User.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package entities;
22
import java.util.*;
33

4+
/**
5+
* A user interface that has their username, password, whether they have admin access, and the list of all the ids
6+
* of the flashcard sets that belong to them
7+
*<p>
8+
* Enterprise Business Rules
9+
* @author Aryan Chablani
10+
*/
411
public interface User {
512
String username = null;
613

@@ -15,12 +22,20 @@ public interface User {
1522

1623
String getPassword();
1724

18-
19-
boolean passwordIsValid();
20-
2125
boolean getIsAdmin();
2226

2327
ArrayList<Integer> getFlashcardSetIds();
2428

29+
/**
30+
* Checks whether the password is valid by not being nothing and greater in length by 5
31+
* @return whether the password is valid
32+
*/
33+
boolean passwordIsValid();
34+
35+
/**
36+
* Checks whether the admin key entered is similar to the actual admin key in the business rules
37+
* @param adminKey the username of the use
38+
* @return whether the admin is the same as the one stored in the enterprise rules
39+
*/
2540
boolean adminKeyValid(String adminKey);
2641
}
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
package entities;
22

3-
import java.util.ArrayList;
4-
import java.util.Map;
3+
/**
4+
* A class to call the constructor of the CommonUser and create a Common User object to ensure Clean Architecture
5+
*<p>
6+
* Enterprise Business Rules
7+
* @author Aryan Chablani
8+
*/
59

610
public interface UserFactory {
711

12+
/**
13+
* A factory to create a user object
14+
* Precondition: No User for this username exists yet
15+
* @param username the username of the user
16+
* @param password the password of the user
17+
* @param isAdmin whether the user is an admin or not
18+
* @return a User object
19+
* Post Condition: A User will be creates.
20+
*/
821
User create(String username, String password, boolean isAdmin);
922
}

0 commit comments

Comments
 (0)