summaryrefslogtreecommitdiff
path: root/src/test/java/design/model/GolferTest.java
diff options
context:
space:
mode:
authorWillemDalton <willemhdalton@gmail.com>2025-11-10 18:29:20 -0500
committerWillemDalton <willemhdalton@gmail.com>2025-11-10 18:29:20 -0500
commit5d8330c190d736427066e3efce283258956d3dfd (patch)
treefa832c2485597fc0f51d02f231bef2a2bfe410a7 /src/test/java/design/model/GolferTest.java
parentac4a71e3b43370fe45e39ac4e735b88f2e284a14 (diff)
downloaddesignproject-design-6-5d8330c190d736427066e3efce283258956d3dfd.tar.gz
designproject-design-6-5d8330c190d736427066e3efce283258956d3dfd.tar.bz2
designproject-design-6-5d8330c190d736427066e3efce283258956d3dfd.zip
more unit tests
Diffstat (limited to 'src/test/java/design/model/GolferTest.java')
-rw-r--r--src/test/java/design/model/GolferTest.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/test/java/design/model/GolferTest.java b/src/test/java/design/model/GolferTest.java
index 4dce705..52e6271 100644
--- a/src/test/java/design/model/GolferTest.java
+++ b/src/test/java/design/model/GolferTest.java
@@ -4,6 +4,7 @@ package design.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -13,6 +14,7 @@ import design.model.Club.ClubType;
import java.lang.reflect.Constructor;
import java.time.LocalDateTime;
import java.util.ArrayList;
+import java.util.List;
import java.lang.reflect.Modifier;
/** Unit Tests for the Club class.
@@ -30,12 +32,15 @@ public class GolferTest {
assertTrue(testGolfer.checkPassword("weback4321"));
}
- // @Test
- // void testPrivateConstructor() throws Exception
- // {
- // Constructor<Golfer> constructor = Golfer.class.getDeclaredConstructor();
- // assertTrue(Modifier.isPrivate(constructor.getModifiers()));
- // }
+ @Test
+ void testPrivateConstructor() throws Exception
+ {
+ Constructor<Golfer> constructor = Golfer.class.getDeclaredConstructor(String.class, int.class, String.class, List.class, List.class, List.class);
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ Golfer testGolfer = constructor.newInstance("testUser", 12345, "Test Golfer", new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
+ assertNotNull(testGolfer);
+ }
@Test
void testSetUserName()
@@ -102,7 +107,6 @@ public class GolferTest {
void testAddClub()
{
Golfer testGolfer = new Golfer("John Doe", "jdoesgolf2", "weback4321");
-
testGolfer.addClub("John Doe", "The Slammer", ClubType.DRIVER);
Club addedClub = testGolfer.getClubs()[0];
assertTrue(testGolfer.hasClub(addedClub));
@@ -113,7 +117,6 @@ public class GolferTest {
void testRemoveClub()
{
Golfer testGolfer = new Golfer("John Doe", "jdoesgolf2", "weback4321");
-
testGolfer.addClub("John Doe", "The Slammer", ClubType.DRIVER);
Club addedClub = testGolfer.getClubs()[0];
testGolfer.removeClub(addedClub);
@@ -129,8 +132,4 @@ public class GolferTest {
String expectedString = "John Doe (@jdoesgolf2)";
assertEquals(expectedString, testGolfer.toString());
}
-
-
-
-}
-
+} \ No newline at end of file