aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-03-17 16:12:56 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-03-17 16:12:56 -0400
commitebccd8c4bddc9799e91a3149040efb4cac647c45 (patch)
tree0ea4dbb616005cc833b7e877bc56eaed412f163d /ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java
parent60dd2db634de6146671be9546fb3e4bdf6d9b7d9 (diff)
parent251f30c402700169213ed4560a7797a785a50e78 (diff)
downloadJellySolutions-ebccd8c4bddc9799e91a3149040efb4cac647c45.tar.gz
JellySolutions-ebccd8c4bddc9799e91a3149040efb4cac647c45.tar.bz2
JellySolutions-ebccd8c4bddc9799e91a3149040efb4cac647c45.zip
Merge branch 'service-tests' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b into service-tests
Diffstat (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java')
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/controller/UserControllerTest.java32
1 files changed, 8 insertions, 24 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 a25ec8a..7bedd3e 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
@@ -44,9 +44,9 @@ 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();
- // When the same id is passed in, our mock User service will return the User object
+ 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);
@@ -112,7 +112,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);
@@ -183,7 +183,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
@@ -201,7 +201,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
@@ -218,25 +218,9 @@ public class UserControllerTest {
public void testUpdateUserInvalidParameter() throws IOException { // updateUser may throw IOException
// Setup
String username = "Test";
- User user = new User("Bob");
- String key = UserAuth.generate(username).getKey();
- // When updateUser is called on the Mock User service, throw a Invalid Parameter exception
- doThrow(new InvalidParameterException()).when(mockUserService).updateUser(user, username);
-
- // Invoke
- ResponseEntity<User> response = userController.updateUser(user, username, key);
-
- // Analyze
- assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
- }
-
- @Test
- 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 service, throw an IOException
+ // When updateUser is called on the Mock User DAO, throw an IOException
doThrow(new IOException()).when(mockUserService).updateUser(user, username);
// Invoke