summaryrefslogtreecommitdiff
path: root/src/test/java/design
diff options
context:
space:
mode:
authorWillemDalton <willemhdalton@gmail.com>2025-11-13 17:48:29 -0500
committerWillemDalton <willemhdalton@gmail.com>2025-11-13 17:48:29 -0500
commitea93075796d8af8e7dee1d2eac7407e7bbe8aea8 (patch)
tree6471dece55597bd2c77a15e5bab91b70adeba0f9 /src/test/java/design
parent229a469f61f842260618ee52294b5dae0f3c1bb4 (diff)
downloaddesignproject-design-6-ea93075796d8af8e7dee1d2eac7407e7bbe8aea8.tar.gz
designproject-design-6-ea93075796d8af8e7dee1d2eac7407e7bbe8aea8.tar.bz2
designproject-design-6-ea93075796d8af8e7dee1d2eac7407e7bbe8aea8.zip
completed unit testing for scramble
Diffstat (limited to 'src/test/java/design')
-rw-r--r--src/test/java/design/model/ScrambleLeagueTest.java89
-rw-r--r--src/test/java/design/model/StrokeLeagueTest.java3
2 files changed, 90 insertions, 2 deletions
diff --git a/src/test/java/design/model/ScrambleLeagueTest.java b/src/test/java/design/model/ScrambleLeagueTest.java
new file mode 100644
index 0000000..e8fe63c
--- /dev/null
+++ b/src/test/java/design/model/ScrambleLeagueTest.java
@@ -0,0 +1,89 @@
+package design.model;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+/** Tests for the scramble league model class.
+ * @author Willem Dalton
+ */
+@Tag("Model-tier")
+public class ScrambleLeagueTest {
+
+ @Test
+ void testConstructor()
+ {
+ Date testStart = new Date(1234567);
+ Date testRegistration = new Date(1234568);
+ Date testEnd = new Date(12345679);
+ Golfer testOwner = new Golfer("Bobby", "bobby123", "iloveswen262");
+ ScrambleLeague testLeague = new ScrambleLeague("Bobby's Band", testRegistration, testStart, testEnd, testOwner);
+ assertEquals(-1, testLeague.getId());
+ assertEquals("Bobby's Band", testLeague.getName());
+ assertEquals(testRegistration, testLeague.getRegistrationDate());
+ assertEquals(testStart, testLeague.getStartDate());
+ assertEquals(testEnd, testLeague.getEndDate());
+ assertEquals(testOwner, testLeague.getOwner());
+ }
+
+ @Test
+ void testPrivateConstructor() throws Exception
+ {
+ Golfer testOwner = new Golfer("Bobby", "bobby123", "iloveswen262");
+ Constructor<ScrambleLeague> constructor = ScrambleLeague.class.getDeclaredConstructor(int.class, String.class, Date.class, Date.class, Date.class, Golfer.class, List.class, List.class);
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ ScrambleLeague testLeague = constructor.newInstance(1, "Bobby's Band", new Date(), new Date(), new Date(), testOwner, new ArrayList<Team>(), new ArrayList<Match>());
+ assertNotNull(testLeague);
+ }
+
+ @Test
+ void testParticipants() throws Exception
+ {
+ Date testStart = new Date(1234567);
+ Date testRegistration = new Date(1234568);
+ Date testEnd = new Date(12345679);
+ Golfer testOwner = new Golfer("Bobby", "bobby123", "iloveswen262");
+ ScrambleLeague testLeague = new ScrambleLeague("Bobby's Band", testRegistration, testStart, testEnd, testOwner);
+ Team testTeam = new Team("The A Team", testOwner);
+
+ // add and remove participant
+ testLeague.addParticipants(testTeam);
+ assertEquals(testTeam, testLeague.getParticipants()[0]);
+ assertEquals(1, testLeague.getParticipants().length);
+ testLeague.removeParticipants(testTeam);
+ assertEquals(0, testLeague.getParticipants().length);
+ }
+
+ @Test
+ void testLocateTeam() throws Exception
+ {
+ Date testStart = new Date(1234567);
+ Date testRegistration = new Date(1234568);
+ Date testEnd = new Date(12345679);
+ Golfer testOwner = new Golfer("Bobby", "bobby123", "iloveswen262");
+ ScrambleLeague testLeague = new ScrambleLeague("Bobby's Band", testRegistration, testStart, testEnd, testOwner);
+
+ Team testTeam = new Team("The A Team", testOwner);
+ Golfer teamMember = new Golfer("Jane Doe", "jane_doe", "weback");
+ Golfer nonMember = new Golfer("NAN doe", "nan_doe", "wenotback");
+
+ // expect a result if member is part of team. expect null if they are not.
+ testTeam.addMember(teamMember);
+ testLeague.addParticipants(testTeam);
+ Team result = testLeague.locateTeam(teamMember);
+ assertEquals(result, testTeam);
+ result = testLeague.locateTeam(nonMember);
+ assertNull(result);
+ }
+}
diff --git a/src/test/java/design/model/StrokeLeagueTest.java b/src/test/java/design/model/StrokeLeagueTest.java
index cc37887..8af7561 100644
--- a/src/test/java/design/model/StrokeLeagueTest.java
+++ b/src/test/java/design/model/StrokeLeagueTest.java
@@ -1,6 +1,5 @@
package design.model;
-import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -14,7 +13,7 @@ import java.util.List;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
-/** Tests for the league model class.
+/** Tests for the stroke league model class.
* @author Willem Dalton
*/
@Tag("Model-tier")