aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/test/java/com
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-03-17 16:08:11 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-03-17 16:08:11 -0400
commit251f30c402700169213ed4560a7797a785a50e78 (patch)
treecbc658e4de18d7f6b2c6957a352fb4bfb871c7a6 /ufund-api/src/test/java/com
parent4d9fe6c96f487d75a03e3a680cc80fa3f2ad5e4f (diff)
downloadJellySolutions-251f30c402700169213ed4560a7797a785a50e78.tar.gz
JellySolutions-251f30c402700169213ed4560a7797a785a50e78.tar.bz2
JellySolutions-251f30c402700169213ed4560a7797a785a50e78.zip
Refactoring
Diffstat (limited to 'ufund-api/src/test/java/com')
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java12
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java8
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserFileDAOTest.java8
3 files changed, 14 insertions, 14 deletions
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java
index efe639e..3f110cb 100644
--- a/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java
+++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java
@@ -37,8 +37,8 @@ public class UserControllerTest {
public void testGetUser() throws IOException { // getUser may throw IOException
// Setup
String username = "Test";
- User user = new User(username);
- String key = UserAuth.generate(username).getKey();
+ User user = User.create(username, "pass");
+ String key = UserAuth.generate(username).getKey( );
// When the same id is passed in, our mock User DAO will return the User object
when(mockUserService.getUser(username)).thenReturn(user);
@@ -89,7 +89,7 @@ public class UserControllerTest {
// Setup
String username = "Test";
String password = "Pass";
- User user = new User(username);
+ User user = User.create(username, "pass");
// when createUser is called, return true simulating successful
// creation and save
when(mockUserService.createUser(username, password)).thenReturn(user);
@@ -153,7 +153,7 @@ public class UserControllerTest {
public void testUpdateUser() throws IOException { // updateUser may throw IOException
// Setup
String username = "Test";
- User user = new User("Bob");
+ User user = User.create("Bob", "pass");
String key = UserAuth.generate(username).getKey();
// when updateUser is called, return true simulating successful
// update and save
@@ -171,7 +171,7 @@ public class UserControllerTest {
public void testUpdateUserFailed() throws IOException { // updateUser may throw IOException
// Setup
String username = "Test";
- User user = new User("Bob");
+ User user = User.create("Bob", "pass");
String key = UserAuth.generate(username).getKey();
// when updateUser is called, return true simulating successful
// update and save
@@ -188,7 +188,7 @@ public class UserControllerTest {
public void testUpdateUserHandleException() throws IOException { // updateUser may throw IOException
// Setup
String username = "Test";
- User user = new User("Bob");
+ User user = User.create("Bob", "pass");
String key = UserAuth.generate(username).getKey();
// When updateUser is called on the Mock User DAO, throw an IOException
doThrow(new IOException()).when(mockUserService).updateUser(user, username);
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java
index 1725190..5e017dd 100644
--- a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java
+++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java
@@ -13,7 +13,7 @@ public class UserTest {
String name = "Bob";
- User user = new User(name);
+ User user = User.create(name, "pass");
assertNotNull(user);
@@ -36,7 +36,7 @@ public class UserTest {
String expectedName = "Bob";
- User user = new User(expectedName);
+ User user = User.create(expectedName, "pass");
Need need = new Need("Test", 0, 100, Need.GoalType.MONETARY);
Need[] needs = { need };
@@ -51,7 +51,7 @@ public class UserTest {
String expectedName = "Bob";
- User user = new User(expectedName);
+ User user = User.create(expectedName, "pass");
Need need = new Need("Test", 0, 100, Need.GoalType.MONETARY);
Need need2 = new Need("Test2", 0, 100, Need.GoalType.MONETARY);
@@ -68,7 +68,7 @@ public class UserTest {
String expectedName = "Bob";
- User user = new User(expectedName);
+ User user = User.create(expectedName, "pass");
assertFalse(user.verifyPassword(expectedName));
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserFileDAOTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserFileDAOTest.java
index b802669..9361188 100644
--- a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserFileDAOTest.java
+++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserFileDAOTest.java
@@ -27,9 +27,9 @@ public class UserFileDAOTest {
public void setupHeroFileDAO() throws IOException {
mockObjectMapper = mock(ObjectMapper.class);
testUsers = new User[3];
- testUsers[0] = new User("bob");
- testUsers[1] = new User("admin");
- testUsers[2] = new User("jelly12");
+ testUsers[0] = User.create("bob", "pass");
+ testUsers[1] = User.create("admin", "pass");
+ testUsers[2] = User.create("jelly12", "pass");
// When the object mapper is supposed to read from the file
// the mock object mapper will return the hero array above
@@ -75,7 +75,7 @@ public class UserFileDAOTest {
@Test
public void createUserTest() throws IOException {
- User newUser = new User("keshey");
+ User newUser = User.create("keshey", "pass");
userFileDAO.addUser(newUser);
User actualUser = userFileDAO.getUser("keshey");