diff options
-rw-r--r-- | docs/CupboardPage.jpeg | bin | 0 -> 2359696 bytes | |||
-rw-r--r-- | docs/DashboardPage.jpeg | bin | 0 -> 2424408 bytes | |||
-rw-r--r-- | docs/DesignDoc.md | 24 | ||||
-rw-r--r-- | docs/FundingBasketPage.jpeg | bin | 0 -> 2508103 bytes | |||
-rw-r--r-- | docs/HomePage.jpeg | bin | 0 -> 2330104 bytes | |||
-rw-r--r-- | docs/LoginPage.jpeg | bin | 0 -> 2347376 bytes | |||
-rw-r--r-- | docs/NeedPage.jpeg | bin | 0 -> 2471361 bytes | |||
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java | 12 | ||||
-rw-r--r-- | ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java | 31 |
9 files changed, 57 insertions, 10 deletions
diff --git a/docs/CupboardPage.jpeg b/docs/CupboardPage.jpeg Binary files differnew file mode 100644 index 0000000..983563f --- /dev/null +++ b/docs/CupboardPage.jpeg diff --git a/docs/DashboardPage.jpeg b/docs/DashboardPage.jpeg Binary files differnew file mode 100644 index 0000000..48a862b --- /dev/null +++ b/docs/DashboardPage.jpeg diff --git a/docs/DesignDoc.md b/docs/DesignDoc.md index 5fda309..5d673b2 100644 --- a/docs/DesignDoc.md +++ b/docs/DesignDoc.md @@ -20,6 +20,8 @@ Our project is intended to create a space to fund aquatic conservation, from phy > _**[Sprint 2 & 4]** Provide a very brief statement about the project and the most > important user group and user goals._ + + ### Glossary and Acronyms > _**[Sprint 2 & 4]** Provide a table of terms and acronyms._ @@ -38,6 +40,7 @@ This section describes the features of the application. ### Definition of MVP > _**[Sprint 2 & 4]** Provide a simple description of the Minimum Viable Product._ + Users are able to login to the Ufund, either as a manager or helper. Helpers are able to go to the cupboard and can view needs, search for needs, add/remove needs to their funding basket, and check out and fund needs. Managers can add, remove, and edit needs in the cupboard. Needs are saved so users and managers will see when they are updated. ### MVP Features @@ -88,6 +91,25 @@ This section describes the web interface flow; this is how the user views and in > (Add low-fidelity mockups prior to initiating your **[Sprint 2]** work so you have a good idea of the user interactions.) Eventually replace with representative screen shots of your high-fidelity results as these become available and finally include future recommendations improvement recommendations for your **[Sprint 4]** )_ +Home Page: + + +Login Page: + + +Dashboard: + + +Cupboard: + + +Need page: + + +Funding basket: + + + ### View Tier > _**[Sprint 4]** Provide a summary of the View Tier UI of your architecture. > Describe the types of components in the tier and describe their @@ -129,6 +151,8 @@ The Model Tier contains the classes responsible for handling and serving Need da > section will follow the same instructions that are given for the View > Tier above._ +In our model tier we have a Need class, a User class, and a UserAuth class. The Need class represents needs and has fields for all of their values. Users have a passwordHash field, storing a hashed version of their password, an List of integers, representing the ID's of needs in the basket, and the userType which determines their privileges. The UserAuth class stores a key, a username, and expiration. A key is generated for a user and is used to authenticate the user. The username is the name associated with the key and the expiration is how long until the user must login again. + > _At appropriate places as part of this narrative provide **one** or more updated and **properly labeled** > static models (UML class diagrams) with some details such as associations (connections) between classes, and critical attributes and methods. (**Be sure** to revisit the Static **UML Review Sheet** to ensure your class diagrams are using correct format and syntax.)_ > diff --git a/docs/FundingBasketPage.jpeg b/docs/FundingBasketPage.jpeg Binary files differnew file mode 100644 index 0000000..733d332 --- /dev/null +++ b/docs/FundingBasketPage.jpeg diff --git a/docs/HomePage.jpeg b/docs/HomePage.jpeg Binary files differnew file mode 100644 index 0000000..f747f0f --- /dev/null +++ b/docs/HomePage.jpeg diff --git a/docs/LoginPage.jpeg b/docs/LoginPage.jpeg Binary files differnew file mode 100644 index 0000000..00ef5af --- /dev/null +++ b/docs/LoginPage.jpeg diff --git a/docs/NeedPage.jpeg b/docs/NeedPage.jpeg Binary files differnew file mode 100644 index 0000000..8ffec79 --- /dev/null +++ b/docs/NeedPage.jpeg diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java index 61293b9..f08f9f0 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/User.java @@ -14,7 +14,7 @@ public class User { @JsonProperty("username") private final String username; @JsonProperty("passwordHash") private int passwordHash; - @JsonProperty("basket") private final List<Need> basket; + @JsonProperty("basket") private final List<Integer> basket; @JsonProperty("type") private final UserType type; /** @@ -23,7 +23,7 @@ public class User { * @param username The name of the user * @param basket A basket to copy from */ - public User(@JsonProperty("username") String username, @JsonProperty("passwordHash") int passwordHash, @JsonProperty("basket") List<Need> basket, @JsonProperty("type") UserType userType) { + public User(@JsonProperty("username") String username, @JsonProperty("passwordHash") int passwordHash, @JsonProperty("basket") List<Integer> basket, @JsonProperty("type") UserType userType) { this.username = username; this.basket = basket; this.passwordHash = passwordHash; @@ -48,15 +48,15 @@ public class User { } public void addToBasket(Need need) { - basket.add(need); + basket.add(need.getId()); } - public Need[] getBasketNeeds() { - return basket.toArray(Need[]::new); + public Integer[] getBasketNeeds() { + return basket.toArray(Integer[]::new); } public void removeBasketNeed(Need need) { - basket.remove(need); + basket.remove(need.getId()); } public User withoutPasswordHash() { 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 5e017dd..54aa4d1 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 @@ -4,10 +4,25 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.mock; + +import java.io.IOException; + +import org.junit.jupiter.api.BeforeEach; +import static org.mockito.Mockito.when; + +import com.ufund.api.ufundapi.service.CupboardService; @Tag("Model-tier") public class UserTest { + private CupboardService cupboardService; + + @BeforeEach + public void setup() { + cupboardService = mock(CupboardService.class); + } + @Test public void createUser() { @@ -32,7 +47,7 @@ public class UserTest { } @Test - public void addNeedToBasket() { + public void addNeedToBasket() throws IOException { String expectedName = "Bob"; @@ -40,14 +55,18 @@ public class UserTest { Need need = new Need("Test", 0, 100, Need.GoalType.MONETARY); Need[] needs = { need }; + when(cupboardService.getNeed(0)).thenReturn(need); + user.addToBasket(need); - assertEquals(needs[0], user.getBasketNeeds()[0]); + Need getNeed = cupboardService.getNeed(user.getBasketNeeds()[0]); + + assertEquals(needs[0], getNeed); } @Test - public void testRemoveBasketNeed() { + public void testRemoveBasketNeed() throws IOException { String expectedName = "Bob"; @@ -55,11 +74,15 @@ public class UserTest { Need need = new Need("Test", 0, 100, Need.GoalType.MONETARY); Need need2 = new Need("Test2", 0, 100, Need.GoalType.MONETARY); + when(cupboardService.getNeed(0)).thenReturn(need2); + user.addToBasket(need); user.removeBasketNeed(need); user.addToBasket(need2); - assertEquals(need2, user.getBasketNeeds()[0]); + Need getNeed = cupboardService.getNeed(user.getBasketNeeds()[0]); + + assertEquals(need2, getNeed); } |