From 7e767248eae123e8fcefd28de803d12608033c1b Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Fri, 2 Dec 2022 18:16:33 -0500 Subject: [PATCH 1/9] added logout interactor stuff to main because I forgot to add it before ugh --- src/main/java/Main.java | 11 +++++++++++ src/main/java/data/courses.csv | 1 + src/main/java/screens/InstructorMain.java | 1 + .../java/screens/login_registration/LogoutFailed.java | 8 ++++++++ 4 files changed, 21 insertions(+) create mode 100644 src/main/java/data/courses.csv create mode 100644 src/main/java/screens/login_registration/LogoutFailed.java diff --git a/src/main/java/Main.java b/src/main/java/Main.java index a222b32..3556f61 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -15,6 +15,10 @@ import use_cases.login_registration.login_usecase.LoginInputBoundary; import use_cases.login_registration.login_usecase.LoginInteractor; import use_cases.login_registration.login_usecase.LoginPresenter; +import use_cases.login_registration.logout_usecase.LogoutGateway; +import use_cases.login_registration.logout_usecase.LogoutInputBoundary; +import use_cases.login_registration.logout_usecase.LogoutInteractor; +import use_cases.login_registration.logout_usecase.LogoutPresenter; import use_cases.login_registration.user_register_usecase.*; import use_cases.task_management.event_creation_use_case.*; @@ -91,6 +95,13 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio CourseCreationInputBoundary interactor = new CourseCreationInteractor(course, presenter, courseMap); CourseCreationController courseCreationController = new CourseCreationController(interactor); + // Adding in logout use case + LogoutGateway logoutUser = new FileUser("src/main/java/data/users.ser"); + LogoutPresenter logoutPresenter = new LogoutResponseFormatter(); + LogoutInputBoundary logoutInteractor = new LogoutInteractor(logoutUser, logoutPresenter, user); + LogoutController logoutController = new LogoutController(logoutInteractor); + // + // Build the GUI EventCreationScreen taskScreen = new EventCreationScreen(eventCreationController, screens, cardLayout); screens.add("toDoList", taskScreen); diff --git a/src/main/java/data/courses.csv b/src/main/java/data/courses.csv new file mode 100644 index 0000000..122444c --- /dev/null +++ b/src/main/java/data/courses.csv @@ -0,0 +1 @@ +course_name,course_instructor,tasks? diff --git a/src/main/java/screens/InstructorMain.java b/src/main/java/screens/InstructorMain.java index ca37401..d3c1195 100644 --- a/src/main/java/screens/InstructorMain.java +++ b/src/main/java/screens/InstructorMain.java @@ -81,6 +81,7 @@ public void actionPerformed(ActionEvent evt) { // cardLayout.show(screens, "scheduleCT"); // } if (evt.getSource() == logout) { + cardLayout.show(screens, "welcome"); } diff --git a/src/main/java/screens/login_registration/LogoutFailed.java b/src/main/java/screens/login_registration/LogoutFailed.java new file mode 100644 index 0000000..2934fb8 --- /dev/null +++ b/src/main/java/screens/login_registration/LogoutFailed.java @@ -0,0 +1,8 @@ +package screens.login_registration; + +public class LogoutFailed extends Throwable { + + public LogoutFailed(String error) { + super(error); + } +} \ No newline at end of file From c116c491e0a5d8f2c422fcdd59231dbd7bad50ba Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Fri, 2 Dec 2022 18:18:57 -0500 Subject: [PATCH 2/9] added logoutController parameters to StudentMainScreen and InstructorMainScreen --- src/main/java/Main.java | 4 ++-- src/main/java/screens/InstructorMain.java | 4 +++- src/main/java/screens/StudentMainScreen.java | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 3556f61..16cc7c5 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -118,7 +118,7 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio CourseCreationScreen courseCreationScreen = new CourseCreationScreen(courseCreationController, screens, cardLayout); screens.add("course", courseCreationScreen); - StudentMainScreen studentMainScreen = new StudentMainScreen(screens, cardLayout); + StudentMainScreen studentMainScreen = new StudentMainScreen(screens, cardLayout, logoutController); screens.add("main", studentMainScreen); RegisterScreen registerScreen = new RegisterScreen(userRegisterController, cardLayout, screens); @@ -127,7 +127,7 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio LoginScreen loginScreen = new LoginScreen(loginController, cardLayout, screens); screens.add("login", loginScreen); - InstructorMain instructorMainScreen = new InstructorMain(screens, cardLayout); + InstructorMain instructorMainScreen = new InstructorMain(screens, cardLayout, logoutController); screens.add("InstructorMain", instructorMainScreen); WelcomeScreen welcomeScreen = new WelcomeScreen(cardLayout, screens); diff --git a/src/main/java/screens/InstructorMain.java b/src/main/java/screens/InstructorMain.java index d3c1195..19460eb 100644 --- a/src/main/java/screens/InstructorMain.java +++ b/src/main/java/screens/InstructorMain.java @@ -1,5 +1,7 @@ package screens; +import screens.login_registration.LogoutController; + import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -27,7 +29,7 @@ public class InstructorMain extends JPanel implements ActionListener { /** * The window of the main screen with buttons connecting to each use case */ - public InstructorMain(JPanel screens, CardLayout cardLayout) { + public InstructorMain(JPanel screens, CardLayout cardLayout, LogoutController controller) { this.cardLayout = cardLayout; this.screens = screens; diff --git a/src/main/java/screens/StudentMainScreen.java b/src/main/java/screens/StudentMainScreen.java index b63d03c..0198d94 100644 --- a/src/main/java/screens/StudentMainScreen.java +++ b/src/main/java/screens/StudentMainScreen.java @@ -1,5 +1,7 @@ package screens; +import screens.login_registration.LogoutController; + import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -27,7 +29,7 @@ public class StudentMainScreen extends JPanel implements ActionListener { /** * The window of the main screen with buttons connecting to each use case */ - public StudentMainScreen(JPanel screens, CardLayout cardLayout) { + public StudentMainScreen(JPanel screens, CardLayout cardLayout, LogoutController controller) { this.cardLayout = cardLayout; this.screens = screens; From b8f325fd1d206a59dd99e597f4e9fe44080aa595 Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Fri, 2 Dec 2022 18:20:48 -0500 Subject: [PATCH 3/9] added logoutController attributes to StudentMainScreen and InstructorMainScreen --- src/main/java/screens/InstructorMain.java | 3 +++ src/main/java/screens/StudentMainScreen.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/screens/InstructorMain.java b/src/main/java/screens/InstructorMain.java index 19460eb..927eab7 100644 --- a/src/main/java/screens/InstructorMain.java +++ b/src/main/java/screens/InstructorMain.java @@ -26,6 +26,8 @@ public class InstructorMain extends JPanel implements ActionListener { CardLayout cardLayout; JPanel screens; + LogoutController logoutController; + /** * The window of the main screen with buttons connecting to each use case */ @@ -33,6 +35,7 @@ public InstructorMain(JPanel screens, CardLayout cardLayout, LogoutController co this.cardLayout = cardLayout; this.screens = screens; + this.logoutController = controller; // Create label for title of screen JLabel title = new JLabel("32 Things To Do"); diff --git a/src/main/java/screens/StudentMainScreen.java b/src/main/java/screens/StudentMainScreen.java index 0198d94..2a294b7 100644 --- a/src/main/java/screens/StudentMainScreen.java +++ b/src/main/java/screens/StudentMainScreen.java @@ -26,6 +26,8 @@ public class StudentMainScreen extends JPanel implements ActionListener { CardLayout cardLayout; JPanel screens; + LogoutController logoutController; + /** * The window of the main screen with buttons connecting to each use case */ @@ -33,6 +35,7 @@ public StudentMainScreen(JPanel screens, CardLayout cardLayout, LogoutController this.cardLayout = cardLayout; this.screens = screens; + this.logoutController = controller; // Create label for title of screen JLabel title = new JLabel("32 Things To Do"); From 798446ac1bb1693a0f2e5eb107445014b13dfa19 Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Fri, 2 Dec 2022 20:25:10 -0500 Subject: [PATCH 4/9] finished integrating logout use case --- src/main/java/Main.java | 6 +--- src/main/java/data/users.ser | Bin 1015 -> 1272 bytes .../java/screens/InstructorMainScreen.java | 27 ++++++++++++------ src/main/java/screens/StudentMainScreen.java | 10 ++++++- .../login_registration/LoginScreen.java | 2 +- .../login_registration/LogoutController.java | 10 +++---- .../login_registration/RegisterScreen.java | 2 +- .../logout_usecase/LogoutInputBoundary.java | 6 ++-- .../logout_usecase/LogoutInteractor.java | 21 ++++---------- .../UserRegInteractor.java | 5 +--- .../logout_usecase/LogoutInteractorTest.java | 8 ++---- 11 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index ab41fb1..f2c4943 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -97,8 +97,7 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio // Adding in logout use case LogoutGateway logoutUser = new FileUser("src/main/java/data/users.ser"); - LogoutPresenter logoutPresenter = new LogoutResponseFormatter(); - LogoutInputBoundary logoutInteractor = new LogoutInteractor(logoutUser, logoutPresenter, user); + LogoutInputBoundary logoutInteractor = new LogoutInteractor(logoutUser); LogoutController logoutController = new LogoutController(logoutInteractor); // @@ -119,8 +118,6 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio screens.add("course", courseCreationScreen); StudentMainScreen studentMainScreen = new StudentMainScreen(screens, cardLayout, logoutController); - screens.add("main", studentMainScreen); - StudentMainScreen studentMainScreen = new StudentMainScreen(screens, cardLayout); screens.add("StudentMain", studentMainScreen); RegisterScreen registerScreen = new RegisterScreen(userRegisterController, cardLayout, screens); @@ -130,7 +127,6 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio screens.add("login", loginScreen); InstructorMainScreen instructorMainScreen = new InstructorMainScreen(screens, cardLayout, logoutController); -// InstructorMainScreen instructorMainScreen = new InstructorMain(screens, cardLayout, logoutController); screens.add("InstructorMain", instructorMainScreen); WelcomeScreen welcomeScreen = new WelcomeScreen(cardLayout, screens); diff --git a/src/main/java/data/users.ser b/src/main/java/data/users.ser index 8f6702e427ac07231145c6fb60234f6adaa3f098..fcbfbba557f5b969ff62c78d3028e15596fb09f5 100644 GIT binary patch delta 200 zcmey){)2Nu03++h!2gWwA`-HkF~w&#hcnG*)GT3ODM&2MDK2EFV-N+CT;+VM3=Hhg zc$h>)twt9CPN4riLr$XEdYh~Wt5 diff --git a/src/main/java/screens/InstructorMainScreen.java b/src/main/java/screens/InstructorMainScreen.java index e731e21..6800d90 100644 --- a/src/main/java/screens/InstructorMainScreen.java +++ b/src/main/java/screens/InstructorMainScreen.java @@ -1,12 +1,18 @@ package screens; +import screens.login_registration.LoginFailed; import screens.login_registration.LogoutController; +import screens.login_registration.LogoutFailed; +import use_cases.login_registration.login_usecase.LoginResponseModel; +import use_cases.login_registration.logout_usecase.LogoutResponseModel; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import static javax.swing.JOptionPane.showMessageDialog; + public class InstructorMainScreen extends JPanel implements ActionListener { @@ -26,13 +32,16 @@ public class InstructorMainScreen extends JPanel implements ActionListener { CardLayout cardLayout; JPanel screens; + LogoutController logoutController; + /** * The window of the main screen with buttons connecting to each use case */ - public InstructorMain(JPanel screens, CardLayout cardLayout) { + public InstructorMainScreen(JPanel screens, CardLayout cardLayout, LogoutController controller) { this.cardLayout = cardLayout; this.screens = screens; + this.logoutController = controller; // Create label for title of screen JLabel title = new JLabel("32 Things To Do"); @@ -42,13 +51,11 @@ public InstructorMain(JPanel screens, CardLayout cardLayout) { taskCreate = new JButton("New Task"); calendar = new JButton("Calendar"); courses = new JButton("Courses"); -// scheduleCT = new JButton("Schedule Collaborative Task"); logout = new JButton("Logout"); taskCreate.addActionListener(this); calendar.addActionListener(this); courses.addActionListener(this); -// scheduleCT.addActionListener(this); logout.addActionListener(this); // Create panel for buttons @@ -56,7 +63,6 @@ public InstructorMain(JPanel screens, CardLayout cardLayout) { buttons.add(taskCreate); buttons.add(calendar); buttons.add(courses); -// buttons.add(scheduleCT); buttons.add(logout); // Add all components to the panel @@ -79,11 +85,16 @@ public void actionPerformed(ActionEvent evt) { if (evt.getSource() == courses) { cardLayout.show(screens, "course"); } -// if (evt.getSource() == scheduleCT) { -// cardLayout.show(screens, "scheduleCT"); -// } + if (evt.getSource() == logout) { - cardLayout.show(screens, "welcome"); + try { + logoutController.create(); + showMessageDialog(this, "Successfully logged out"); + cardLayout.show(screens, "welcome"); + } catch (Exception e) { + showMessageDialog(this, "Logout failed"); + } + } } diff --git a/src/main/java/screens/StudentMainScreen.java b/src/main/java/screens/StudentMainScreen.java index 2a294b7..d087c34 100644 --- a/src/main/java/screens/StudentMainScreen.java +++ b/src/main/java/screens/StudentMainScreen.java @@ -7,6 +7,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import static javax.swing.JOptionPane.showMessageDialog; + public class StudentMainScreen extends JPanel implements ActionListener { /** @@ -91,7 +93,13 @@ public void actionPerformed(ActionEvent evt) { cardLayout.show(screens, "scheduleCT"); } if (evt.getSource() == logout) { - cardLayout.show(screens, "welcome"); + try { + logoutController.create(); + showMessageDialog(this, "Successfully logged out"); + cardLayout.show(screens, "welcome"); + } catch (Exception e) { + showMessageDialog(this, "Logout failed"); + } } } diff --git a/src/main/java/screens/login_registration/LoginScreen.java b/src/main/java/screens/login_registration/LoginScreen.java index 802a2a5..b9afac1 100644 --- a/src/main/java/screens/login_registration/LoginScreen.java +++ b/src/main/java/screens/login_registration/LoginScreen.java @@ -73,7 +73,7 @@ public void actionPerformed(ActionEvent evt) { try { LoginResponseModel l = loginController.create(username.getText(), String.valueOf(password.getPassword())); - showMessageDialog(this, "% logged in.".format(username.getText())); + showMessageDialog(this, "Successfully logged in."); if (l.getTypeOfUser().equals("Instructor")) { cardLayout.show(screens, "InstructorMain"); } else { diff --git a/src/main/java/screens/login_registration/LogoutController.java b/src/main/java/screens/login_registration/LogoutController.java index ab42e48..67609bc 100644 --- a/src/main/java/screens/login_registration/LogoutController.java +++ b/src/main/java/screens/login_registration/LogoutController.java @@ -8,15 +8,13 @@ public class LogoutController { - final LogoutInputBoundary userInput; + final LogoutInputBoundary interactor; public LogoutController(LogoutInputBoundary accGateway) { - this.userInput = accGateway; + this.interactor = accGateway; } - LogoutResponseModel create(String name, String timeOfLogout) throws IOException { - LogoutRequestModel request = new LogoutRequestModel(); - - return userInput.create(request); + public void create() throws IOException { + interactor.create(); } } diff --git a/src/main/java/screens/login_registration/RegisterScreen.java b/src/main/java/screens/login_registration/RegisterScreen.java index 4bd5fcc..91c532b 100644 --- a/src/main/java/screens/login_registration/RegisterScreen.java +++ b/src/main/java/screens/login_registration/RegisterScreen.java @@ -110,7 +110,7 @@ public void actionPerformed(ActionEvent evt) { String.valueOf(password.getPassword()), String.valueOf(repeatPassword.getPassword()), String.valueOf(typeOfUser.getText())); - showMessageDialog(this, "%s created.".format(username.getText())); + showMessageDialog(this, "Registration successful and logged in"); if (String.valueOf(typeOfUser.getText()).equals("Student")) { cardLayout.show(screens, "StudentMain"); } else if (String.valueOf(typeOfUser.getText()).equals("Instructor")) { diff --git a/src/main/java/use_cases/login_registration/logout_usecase/LogoutInputBoundary.java b/src/main/java/use_cases/login_registration/logout_usecase/LogoutInputBoundary.java index e1f79c7..393ce4e 100644 --- a/src/main/java/use_cases/login_registration/logout_usecase/LogoutInputBoundary.java +++ b/src/main/java/use_cases/login_registration/logout_usecase/LogoutInputBoundary.java @@ -4,10 +4,8 @@ public interface LogoutInputBoundary { - /** - * @param request the request to logout - * @return the logout response + /** Save a User's information into the database before they log out * @throws IOException */ - LogoutResponseModel create(LogoutRequestModel request) throws IOException; + void create() throws IOException; } diff --git a/src/main/java/use_cases/login_registration/logout_usecase/LogoutInteractor.java b/src/main/java/use_cases/login_registration/logout_usecase/LogoutInteractor.java index 4470846..327f8a1 100644 --- a/src/main/java/use_cases/login_registration/logout_usecase/LogoutInteractor.java +++ b/src/main/java/use_cases/login_registration/logout_usecase/LogoutInteractor.java @@ -1,5 +1,6 @@ package use_cases.login_registration.logout_usecase; +import entities.CurrentUser; import entities.InstructorUser; import entities.StudentUser; import entities.User; @@ -18,31 +19,24 @@ public class LogoutInteractor implements LogoutInputBoundary { */ final LogoutGateway userGateway; - final LogoutPresenter userPresenter; - - final User user; + private User user; /** * @param gateway the logout gateway (which interacts with the User database) - * @param logoutPresenter the logout presenter - * @param u the User that is logging out */ - public LogoutInteractor(LogoutGateway gateway, LogoutPresenter logoutPresenter, User u) { + public LogoutInteractor(LogoutGateway gateway) { this.userGateway = gateway; - this.userPresenter = logoutPresenter; - this.user = u; + this.user = CurrentUser.getCurrentUser(); } /** * Save a new UserRegSaveRequest which contains all of the information in the User that is trying to * log out into the User database. - * @param request the request to logout - * @return the logout response * @throws IOException if logout fails */ @Override - public LogoutResponseModel create(LogoutRequestModel request) throws IOException { - + public void create() throws IOException { + this.user = CurrentUser.getCurrentUser(); LocalDateTime now = LocalDateTime.now(); UserRegSaveRequest userModel; @@ -58,8 +52,5 @@ public LogoutResponseModel create(LogoutRequestModel request) throws IOException } userGateway.save(userModel); - - LogoutResponseModel accResponseModel = new LogoutResponseModel(user.getName(), now.toString()); - return userPresenter.prepareSuccessView(accResponseModel); } } diff --git a/src/main/java/use_cases/login_registration/user_register_usecase/UserRegInteractor.java b/src/main/java/use_cases/login_registration/user_register_usecase/UserRegInteractor.java index 2050604..e730a2e 100644 --- a/src/main/java/use_cases/login_registration/user_register_usecase/UserRegInteractor.java +++ b/src/main/java/use_cases/login_registration/user_register_usecase/UserRegInteractor.java @@ -52,13 +52,10 @@ public UserRegResponse create(UserRegRequest request) throws IOException { if (request.getTypeOfUser().equals("Instructor")) { this.user = userFactory.createInstructor(request.getName(), request.getPassword()); - } else //if (request.getTypeOfUser().equals("Student")) + } else // initialize a StudentUser { this.user = userFactory.createStudent(request.getName(), request.getPassword()); } -// else { -// this.user = null; -// } if (!user.checkPassword()) { return userPresenter.prepareFailView("Password must be at least 9 characters long"); diff --git a/src/test/java/logout_usecase/LogoutInteractorTest.java b/src/test/java/logout_usecase/LogoutInteractorTest.java index be88ba4..b34f6e5 100644 --- a/src/test/java/logout_usecase/LogoutInteractorTest.java +++ b/src/test/java/logout_usecase/LogoutInteractorTest.java @@ -43,14 +43,10 @@ public LogoutResponseModel prepareFailView(String error) { }; User u = new InstructorUser("paul", "123456789"); - LogoutInputBoundary interactor = new LogoutInteractor(userRepository, presenter, u); - - // 2) Input data — we can make this up for the test. Normally it would - // be created by the Controller. - LogoutRequestModel request = new LogoutRequestModel(); + LogoutInputBoundary interactor = new LogoutInteractor(userRepository); // 3) Run the use case - interactor.create(request); + interactor.create(); // was the user saved after logout? assert ((InMemoryUser) userRepository).existsByName("paul"); From b96197d4623b147e67fa0b5897a51b6881d79724 Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Fri, 2 Dec 2022 20:26:58 -0500 Subject: [PATCH 5/9] changed logout interactor test to suit changes --- .../logout_usecase/LogoutInteractorTest.java | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/test/java/logout_usecase/LogoutInteractorTest.java b/src/test/java/logout_usecase/LogoutInteractorTest.java index b34f6e5..f80acaf 100644 --- a/src/test/java/logout_usecase/LogoutInteractorTest.java +++ b/src/test/java/logout_usecase/LogoutInteractorTest.java @@ -1,9 +1,6 @@ package logout_usecase; -import entities.GeneralUserFactory; -import entities.InstructorUser; -import entities.User; -import entities.UserFactory; +import entities.*; import org.junit.jupiter.api.Test; import screens.login_registration.InMemoryUser; import screens.login_registration.LogoutResponseFormatter; @@ -23,26 +20,8 @@ void create() throws IOException { LogoutGateway userRepository = new InMemoryUser(); - // This creates an anonymous implementing class for the Output Boundary. - LogoutPresenter presenter = new LogoutResponseFormatter() { - - @Override - public LogoutResponseModel prepareSuccessView(LogoutResponseModel logout) { - // 4) Check that the Output Data and associated changes - // are correct - assertEquals("paul", logout.getName()); - assertNotNull(logout.getLogoutTime()); // any creation time is fine. - return null; - } - - public LogoutResponseModel prepareFailView(String error) { - fail("Use case failure is unexpected."); - return null; - } - - }; - User u = new InstructorUser("paul", "123456789"); + CurrentUser.setCurrentUser(u); LogoutInputBoundary interactor = new LogoutInteractor(userRepository); // 3) Run the use case From 346afbf2d115021ac5adcbc808f96d382954fe67 Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Fri, 2 Dec 2022 20:37:22 -0500 Subject: [PATCH 6/9] removed unused imports, etc. to fix checks --- .../screens/login_registration/LoginScreen.java | 6 ------ .../login_registration/LogoutController.java | 2 -- .../LogoutResponseFormatter.java | 17 ----------------- .../login_registration/RegisterScreen.java | 14 -------------- .../logout_usecase/LogoutInputBoundary.java | 2 +- .../logout_usecase/LogoutRequestModel.java | 4 ---- .../logout_usecase/LogoutResponseModel.java | 8 -------- .../logout_usecase/LogoutInteractorTest.java | 13 ++++--------- 8 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 src/main/java/screens/login_registration/LogoutResponseFormatter.java delete mode 100644 src/main/java/use_cases/login_registration/logout_usecase/LogoutRequestModel.java diff --git a/src/main/java/screens/login_registration/LoginScreen.java b/src/main/java/screens/login_registration/LoginScreen.java index b9afac1..777d9e1 100644 --- a/src/main/java/screens/login_registration/LoginScreen.java +++ b/src/main/java/screens/login_registration/LoginScreen.java @@ -49,17 +49,11 @@ public LoginScreen(LoginController controller, CardLayout cardLayout, JPanel scr logIn.addActionListener(this); cancel.addActionListener(this); -// JPanel main = new JPanel(); -// main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS)); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); -// this.add(title); this.add(usernameInfo); this.add(passwordInfo); this.add(buttons); -// this.setContentPane(main); -// -// this.pack(); } /** diff --git a/src/main/java/screens/login_registration/LogoutController.java b/src/main/java/screens/login_registration/LogoutController.java index 67609bc..8e82009 100644 --- a/src/main/java/screens/login_registration/LogoutController.java +++ b/src/main/java/screens/login_registration/LogoutController.java @@ -1,8 +1,6 @@ package screens.login_registration; import use_cases.login_registration.logout_usecase.LogoutInputBoundary; -import use_cases.login_registration.logout_usecase.LogoutRequestModel; -import use_cases.login_registration.logout_usecase.LogoutResponseModel; import java.io.IOException; diff --git a/src/main/java/screens/login_registration/LogoutResponseFormatter.java b/src/main/java/screens/login_registration/LogoutResponseFormatter.java deleted file mode 100644 index c625e26..0000000 --- a/src/main/java/screens/login_registration/LogoutResponseFormatter.java +++ /dev/null @@ -1,17 +0,0 @@ -package screens.login_registration; - -import use_cases.login_registration.logout_usecase.LogoutPresenter; -import use_cases.login_registration.logout_usecase.LogoutResponseModel; - -public class LogoutResponseFormatter implements LogoutPresenter { - - /** - * @param logout the logout response - * @return the successful logout view - */ - @Override - public LogoutResponseModel prepareSuccessView(LogoutResponseModel logout) { - return logout; - } - -} diff --git a/src/main/java/screens/login_registration/RegisterScreen.java b/src/main/java/screens/login_registration/RegisterScreen.java index 91c532b..06ec28b 100644 --- a/src/main/java/screens/login_registration/RegisterScreen.java +++ b/src/main/java/screens/login_registration/RegisterScreen.java @@ -53,10 +53,6 @@ public RegisterScreen(UserRegController controller, CardLayout cardLayout, JPane JLabel title = new JLabel("Register Screen"); title.setAlignmentX(Component.CENTER_ALIGNMENT); -// JPanel userButtons = new JPanel(); -// userButtons.add(instructor); -// userButtons.add(student); - LabelTextPanel usernameInfo = new LabelTextPanel( new JLabel("Choose username"), username); LabelTextPanel passwordInfo = new LabelTextPanel( @@ -65,8 +61,6 @@ public RegisterScreen(UserRegController controller, CardLayout cardLayout, JPane new JLabel("Enter password again"), repeatPassword); LabelTextPanel chooseTypeOfUser = new LabelTextPanel( new JLabel("I am a (type 'Instructor' or 'Student')") , typeOfUser); -// JLabel chooseTypeOfUser = new JLabel("I am a:"); -// userButtons.add(chooseTypeOfUser); JButton signUp = new JButton("Sign up"); JButton cancel = new JButton("Cancel"); @@ -75,11 +69,8 @@ public RegisterScreen(UserRegController controller, CardLayout cardLayout, JPane buttons.add(signUp); buttons.add(cancel); -// typeOfUser.addActionListener(this); signUp.addActionListener(this); cancel.addActionListener(this); -// instructor.addActionListener(this); -// student.addActionListener(this); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); @@ -89,13 +80,8 @@ public RegisterScreen(UserRegController controller, CardLayout cardLayout, JPane this.add(repeatPasswordInfo); this.add(chooseTypeOfUser); this.add(buttons); -// this.add(userButtons); - } -// private void add(LabelTextPanel usernameInfo) { -// } - /** * React to a button click that results in event. */ diff --git a/src/main/java/use_cases/login_registration/logout_usecase/LogoutInputBoundary.java b/src/main/java/use_cases/login_registration/logout_usecase/LogoutInputBoundary.java index 393ce4e..ef5b3d0 100644 --- a/src/main/java/use_cases/login_registration/logout_usecase/LogoutInputBoundary.java +++ b/src/main/java/use_cases/login_registration/logout_usecase/LogoutInputBoundary.java @@ -5,7 +5,7 @@ public interface LogoutInputBoundary { /** Save a User's information into the database before they log out - * @throws IOException + * @throws IOException if saving not successful */ void create() throws IOException; } diff --git a/src/main/java/use_cases/login_registration/logout_usecase/LogoutRequestModel.java b/src/main/java/use_cases/login_registration/logout_usecase/LogoutRequestModel.java deleted file mode 100644 index 7fbeeb2..0000000 --- a/src/main/java/use_cases/login_registration/logout_usecase/LogoutRequestModel.java +++ /dev/null @@ -1,4 +0,0 @@ -package use_cases.login_registration.logout_usecase; - -public class LogoutRequestModel { -} diff --git a/src/main/java/use_cases/login_registration/logout_usecase/LogoutResponseModel.java b/src/main/java/use_cases/login_registration/logout_usecase/LogoutResponseModel.java index 02129bc..2b9cb07 100644 --- a/src/main/java/use_cases/login_registration/logout_usecase/LogoutResponseModel.java +++ b/src/main/java/use_cases/login_registration/logout_usecase/LogoutResponseModel.java @@ -22,12 +22,4 @@ public LogoutResponseModel(String name, String timeOfLogout) { public void setName(String username) { this.name = username; } - public String getLogoutTime() { - return logoutTime; - } - - public void setLogoutTime(String TimeOfLogout) { - this.logoutTime = TimeOfLogout; - } - } diff --git a/src/test/java/logout_usecase/LogoutInteractorTest.java b/src/test/java/logout_usecase/LogoutInteractorTest.java index f80acaf..c797386 100644 --- a/src/test/java/logout_usecase/LogoutInteractorTest.java +++ b/src/test/java/logout_usecase/LogoutInteractorTest.java @@ -3,31 +3,26 @@ import entities.*; import org.junit.jupiter.api.Test; import screens.login_registration.InMemoryUser; -import screens.login_registration.LogoutResponseFormatter; -import screens.login_registration.UserRegResponseFormatter; import use_cases.login_registration.logout_usecase.*; -import use_cases.login_registration.user_register_usecase.*; import java.io.IOException; -import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.fail; - public class LogoutInteractorTest { @Test void create() throws IOException { - LogoutGateway userRepository = new InMemoryUser(); + InMemoryUser userRepository = new InMemoryUser(); - User u = new InstructorUser("paul", "123456789"); + User u = new InstructorUser("jallope", "123456789"); CurrentUser.setCurrentUser(u); + LogoutInputBoundary interactor = new LogoutInteractor(userRepository); // 3) Run the use case interactor.create(); // was the user saved after logout? - assert ((InMemoryUser) userRepository).existsByName("paul"); + assert userRepository.existsByName("jallope"); } } From d3cc55de8c76a1dd40791dd8ed6df2634c29a8e4 Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Fri, 2 Dec 2022 21:20:25 -0500 Subject: [PATCH 7/9] commented out parts that still pull user from main and into their interactors (please change these to use CurrentUser) --- src/main/java/Main.java | 62 +++++++++++++++++------------------ src/main/java/data/users.ser | Bin 1272 -> 1272 bytes 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index f2c4943..0f6cb62 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -58,31 +58,31 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio // initialize User based on whether they log in or register // if you don't register, then you are logging in: - User user; - if ((((UserRegInteractor) userInteractor).getUser() instanceof StudentUser) | - (((UserRegInteractor) userInteractor).getUser() instanceof InstructorUser)) { - user = ((UserRegInteractor) userInteractor).getUser(); - } else { - user = ((LoginInteractor) loginInteractor).getUser(); - } +// User user; +// if ((((UserRegInteractor) userInteractor).getUser() instanceof StudentUser) | +// (((UserRegInteractor) userInteractor).getUser() instanceof InstructorUser)) { +// user = ((UserRegInteractor) userInteractor).getUser(); +// } else { +// user = ((LoginInteractor) loginInteractor).getUser(); +// } SchedulerPresenter schedulerPresenter = new SchedulerResponseFormatter(); ScheduleConflictPresenter scheduleConflictPresenter = new ScheduleConflictResponseFormatter(); - EventCreationPresenter eventPresenter = new EventCreationResponseFormatter(); - EventCreationInputBoundary eventInteractor = new EventCreationInteractor(eventPresenter, (StudentUser) user, - schedulerPresenter, scheduleConflictPresenter); - EventCreationController eventCreationController = new EventCreationController(eventInteractor); - - ProgressTrackerOutputBoundary trackerPresenter = new ProgressTrackerPresenter(); - ProgressTrackerInputBoundary trackerInteractor = new ProgressTrackerInteractor(trackerPresenter); - ProgressTrackerController trackerController = new ProgressTrackerController(trackerInteractor, user, "", allTasks, allUsers, allCourses); - - ScheduleCTViewInterface presentOutputInterface = new ScheduleCTView(cardLayout, screens); - ScheduleCTOutputBoundary scheduleCTOutputBoundary = new ScheduleCTPresenter(presentOutputInterface); - ScheduleCTInputBoundary scheduleCTInputBoundary = new ScheduleCTInteractor(scheduleCTOutputBoundary); - ScheduleCTController scheduleCTController = new ScheduleCTController(scheduleCTInputBoundary, allTasks, (StudentUser) user); +// EventCreationPresenter eventPresenter = new EventCreationResponseFormatter(); +// EventCreationInputBoundary eventInteractor = new EventCreationInteractor(eventPresenter, (StudentUser) user, +// schedulerPresenter, scheduleConflictPresenter); +// EventCreationController eventCreationController = new EventCreationController(eventInteractor); +// +// ProgressTrackerOutputBoundary trackerPresenter = new ProgressTrackerPresenter(); +// ProgressTrackerInputBoundary trackerInteractor = new ProgressTrackerInteractor(trackerPresenter); +// ProgressTrackerController trackerController = new ProgressTrackerController(trackerInteractor, user, "", allTasks, allUsers, allCourses); +// +// ScheduleCTViewInterface presentOutputInterface = new ScheduleCTView(cardLayout, screens); +// ScheduleCTOutputBoundary scheduleCTOutputBoundary = new ScheduleCTPresenter(presentOutputInterface); +// ScheduleCTInputBoundary scheduleCTInputBoundary = new ScheduleCTInteractor(scheduleCTOutputBoundary); +// ScheduleCTController scheduleCTController = new ScheduleCTController(scheduleCTInputBoundary, allTasks, (StudentUser) user); CourseCreationDsGateway course; try { @@ -102,17 +102,17 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio // // Build the GUI - EventCreationScreen taskScreen = new EventCreationScreen(eventCreationController, screens, cardLayout); - screens.add("toDoList", taskScreen); - - CalendarScreen calendarScreen = new CalendarScreen((StudentUser) user, allTasks, screens, cardLayout); - screens.add("calendar", calendarScreen); - - ScheduleCTScreen scheduleCTScreen = new ScheduleCTScreen(scheduleCTController, screens, cardLayout); - screens.add("scheduleCT", scheduleCTScreen); - - ProgressTrackerScreen progressTrackerScreen = new ProgressTrackerScreen(trackerController); - screens.add("tracker", progressTrackerScreen); +// EventCreationScreen taskScreen = new EventCreationScreen(eventCreationController, screens, cardLayout); +// screens.add("toDoList", taskScreen); +// +// CalendarScreen calendarScreen = new CalendarScreen((StudentUser) user, allTasks, screens, cardLayout); +// screens.add("calendar", calendarScreen); +// +// ScheduleCTScreen scheduleCTScreen = new ScheduleCTScreen(scheduleCTController, screens, cardLayout); +// screens.add("scheduleCT", scheduleCTScreen); +// +// ProgressTrackerScreen progressTrackerScreen = new ProgressTrackerScreen(trackerController); +// screens.add("tracker", progressTrackerScreen); CourseCreationScreen courseCreationScreen = new CourseCreationScreen(courseCreationController, screens, cardLayout); screens.add("course", courseCreationScreen); diff --git a/src/main/java/data/users.ser b/src/main/java/data/users.ser index fcbfbba557f5b969ff62c78d3028e15596fb09f5..47fa50d4c7323f5089dc89b539b2249d184f21d7 100644 GIT binary patch delta 20 ccmeyt`Ga#q028|?uPML5f;F4NnHDku07`%cod5s; delta 20 bcmeyt`Ga#q028~2ge+%F@tMuxObeL+N~{K` From 88eb1f676aa5a0afa5605d437279fe3b09a28b5c Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Fri, 2 Dec 2022 23:21:02 -0500 Subject: [PATCH 8/9] got rid of unnecessary lines in main (the lines 60-62 part) and commented out the parts that don't work because they require a user to be initialized --- src/main/java/Main.java | 11 ----------- src/main/java/data/users.ser | Bin 1272 -> 1272 bytes src/test/java/data/userstest.ser | Bin 1304 -> 1304 bytes 3 files changed, 11 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 0f6cb62..647e379 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -54,17 +54,6 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio LoginPresenter loginPresenter = new LoginResponseFormatter(); LoginInputBoundary loginInteractor = new LoginInteractor(loginUser, loginPresenter); LoginController loginController = new LoginController(loginInteractor); - // - - // initialize User based on whether they log in or register - // if you don't register, then you are logging in: -// User user; -// if ((((UserRegInteractor) userInteractor).getUser() instanceof StudentUser) | -// (((UserRegInteractor) userInteractor).getUser() instanceof InstructorUser)) { -// user = ((UserRegInteractor) userInteractor).getUser(); -// } else { -// user = ((LoginInteractor) loginInteractor).getUser(); -// } SchedulerPresenter schedulerPresenter = new SchedulerResponseFormatter(); diff --git a/src/main/java/data/users.ser b/src/main/java/data/users.ser index 47fa50d4c7323f5089dc89b539b2249d184f21d7..af552fa7d7582f07dc442596ce2e90a5846b9a21 100644 GIT binary patch delta 20 bcmeyt`Ga#q028~o2n!?c)rigEObeL+M&Je| delta 20 ccmeyt`Ga#q028|?uPML5f;F4NnHDku07`%cod5s; diff --git a/src/test/java/data/userstest.ser b/src/test/java/data/userstest.ser index 4adea51d75d1eb0833fed45216c949ed6987c094..cf350da4b900db982da0c29697e808aea341cbd0 100644 GIT binary patch delta 56 zcmbQiHG^xzHAZ%EVRg$TY(F;NWo(CYCTBBm1xZ-^obhC`I?E;y+tmLA$K(er762C! B643wv delta 56 zcmbQiHG^xzHAZ$mX*MzT?Nc`2Wo(CYCTBBm1xbj8)Et?t&aw%_7Vw;ZW%2_S3jozP B5Z3?z From 6e4fb9ec9dde8925d5300ec97f409df17c785b24 Mon Sep 17 00:00:00 2001 From: CC-3636 Date: Mon, 5 Dec 2022 12:29:16 -0500 Subject: [PATCH 9/9] got rid of unnecessary lines in main (the lines 60-62 part) and commented out the parts that don't work because they require a user to be initialized --- src/test/java/{ => user_register_usecase}/FileUserTest.java | 2 ++ 1 file changed, 2 insertions(+) rename src/test/java/{ => user_register_usecase}/FileUserTest.java (98%) diff --git a/src/test/java/FileUserTest.java b/src/test/java/user_register_usecase/FileUserTest.java similarity index 98% rename from src/test/java/FileUserTest.java rename to src/test/java/user_register_usecase/FileUserTest.java index f25e628..fb24a4d 100644 --- a/src/test/java/FileUserTest.java +++ b/src/test/java/user_register_usecase/FileUserTest.java @@ -1,3 +1,5 @@ +package user_register_usecase; + import entities.InstructorUser; import entities.StudentUser; import org.junit.jupiter.api.Test;