diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-03-17 23:16:29 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-03-17 23:16:29 -0400 |
commit | 68515441acd77d3356e8ec8b58700411661fec13 (patch) | |
tree | f3e08e4eecb5c06c8149d56ca08253a3c2d92607 /ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserAuthFileDAOTest.java | |
parent | 7a5c5073e9e410b3ccc3ab7902a0d6f558277c7d (diff) | |
parent | 275a6062007380389b7a8f1b8958e8033b4f0925 (diff) | |
download | JellySolutions-68515441acd77d3356e8ec8b58700411661fec13.tar.gz JellySolutions-68515441acd77d3356e8ec8b58700411661fec13.tar.bz2 JellySolutions-68515441acd77d3356e8ec8b58700411661fec13.zip |
Merge remote-tracking branch 'refs/remotes/origin/main' into funding_basket
# Conflicts:
# ufund-ui/src/app/components/funding-basket/funding-basket.component.ts
Diffstat (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserAuthFileDAOTest.java')
-rw-r--r-- | ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserAuthFileDAOTest.java | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserAuthFileDAOTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserAuthFileDAOTest.java new file mode 100644 index 0000000..f7db747 --- /dev/null +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/UserAuthFileDAOTest.java @@ -0,0 +1,63 @@ +package com.ufund.api.ufundapi.persistence; + +import java.io.File; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ufund.api.ufundapi.model.UserAuth; + +@Tag("Persistence-tier") +public class UserAuthFileDAOTest { + + private UserAuthFIleDAO userAuthFIleDAO; + private ObjectMapper mockObjectMapper; + private UserAuth[] userAuths; + + @BeforeEach + public void setupUserAuthFileDAO() throws IOException { + + mockObjectMapper = mock(ObjectMapper.class); + userAuths = new UserAuth[]{ + new UserAuth("123", "Phil", null), + new UserAuth("456", "Bob", null), + new UserAuth("789", "Steve", null) + }; + // When the object mapper is supposed to read from the file + // the mock object mapper will return the hero array above + when(mockObjectMapper + .readValue(new File("doesnt_matter.txt"),UserAuth[].class)) + .thenReturn(userAuths); + userAuthFIleDAO = new UserAuthFIleDAO(mockObjectMapper, "doesnt_matter.txt"); + } + + @Test + public void getUserAuthTest() { + String key = "123"; + UserAuth auth = userAuthFIleDAO.getUserAuth(key); + + assertEquals(auth, userAuths[0]); + } + + @Test + public void addUserAuthTest() throws IOException { + UserAuth auth = new UserAuth("999", "Fish", null); + + assertDoesNotThrow(() -> userAuthFIleDAO.addUserAuth(auth)); + } + + @Test + public void removeUserAuthTest() throws IOException { + String key = "123"; + + assertDoesNotThrow(() -> userAuthFIleDAO.removeUserAuth(key)); + } + +} |