Skip to content
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e71f7da
Minor Changes, just added some of the objects which I will implement …
Madhavan7 Nov 9, 2022
26632a1
Added a few methods, pending implementation
Madhavan7 Nov 10, 2022
0b25139
Added the required objects and wrote some code
Madhavan7 Nov 12, 2022
cb07aea
Wrote some code for the UI
Madhavan7 Nov 12, 2022
33eab38
Almost done implementation of UserRegistrationUI and UserVerificationUI
Madhavan7 Nov 12, 2022
b8f86ab
Minor changes
Madhavan7 Nov 12, 2022
e4efd7e
added changes made to another branch and brought it here
Madhavan7 Nov 13, 2022
5c4b5c9
added changes made to another branch and resolved conflicts
Madhavan7 Nov 13, 2022
bf8afc7
Made changes to UserRegistrationUI and UserVerificationUI the only is…
Madhavan7 Nov 13, 2022
a2a33b7
When tested using "TestUserDatabase3.csv" everything seems to work
Madhavan7 Nov 13, 2022
f837d19
Used Factory design pattern to change the method "sendVerificationCod…
Madhavan7 Nov 14, 2022
9c471f0
Figured out and corrected the bug in UserDatabase.createUser now its …
Madhavan7 Nov 17, 2022
776765e
Made changes to the gradle dependencies in order to facilitate email …
Madhavan7 Nov 17, 2022
f19fb12
Packaged all the files
Madhavan7 Nov 17, 2022
2f00f3a
There was design problems with user verification, so I changed the de…
Madhavan7 Nov 18, 2022
45271e7
Implemented Email verification
Madhavan7 Nov 19, 2022
bf563b5
Changed the Packaging Structure
Madhavan7 Nov 20, 2022
bbd6f94
Minor Changes
Madhavan7 Nov 20, 2022
73d358a
Merge branch 'main' into 9-feature-1-user-registration
Madhavan7 Nov 21, 2022
1007a1e
Minor Changes
Madhavan7 Nov 21, 2022
1da907a
Minor Changes
Madhavan7 Nov 21, 2022
705b6c9
Minor Changes
Madhavan7 Nov 21, 2022
6e91e27
Minor Changes
Madhavan7 Nov 21, 2022
a86bb7d
Merged conflicts from the main branch
Madhavan7 Nov 29, 2022
a6d0b75
Merged conflicts from the main branch
Madhavan7 Nov 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS entities.userEntities.User-specific
.idea/**/aws.xml

Expand Down
Binary file added javax.mail.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package entities.userEntities;
package Entities.user_entities;

public class BasicUser extends User{
public class BasicUser extends User {
public BasicUser(String Username, String Password, String Email){
super(Username, Password, Email);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
package entities.userEntities;

import interface_adapters.User.*;

package Entities.user_entities;
import UseCase.Changeable;
import java.io.Serializable;
import java.util.ArrayList;

public abstract class User implements Serializable, Changeable, UserAuthenticationI {
public abstract class User implements Serializable, Changeable {
protected String username;
protected String password;
protected String email;
boolean verified = false;
boolean online = false;
// protected ArrayList<Chat> chats;
public User(String username, String password, String email){
this.username = username;
this.password = password;
this.email = email;
// this.chats = new ArrayList<Chat>();
}
public String getEmail(){
return this.email;
Expand All @@ -28,17 +22,8 @@ private String getPassword(){
return this.password;
}

// public ArrayList<Chat> getChats() {
// return this.chats;
// }

@Override
public Boolean PasswordMatch(String attempt){
return (this.getPassword().equals(attempt));
}

@Override
// from interface_adapters.User.Changeable
// from UseCase.Changeable
public void changeFeature(String feature, String newFeature){
if (feature == "Username"){
this.username = newFeature;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
package entities.userEntities;

import entities.userEntities.BasicUser;
import entities.userEntities.User;
package Entities.user_entities;

public class UserFactory {
//Following the factory design pattern, just in case in the future we decide to add various different types of Users
Expand Down
Empty file.
28 changes: 10 additions & 18 deletions src/main/java/data_access/UserDatabase.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package data_access;

import entities.userEntities.User;
import entities.userEntities.UserFactory;
import interface_adapters.IRetrieveList;
import interface_adapters.user_registration_interface_adapters.UserExists;
import entities.user_entities.User;
import entities.user_entities.UserFactory;
import use_cases.user_login_use_case.UserCreator;
import interface_adapters.UserRetriever;

import interface_adapters.Chat.ConvHistGateway;
import interface_adapters.Chat.MsgSenderGateway;
import interface_adapters.Chat.UserChatGateway;
Expand All @@ -10,6 +15,7 @@
import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway,
ConvHistGateway, MsgSenderGateway, UserChatGateway {
File accounts;
Expand Down Expand Up @@ -41,14 +47,9 @@ public boolean UserExists(String username, String email) {

@Override
public boolean UserExists(String username) {
for(User user: this.accountList){
if(user.getUsername().equals(username)){
return true;
}
}
return false;
return UserExists(username, "");
}

// Creates a new user with a username and password, and an email address
// The order is username, password, email address, verification status, status
//
Expand Down Expand Up @@ -89,14 +90,6 @@ public List<User> getList() {
ObjectInputStream in = new ObjectInputStream(fileIn)) {

users = (ArrayList<User>) in.readObject();
/*
while(true){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is correct to delete this while loop since it is not necessary

try{
entities.userEntities.User user = (entities.userEntities.User) in.readObject();
users.add(user);}
catch(EOFException e){
break;
}*/
return users;
}catch(EOFException e){
return users;
Expand Down Expand Up @@ -172,5 +165,4 @@ public void modifyUser(String oldUsername, User modified){
// }
// throw new RuntimeException("Invalid username: user does not exist");
// }

}
3 changes: 1 addition & 2 deletions src/main/java/entities/user_entities/BasicUser.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package entities.user_entities;

import entities.user_entities.User;
public class BasicUser extends User{
public class BasicUser extends User {
public BasicUser(String Username, String Password, String Email){
super(Username, Password, Email);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/entities/user_entities/User.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package entities.user_entities;

import use_cases.user_attribute_modification_use_case.Changeable;

import java.io.Serializable;
Expand All @@ -25,7 +24,7 @@ private String getPassword(){
}

@Override
// from Changeable
// from UseCase.Changeable
public void changeFeature(String feature, String newFeature){
if (feature == "Username"){
this.username = newFeature;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/interface_adapters/User/IRetrieveList.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package interface_adapters.User;

import entities.userEntities.User;
import entities.user_entities.User;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package interface_adapters.User;

import entities.userEntities.User;
import entities.user_entities.User;

// allows for the serialized data_access.UserDatabase to update when changes occur to user attributes.
public interface UserModificationGateway {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/interface_adapters/User/UserRetriever.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package interface_adapters.User;

import entities.userEntities.User;
import entities.user_entities.User;

public interface UserRetriever {
User getUser(String username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

public interface UserExists {
boolean UserExists(String username, String password);
boolean UserExists(String username);
}
3 changes: 1 addition & 2 deletions src/main/java/screens/Profile_screen/UserSearchUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
* Provides the UI elements
*/
import data_access.UserDatabase;
import entities.userEntities.User;
import entities.user_entities.User;
import interface_adapters.User_search_IA.UserPresenter;
import use_cases.user_profile_display_use_case.UserReader;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;


public class UserSearchUI implements UserPresenter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Provides the UI elements
*/
import data_access.UserDatabase;
import entities.userEntities.User;
import entities.user_entities.User;
import interface_adapters.profile_modification_IA.ChangeController;

import javax.swing.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package use_cases.chat_initiation_use_case;


import data_access.UserDatabase;

/**
* CheckUsernameInteractor responsible checking if a username exist in our userdata base
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package use_cases.user_profile_display_use_case;

import entities.userEntities.User;

import java.io.File;
import entities.user_entities.User;

public class UserReader {
public String[] UserReader(User user) {
Expand Down
Empty file.
15 changes: 8 additions & 7 deletions src/test/java/UserDatabaseTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import entities.user_entities.User;
import data_access.UserDatabase;
import entities.userEntities.User;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand All @@ -9,44 +9,45 @@
public class UserDatabaseTest {
@Test
public void addingFilesRightEmailAndUser(){
File accounts = new File("data_access/TestUserDatabase2.csv");
File accounts = new File("Test3");
UserDatabase accountDatabase = new UserDatabase(accounts);
accountDatabase.createUser("MadhavGopakumar", "123", "[email protected]", "Basic");
Assertions.assertTrue(accountDatabase.UserExists("MadhavGopakumar", "[email protected]"));
}
@Test
public void addingMultipleFiles(){
File accounts = new File("data_access/TestUserDatabase2.csv");
File accounts = new File("Test3");
UserDatabase accountDatabase = new UserDatabase(accounts);
accountDatabase.createUser("MeenakshiGopakumar", "123", "[email protected]", "Basic");
Assertions.assertTrue(accountDatabase.UserExists("MeenakshiGopakumar", "[email protected]"));
}
@Test
public void rightEmailWrongUser(){
File accounts = new File("data_access/TestUserDatabase2.csv");
File accounts = new File("Test3");
UserDatabase accountDatabase = new UserDatabase(accounts);
accountDatabase.createUser("MadhavGopakumar", "123", "[email protected]", "Basic");
Assertions.assertTrue(accountDatabase.UserExists("MadG", "[email protected]"));
}
@Test
public void rightUserWrongEmail(){
File accounts = new File("data_access/TestUserDatabase2.csv");
File accounts = new File("Test3");
UserDatabase accountDatabase = new UserDatabase(accounts);
Assertions.assertTrue(accountDatabase.UserExists("MeenakshiGopakumar", "ma"));
}
@Test
public void listedUsers(){
File accounts = new File("data_access/TestUserDatabase2.csv");
File accounts = new File("Test3");
UserDatabase accountDatabase = new UserDatabase(accounts);
accountDatabase.createUser("MeenakshiGopakumar", "123", "[email protected]", "Basic");
List<User> lst = accountDatabase.getList();
String email = lst.get(0).getEmail();
System.out.println(email);
Assertions.assertTrue(email.equals("[email protected]"));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can do another test with edge cases that contains empty informations (e.g. "" for email)

@Test
public void userGot() {
File accounts = new File("data_access/TestUserDatabase2.csv");
File accounts = new File("Test3");
UserDatabase accountDatabase = new UserDatabase(accounts);
accountDatabase.createUser("MeenakshiGopakumar", "123", "[email protected]", "Basic");
User user = accountDatabase.getUser("MeenakshiGopakumar");
Expand Down