Skip to content

Commit 3426dbb

Browse files
committed
all tests pass
1 parent 0e97335 commit 3426dbb

File tree

11 files changed

+253
-184
lines changed

11 files changed

+253
-184
lines changed

Client/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<modelVersion>4.0.0</modelVersion>
66
<properties>
77
<javafx.version>23.0.2</javafx.version>
8-
<junit.version>5.12.0</junit.version>
98
<maven.compiler.source>24</maven.compiler.source>
109
<maven.compiler.target>24</maven.compiler.target>
1110
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Client/src/test/java/edu/sdccd/cisc191/Client/ClientTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void clearStaticCollections() {
8686
* getOdds
8787
* -------------------------------------------------- */
8888
@Test
89-
void getOdds_returnsCorrectHomeAndAway() throws Exception {
89+
void getOdds() throws Exception {
9090

9191
/* ---------- mock the static constructor ---------- */
9292
try (var mockedStatic = mockStatic(HttpClient.class)) {
@@ -119,7 +119,7 @@ void getOdds_returnsCorrectHomeAndAway() throws Exception {
119119
* getGames
120120
* -------------------------------------------------- */
121121
@Test
122-
void getGames_parsesListIntoDomainObjects() throws Exception {
122+
void getGamesParseToObjects() throws Exception {
123123

124124
try (var mockedStatic = mockStatic(HttpClient.class)) {
125125
HttpClient mockClient = mock(HttpClient.class);
@@ -148,7 +148,7 @@ void getGames_parsesListIntoDomainObjects() throws Exception {
148148
* createBotArray → getBots
149149
* -------------------------------------------------- */
150150
@Test
151-
void createBotArray_convertsUsersToBots_skippingMainUser() throws Exception {
151+
void createBotArray() throws Exception {
152152
Client.createBotArray();
153153
List<BotBase> bots = Client.getBots();
154154
assertEquals(4, bots.size(), "should skip first (human) user and make 2 bots");

Common/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
<artifactId>joda-time</artifactId>
3232
<version>2.12.5</version>
3333
</dependency>
34-
<dependency>
35-
<groupId>com.googlecode.json-simple</groupId>
36-
<artifactId>json-simple</artifactId>
37-
<version>1.1.1</version>
38-
</dependency>
3934
<!-- Spring stuff -->
4035
<dependency>
4136
<groupId>org.springframework.boot</groupId>

Common/src/main/java/edu/sdccd/cisc191/Common/Models/Bet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class Bet implements Serializable {
3131

3232
@ManyToOne
3333
@JoinColumn(name = "game_db_id", unique = true)
34+
@Getter @Setter
3435
private Game game;
3536
private String betTeam;
3637
private int betAmt;

Common/src/main/java/edu/sdccd/cisc191/Common/Models/User.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,54 @@ public JodaModule jodaModule() {
4040
@Setter
4141
@ToString
4242
public class User implements Serializable {
43+
public Long getId() {
44+
return id;
45+
}
46+
47+
public void setId(Long id) {
48+
this.id = id;
49+
}
50+
51+
public String getName() {
52+
return name;
53+
}
54+
55+
public void setName(String name) {
56+
this.name = name;
57+
}
58+
59+
public long getMoney() {
60+
return money;
61+
}
62+
63+
public void setMoney(long money) {
64+
this.money = money;
65+
}
66+
67+
public int getMoneyLine() {
68+
return moneyLine;
69+
}
70+
71+
public void setMoneyLine(int moneyLine) {
72+
this.moneyLine = moneyLine;
73+
}
74+
75+
public List<Bet> getBets() {
76+
return bets;
77+
}
78+
79+
public void setBets(List<Bet> bets) {
80+
this.bets = bets;
81+
}
82+
83+
public int getMoneyBet() {
84+
return moneyBet;
85+
}
86+
87+
public void setMoneyBet(int moneyBet) {
88+
this.moneyBet = moneyBet;
89+
}
90+
4391
@Id
4492
@GeneratedValue(strategy = GenerationType.IDENTITY)
4593
private Long id;
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package edu.sdccd.cisc191.Common;
2+
3+
import edu.sdccd.cisc191.Common.GameBST.BinarySearchTree;
4+
import edu.sdccd.cisc191.Common.Models.Game;
5+
import org.joda.time.DateTime;
6+
import org.junit.jupiter.api.DisplayName;
7+
import org.junit.jupiter.api.Test;
8+
9+
import java.util.Arrays;
10+
import java.util.List;
11+
12+
import static org.junit.jupiter.api.Assertions.*;
13+
14+
class GameBSTTest {
15+
16+
@Test
17+
@DisplayName("Generic BST inorderTraversal should sort Integers")
18+
void testGenericBinarySearchTreeInorderTraversal() {
19+
BinarySearchTree<Integer> tree = new BinarySearchTree<>(Integer::compareTo);
20+
tree.insert(5);
21+
tree.insert(3);
22+
tree.insert(7);
23+
tree.insert(1);
24+
tree.insert(4);
25+
26+
List<Integer> expected = Arrays.asList(1, 3, 4, 5, 7);
27+
assertEquals(expected, tree.inorderTraversal(),
28+
"Inorder traversal of [5,3,7,1,4] should be [1,3,4,5,7]");
29+
}
30+
31+
@Test
32+
@DisplayName("buildGameIdTree orders by Game.getId()")
33+
void testBuildGameIdTree() {
34+
Game g1 = new Game();
35+
g1.setId(2L);
36+
Game g2 = new Game();
37+
g2.setId(1L);
38+
39+
List<Game> games = Arrays.asList(g1, g2);
40+
BinarySearchTree<Game> tree = GameBST.buildGameIdTree(games);
41+
42+
List<Game> inorder = tree.inorderTraversal();
43+
assertEquals(1L, inorder.get(0).getId(), "First element should have ID 1");
44+
assertEquals(2L, inorder.get(1).getId(), "Second element should have ID 2");
45+
}
46+
47+
@Test
48+
@DisplayName("buildOddsTree orders by Game.getTeam1Odd()")
49+
void testBuildOddsTree() {
50+
Game g1 = new Game();
51+
g1.setTeam1Odd(2.0);
52+
Game g2 = new Game();
53+
g2.setTeam1Odd(1.5);
54+
55+
List<Game> games = Arrays.asList(g1, g2);
56+
BinarySearchTree<Game> tree = GameBST.buildOddsTree(games);
57+
58+
List<Game> inorder = tree.inorderTraversal();
59+
assertEquals(1.5, inorder.get(0).getTeam1Odd(), 1e-9,
60+
"Lowest team1Odd should come first");
61+
assertEquals(2.0, inorder.get(1).getTeam1Odd(), 1e-9,
62+
"Highest team1Odd should come last");
63+
}
64+
65+
@Test
66+
@DisplayName("buildTeam2OddsTree orders by Game.getTeam2Odd()")
67+
void testBuildTeam2OddsTree() {
68+
Game g1 = new Game();
69+
g1.setTeam2Odd(3.0);
70+
Game g2 = new Game();
71+
g2.setTeam2Odd(2.5);
72+
73+
List<Game> games = Arrays.asList(g1, g2);
74+
BinarySearchTree<Game> tree = GameBST.buildTeam2OddsTree(games);
75+
76+
List<Game> inorder = tree.inorderTraversal();
77+
assertEquals(2.5, inorder.get(0).getTeam2Odd(), 1e-9,
78+
"Lowest team2Odd should come first");
79+
assertEquals(3.0, inorder.get(1).getTeam2Odd(), 1e-9,
80+
"Highest team2Odd should come last");
81+
}
82+
83+
@Test
84+
@DisplayName("buildDateTree orders by Game.getGameDate()")
85+
void testBuildDateTree() {
86+
Game g1 = new Game();
87+
g1.setGameDate(new DateTime(2021, 1, 2, 0, 0));
88+
Game g2 = new Game();
89+
g2.setGameDate(new DateTime(2021, 1, 1, 0, 0));
90+
91+
List<Game> games = Arrays.asList(g1, g2);
92+
BinarySearchTree<Game> tree = GameBST.buildDateTree(games);
93+
94+
List<Game> inorder = tree.inorderTraversal();
95+
assertEquals(new DateTime(2021, 1, 1, 0, 0), inorder.get(0).getGameDate(),
96+
"Earliest date should come first");
97+
assertEquals(new DateTime(2021, 1, 2, 0, 0), inorder.get(1).getGameDate(),
98+
"Latest date should come last");
99+
}
100+
}

DatabaseServer.mv.db

212 KB
Binary file not shown.

Server/src/main/java/edu/sdccd/cisc191/Server/exceptions/UserNotFoundException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package edu.sdccd.cisc191.Server.exceptions;
22

3+
import org.springframework.http.HttpStatus;
4+
import org.springframework.web.bind.annotation.ResponseStatus;
5+
6+
@ResponseStatus(HttpStatus.NOT_FOUND)
37
public class UserNotFoundException extends RuntimeException {
48
public UserNotFoundException(Long id) {
59
super("Could not find user " + id);
6-
710
}
811
}
9-

Server/src/test/java/edu/sdccd/cisc191/Server/ZGameControllerTest.java renamed to Server/src/test/java/edu/sdccd/cisc191/Server/GameControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
@SpringBootTest
3131
@AutoConfigureMockMvc
32-
class ZGameControllerTest {
32+
class GameControllerTest {
3333
@Autowired
3434
private MockMvc mockMvc;
3535

0 commit comments

Comments
 (0)