aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/test/java/com/ufund/api/ufundapi/model
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/model')
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java49
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java41
2 files changed, 72 insertions, 18 deletions
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java
index 50b5cf2..6b4ddfc 100644
--- a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java
+++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java
@@ -14,13 +14,10 @@ public class NeedTest {
public void createNeed() {
String name = "Jellyfish";
- int id = 0;
double maxGoal = 100.00;
GoalType type = GoalType.MONETARY;
- Need need = new Need(name, id, maxGoal, type);
-
+ Need need = new Need(name, type, maxGoal);
assertNotNull(need);
-
}
@Test
@@ -29,7 +26,7 @@ public class NeedTest {
int id = 0;
double maxGoal = 100.00;
GoalType type = GoalType.MONETARY;
- Need need = new Need(name, id, maxGoal, type);
+ Need need = new Need(name, type, maxGoal);
assertEquals(name, need.getName());
@@ -41,32 +38,31 @@ public class NeedTest {
@Test
public void testCurrentGoal() {
String name = "Jellyfish";
- int id = 0;
double maxGoal = 100.00;
GoalType type = GoalType.MONETARY;
- Need need = new Need(name, id, maxGoal, type);
+ Need need = new Need(name, type, maxGoal);
double current = 0.00;
need.setCurrent(current);
- assertEquals(need.getCurrent(), current);
+ assertEquals(current, need.getCurrent());
current = 100.00;
need.setCurrent(current);
- assertEquals(need.getCurrent(), current);
+ assertEquals(current, need.getCurrent());
current = -100.00;
need.setCurrent(current);
- assertEquals(need.getCurrent(), current);
+ assertEquals(current, need.getCurrent());
}
+
@Test
public void testFilterAttributes() {
String name = "Jellyfish";
- int id = 0;
double maxGoal = 100.00;
GoalType type = GoalType.MONETARY;
- Need need = new Need(name, id, maxGoal, type);
+ Need need = new Need(name, type, maxGoal);
String[] filterAttributes = {"seaweed", "divers", "pacific", "plankton"};
@@ -75,4 +71,33 @@ public class NeedTest {
assertEquals(need.getFilterAttributes(), filterAttributes);
}
+ @Test
+ public void testSetMaxGoal() {
+
+ String name = "Jellyfish";
+ double maxGoal = 100.00;
+ GoalType type = GoalType.MONETARY;
+ Need need = new Need(name, type, maxGoal);
+
+ double newGoal = 200.00;
+ need.setMaxGoal(newGoal);
+
+
+ assertEquals(newGoal, need.getMaxGoal());
+ }
+
+ @Test
+ public void testSetName() {
+
+ String name = "Jellyfish";
+ double maxGoal = 100.00;
+ GoalType type = GoalType.MONETARY;
+ Need need = new Need(name, type, maxGoal);
+
+ String newName = "TESTINGFUN";
+ need.setName(newName);
+
+ assertEquals(newName, need.getName());
+ }
+
}
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 8b8dd99..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
@@ -1,10 +1,10 @@
package com.ufund.api.ufundapi.model;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
@Tag("Model-tier")
public class UserTest {
@@ -13,7 +13,7 @@ public class UserTest {
String name = "Bob";
- User user = new User(name);
+ User user = User.create(name, "pass");
assertNotNull(user);
@@ -23,10 +23,11 @@ public class UserTest {
public void testUsername() {
String expectedName = "Bob";
+ String password = "password";
- User user = new User(expectedName);
+ User user = User.create(expectedName, password);
- assertEquals(expectedName, user.getName());
+ assertEquals(expectedName, user.getUsername());
}
@@ -35,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 };
@@ -45,4 +46,32 @@ public class UserTest {
}
+ @Test
+ public void testRemoveBasketNeed() {
+
+ String expectedName = "Bob";
+
+ 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);
+
+ user.addToBasket(need);
+ user.removeBasketNeed(need);
+ user.addToBasket(need2);
+
+ assertEquals(need2, user.getBasketNeeds()[0]);
+
+ }
+
+ @Test
+ public void testVerifyPassword() {
+
+ String expectedName = "Bob";
+
+ User user = User.create(expectedName, "pass");
+
+ assertFalse(user.verifyPassword(expectedName));
+
+ }
+
}