From 1abdb1408159796d12ed28c73862dd8d186384f0 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Sun, 30 Mar 2025 16:41:24 -0400 Subject: Fixed broken tests and made them more consistent --- .../api/ufundapi/persistence/CupboardFileDAOTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java') diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java index d83e825..acb759a 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java @@ -28,15 +28,13 @@ public class CupboardFileDAOTest { public void setupCupboardFileDao() throws IOException { ObjectMapper mockObjectMapper = mock(ObjectMapper.class); testNeeds = new Need[] { - new Need("one", 0, 100, Need.GoalType.MONETARY), - new Need("two", 1, 100, Need.GoalType.MONETARY), - new Need("three", 2, 100, Need.GoalType.MONETARY) + new Need("one", "Atlantis", 0, 100, Need.GoalType.MONETARY, false), + new Need("two", "Atlantis", 1, 100, Need.GoalType.MONETARY, false), + new Need("three", "Atlantis", 2, 100, Need.GoalType.MONETARY, false) }; // 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"), Need[].class)) - .thenReturn(testNeeds); + when(mockObjectMapper.readValue(new File("doesnt_matter.txt"), Need[].class)).thenReturn(testNeeds); cupboardFileDao = new CupboardFileDAO("doesnt_matter.txt", mockObjectMapper); } @@ -56,7 +54,7 @@ public class CupboardFileDAOTest { @Test public void createNeedTest() throws IOException { - Need newNeed = new Need("sea urchin hats", 3, 100, GoalType.PHYSICAL); + Need newNeed = new Need("sea urchin hats", "Atlantis", 100, GoalType.PHYSICAL, false); Need actualNeed = cupboardFileDao.addNeed(newNeed); @@ -92,7 +90,7 @@ public class CupboardFileDAOTest { Need unupdatedNeed = needs[needs.length - 1]; assertNotNull(unupdatedNeed); - Need updatedNeed = new Need("sequin sea urchin hats", 2, 100, GoalType.PHYSICAL); + Need updatedNeed = new Need("sequin sea urchin hats", "Atlantis", 100, GoalType.PHYSICAL, false); Need actualNeed = cupboardFileDao.updateNeed(updatedNeed); assertEquals(actualNeed, updatedNeed); @@ -105,7 +103,7 @@ public class CupboardFileDAOTest { Need unupdatedNeed = needs[needs.length - 1]; assertNotNull(unupdatedNeed); - Need updatedNeed = new Need("sequin sea urchin hats", 20, 100, GoalType.PHYSICAL); + Need updatedNeed = new Need("sequin sea urchin hats", "Atlantis", 5, 100, GoalType.PHYSICAL, false); Need actualNeed = cupboardFileDao.updateNeed(updatedNeed); assertNull(actualNeed); -- cgit v1.2.3 From cd8b846a4455aba7664cc03e219f471d251ff9bf Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 20:44:22 -0400 Subject: Fixed broken tests due to new need fields --- .../ufund/api/ufundapi/persistence/CupboardFileDAOTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java') diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java index acb759a..76a8b40 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java @@ -28,9 +28,9 @@ public class CupboardFileDAOTest { public void setupCupboardFileDao() throws IOException { ObjectMapper mockObjectMapper = mock(ObjectMapper.class); testNeeds = new Need[] { - new Need("one", "Atlantis", 0, 100, Need.GoalType.MONETARY, false), - new Need("two", "Atlantis", 1, 100, Need.GoalType.MONETARY, false), - new Need("three", "Atlantis", 2, 100, Need.GoalType.MONETARY, false) + new Need("one", "", "Atlantis", 0, 100, Need.GoalType.MONETARY, false, ""), + new Need("two", "", "Atlantis", 1, 100, Need.GoalType.MONETARY, false, ""), + new Need("three", "", "Atlantis", 2, 100, Need.GoalType.MONETARY, false, "") }; // When the object mapper is supposed to read from the file // the mock object mapper will return the hero array above @@ -54,7 +54,7 @@ public class CupboardFileDAOTest { @Test public void createNeedTest() throws IOException { - Need newNeed = new Need("sea urchin hats", "Atlantis", 100, GoalType.PHYSICAL, false); + Need newNeed = new Need("sea urchin hats", "", "Atlantis", 100, GoalType.PHYSICAL, false, ""); Need actualNeed = cupboardFileDao.addNeed(newNeed); @@ -90,7 +90,7 @@ public class CupboardFileDAOTest { Need unupdatedNeed = needs[needs.length - 1]; assertNotNull(unupdatedNeed); - Need updatedNeed = new Need("sequin sea urchin hats", "Atlantis", 100, GoalType.PHYSICAL, false); + Need updatedNeed = new Need("sequin sea urchin hats", "", "Atlantis", 100, GoalType.PHYSICAL, false, ""); Need actualNeed = cupboardFileDao.updateNeed(updatedNeed); assertEquals(actualNeed, updatedNeed); @@ -103,7 +103,7 @@ public class CupboardFileDAOTest { Need unupdatedNeed = needs[needs.length - 1]; assertNotNull(unupdatedNeed); - Need updatedNeed = new Need("sequin sea urchin hats", "Atlantis", 5, 100, GoalType.PHYSICAL, false); + Need updatedNeed = new Need("sequin sea urchin hats", "", "Atlantis", 5, 100, GoalType.PHYSICAL, false, ""); Need actualNeed = cupboardFileDao.updateNeed(updatedNeed); assertNull(actualNeed); -- cgit v1.2.3