summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/design/model/ClubTest.java1
-rw-r--r--src/test/java/design/model/CourseTest.java36
-rw-r--r--src/test/java/design/model/GolferTest.java25
-rw-r--r--src/test/java/design/model/RoundTest.java42
4 files changed, 90 insertions, 14 deletions
diff --git a/src/test/java/design/model/ClubTest.java b/src/test/java/design/model/ClubTest.java
index 9cbfa87..68f87bc 100644
--- a/src/test/java/design/model/ClubTest.java
+++ b/src/test/java/design/model/ClubTest.java
@@ -16,7 +16,6 @@ public class ClubTest {
void testConstructor()
{
Club testClub = new Club(0, "John Doe", "The Slammer", ClubType.DRIVER);
-
assertEquals(0, testClub.getId());
assertEquals("John Doe", testClub.getManufacture());
assertEquals("The Slammer", testClub.getNickname());
diff --git a/src/test/java/design/model/CourseTest.java b/src/test/java/design/model/CourseTest.java
new file mode 100644
index 0000000..b6dd4a5
--- /dev/null
+++ b/src/test/java/design/model/CourseTest.java
@@ -0,0 +1,36 @@
+package design.model;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+
+
+/** Unit Tests for the Course class.
+ * @author Willem Dalton
+ **/
+@Tag("Model-tier")
+public class CourseTest{
+
+ @Test
+ void testConstructor()
+ {
+ Course testCourse = new Course(0, "Rolling Waves", 62, "Rochester, NY", 9, 20, new ArrayList<Hole>());
+ assertEquals(0, testCourse.getId());
+ assertEquals("Rolling Waves", testCourse.getName());
+ assertEquals(62, testCourse.getDifficultyRating());
+ assertEquals("Rochester, NY", testCourse.getLocation());
+ assertEquals(9, testCourse.getHoleCount());
+ assertEquals(20, testCourse.getTotalPar());
+ assertEquals(0, testCourse.getHoles().size());
+ }
+
+ @Test
+ void testToString()
+ {
+ Course testCourse = new Course(0, "Rolling Waves", 62, "Rochester, NY", 9, 20, new ArrayList<Hole>());
+ assertEquals("Rolling Waves (Rochester, NY) | Holes: 9 | Total Par: 20 | Difficulty: 62.0", testCourse.toString());
+ }
+}
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
diff --git a/src/test/java/design/model/RoundTest.java b/src/test/java/design/model/RoundTest.java
new file mode 100644
index 0000000..d472f5b
--- /dev/null
+++ b/src/test/java/design/model/RoundTest.java
@@ -0,0 +1,42 @@
+package design.model;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+
+/** Unit Tests for the Round class.
+ * @author Willem Dalton
+ **/
+@Tag("Model-tier")
+public class RoundTest {
+
+ @Test
+ void testConstructor()
+ {
+ Course testCourse = new Course(0, "Rolling Waves", 62, "Rochester, NY", 9, 20, new ArrayList<Hole>());
+ LocalDateTime testTime = LocalDateTime.now();
+ Hole testHole = new Hole(0,3);
+ Round testRound = new Round(testCourse, testTime, testHole);
+ assertEquals(testCourse, testRound.getCourse());
+ assertEquals(testTime, testRound.getDateTime());
+ assertEquals(testHole, testRound.getStartingHole());
+ }
+
+ @Test
+ void testHolePlay()
+ {
+ Course testCourse = new Course(0, "Rolling Waves", 62, "Rochester, NY", 9, 20, new ArrayList<Hole>());
+ LocalDateTime testTime = LocalDateTime.now();
+ Hole testHole = new Hole(0,3);
+ Round testRound = new Round(testCourse, testTime, testHole);
+ Play testPlay = new Play(0);
+
+ testRound.addPlay(testPlay);
+ assertEquals(1, testRound.getPlays().length);
+ assertEquals(testPlay, testRound.getPlays()[0]);
+ }
+}