diff --git a/pom.xml b/pom.xml
index d0db4ab..299b535 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,6 +54,12 @@
json-simple
1.1.1
+
+
+ org.mockito
+ mockito-core
+ 3.0.0
+
diff --git a/src/main/java/uta/cse3310/Chat.java b/src/main/java/uta/cse3310/Chat.java
deleted file mode 100644
index 655744c..0000000
--- a/src/main/java/uta/cse3310/Chat.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package uta.cse3310;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Chat {
-
- char[] name;
- char[] msg;
-
- public void displayName(){
-
- }
-
- public void displayMsg(){
-
- }
-}
diff --git a/src/main/java/uta/cse3310/HttpServer.java b/src/main/java/uta/cse3310/HttpServer.java
index 8d5c545..4bbeae1 100644
--- a/src/main/java/uta/cse3310/HttpServer.java
+++ b/src/main/java/uta/cse3310/HttpServer.java
@@ -58,4 +58,6 @@ public void start() {
}
+
+
}
diff --git a/src/main/java/uta/cse3310/Matrix.java b/src/main/java/uta/cse3310/Matrix.java
index 1b44fa7..b21c0fd 100644
--- a/src/main/java/uta/cse3310/Matrix.java
+++ b/src/main/java/uta/cse3310/Matrix.java
@@ -54,28 +54,7 @@ public int insertFillerChar(char[][] matrix){
public char[][] wordSearchMatrix(String filename){
return matrix;
}
-
-
- //TEST CASE BELOW:
- public void testMatrix(){
- char[][] grid = new char[50][50];
- List wordBank = new ArrayList();
-
- wordBank.add("Ant");
- wordBank.add("Zebra");
- wordBank.add("Baboon");
-
- //Matrix wordSearch = new Matrix(grid);
-
- //wordSearch.horizontalWordInsert(false,null, grid);
- //assertTrue(gridHasWords(grid, wordBank));
- }
-
- boolean gridHasWords(char[][] grid, List wordBank){
- return false;
- }
-
}
diff --git a/src/test/java/uta/cse3310/Before.java b/src/test/java/uta/cse3310/Before.java
new file mode 100644
index 0000000..c9b11b5
--- /dev/null
+++ b/src/test/java/uta/cse3310/Before.java
@@ -0,0 +1,5 @@
+package uta.cse3310;
+
+public @interface Before {
+
+}
diff --git a/src/test/java/uta/cse3310/GameTest.java b/src/test/java/uta/cse3310/GameTest.java
index 41ba8c7..dfc4820 100644
--- a/src/test/java/uta/cse3310/GameTest.java
+++ b/src/test/java/uta/cse3310/GameTest.java
@@ -5,9 +5,44 @@
import junit.framework.TestSuite;
import org.java_websocket.WebSocket;
+import junit.framework.TestCase;
+import org.mockito.Mockito;
+
+import java.util.ArrayList;
+import java.util.Random;
public class GameTest extends TestCase {
- public void testApp(){
- assertTrue( true );
- }
+
+ public void testGameInitialization() {
+ Game game = new Game();
+
+ assertTrue(game.isOpen);
+ assertEquals(0, game.numPlayers);
+ assertEquals(30, game.matrix.length);
+ assertEquals(30, game.matrix[0].length);
+ assertEquals(30, game.colorGrid.length);
+ assertEquals(30, game.colorGrid[0].length);
+ assertEquals(0, game.temps.size());
+ assertEquals(0, game.scores.size());
+ assertEquals(0, game.names.size());
+ }
+
+ public void testAddEntries() {
+ Game game = new Game();
+ Player player1 = Mockito.mock(Player.class);
+ Player player2 = Mockito.mock(Player.class);
+
+ game.addEntries(player1);
+ game.addEntries(player2);
+
+ assertEquals(2, game.scores.size());
+ assertEquals(2, game.names.size());
+ assertEquals(2, game.temps.size());
+ assertEquals(-1, (int) game.temps.get(0)[0]); // Check if initialized to -1
+ assertEquals(-1, (int) game.temps.get(0)[1]); // Check if initialized to -1
+ assertEquals(-1, (int) game.temps.get(1)[0]); // Check if initialized to -1
+ assertEquals(-1, (int) game.temps.get(1)[1]); // Check if initialized to -1
+ assertEquals(2, game.numPlayers);
+ }
+
}
diff --git a/src/test/java/uta/cse3310/LobbyTest.java b/src/test/java/uta/cse3310/LobbyTest.java
new file mode 100644
index 0000000..4068b2e
--- /dev/null
+++ b/src/test/java/uta/cse3310/LobbyTest.java
@@ -0,0 +1,67 @@
+package uta.cse3310;
+import junit.framework.TestCase;
+import java.util.ArrayList;
+import org.java_websocket.WebSocket;
+import org.mockito.Mockito;
+
+public class LobbyTest extends TestCase {
+
+ public void testLobbyInitialization() {
+ ArrayList players = new ArrayList<>();
+ WebSocket socket1 = Mockito.mock(WebSocket.class);
+ WebSocket socket2 = Mockito.mock(WebSocket.class);
+ Player player1 = new Player("Alice", socket1);
+ Player player2 = new Player("Bob", socket2);
+ players.add(player1);
+ players.add(player2);
+
+ Lobby lobby = new Lobby(players);
+
+ assertEquals(2, lobby.numPlayers);
+ assertEquals(0, lobby.numReady);
+ assertEquals(0, lobby.gamesAvailable);
+ assertTrue(lobby.playerNames.contains("Alice"));
+ assertTrue(lobby.playerNames.contains("Bob"));
+ assertFalse(lobby.playerStatuses.get(0)); // Alice's status
+ assertFalse(lobby.playerStatuses.get(1)); // Bob's status
+ }
+
+ public void testUpdateLobby() {
+ ArrayList players = new ArrayList<>();
+ WebSocket socket1 = Mockito.mock(WebSocket.class);
+ WebSocket socket2 = Mockito.mock(WebSocket.class);
+ Player player1 = new Player("Alice", socket1);
+ Player player2 = new Player("Bob", socket2);
+ players.add(player1);
+ players.add(player2);
+
+ Lobby lobby = new Lobby(players);
+
+ // Update players' readiness
+ player1.isReady = true;
+ player2.isReady = false;
+
+ lobby.updateLobby(players);
+
+ assertEquals(2, lobby.numPlayers);
+ assertEquals(1, lobby.numReady);
+ assertEquals(0, lobby.gamesAvailable);
+ assertTrue(lobby.playerNames.contains("Alice"));
+ assertTrue(lobby.playerNames.contains("Bob"));
+ assertTrue(lobby.playerStatuses.get(0)); // Alice's status
+ assertFalse(lobby.playerStatuses.get(1)); // Bob's status
+ }
+
+ public void testUpdateGamesAvailable() {
+ Game[] games = new Game[3];
+ games[0] = new Game(); // Assume isOpen is true for the first game
+ games[1] = new Game(); // Assume isOpen is false for the second game
+ games[2] = new Game(); // Assume isOpen is true for the third game
+
+ Lobby lobby = new Lobby(new ArrayList<>());
+ lobby.updateGamesAvailable(games);
+
+ assertEquals(2, lobby.gamesAvailable); // Only two games are open
+ }
+
+}
diff --git a/src/test/java/uta/cse3310/MainTest.java b/src/test/java/uta/cse3310/MainTest.java
new file mode 100644
index 0000000..0b1dc7d
--- /dev/null
+++ b/src/test/java/uta/cse3310/MainTest.java
@@ -0,0 +1,35 @@
+package uta.cse3310;
+import org.java_websocket.WebSocket;
+import org.java_websocket.handshake.ClientHandshake;
+import junit.framework.TestCase;
+import org.mockito.Mockito;
+
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.util.ArrayList;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MainTest {
+
+ public void testOnCloseRemovesPlayerFromPlayerList() {
+ // Arrange: Create necessary objects and set up conditions
+ Main main = new Main(8080);
+ WebSocket socket1 = Mockito.mock(WebSocket.class);
+ List playerList = new ArrayList<>();
+ Player player1 = new Player("Alice", socket1);
+ Player player2 = new Player("Bob", socket1);
+ playerList.add(player1);
+ playerList.add(player2);
+
+ // Act: Call the method to be tested
+ main.onClose(socket1, 1001, "Normal closure", true);
+
+ // Assert: Check if the method behaves as expected
+ assert !playerList.contains(player1); // Player1 should be removed from the playerList
+ assert playerList.contains(player2); // Player2 should still be in the playerList
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/uta/cse3310/MatrixTest.java b/src/test/java/uta/cse3310/MatrixTest.java
new file mode 100644
index 0000000..96b96eb
--- /dev/null
+++ b/src/test/java/uta/cse3310/MatrixTest.java
@@ -0,0 +1,32 @@
+package uta.cse3310;
+import junit.framework.TestCase;
+import java.util.List;
+import java.util.ArrayList;
+
+public class MatrixTest extends TestCase
+{
+ public void testGridHasWords() {
+ char[][] grid = new char[50][50];
+ List wordBank = new ArrayList();
+ wordBank.add("Ant");
+ wordBank.add("Zebra");
+ wordBank.add("Baboon");
+
+ boolean result = gridHasWords(grid, wordBank);
+
+ assertFalse(result); // Add your assertions based on the expected behavior
+ }
+
+
+ //Matrix wordSearch = new Matrix(grid);
+
+ //wordSearch.horizontalWordInsert(false,null, grid);
+
+ //assertTrue(gridHasWords(grid, wordBank));
+
+
+ boolean gridHasWords(char[][] grid, List wordBank){
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/uta/cse3310/PlayerTest.java b/src/test/java/uta/cse3310/PlayerTest.java
new file mode 100644
index 0000000..d25ccc9
--- /dev/null
+++ b/src/test/java/uta/cse3310/PlayerTest.java
@@ -0,0 +1,19 @@
+package uta.cse3310;
+
+import junit.framework.TestCase;
+import org.java_websocket.WebSocket;
+import org.mockito.Mockito;
+
+public class PlayerTest extends TestCase {
+
+ public void testPlayerInitialization() {
+ WebSocket socket = Mockito.mock(WebSocket.class);
+ Player player = new Player("Alice", socket);
+
+ assertEquals("Alice", player.name);
+ assertEquals(0, player.score);
+ assertEquals(false, player.isReady);
+ assertEquals(socket, player.playerConn);
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/uta/cse3310/UserMsgTest.java b/src/test/java/uta/cse3310/UserMsgTest.java
new file mode 100644
index 0000000..b2dc6a5
--- /dev/null
+++ b/src/test/java/uta/cse3310/UserMsgTest.java
@@ -0,0 +1,23 @@
+package uta.cse3310;
+import junit.framework.TestCase;
+
+public class UserMsgTest extends TestCase {
+
+ public void testUserMsgInitialization() {
+ int[] startCoords = {1, 2};
+ int[] endCoords = {3, 4};
+
+ UserMsg userMsg = new UserMsg();
+ userMsg.code = 100;
+ userMsg.name = "Alice";
+ userMsg.message = "Hello!";
+ userMsg.startCoords = startCoords;
+ userMsg.endCoords = endCoords;
+ userMsg.gameNum = 1;
+
+ assertEquals(100, userMsg.code);
+ assertEquals("Alice", userMsg.name);
+ assertEquals("Hello!", userMsg.message);
+ assertEquals(1, userMsg.gameNum);
+ }
+}
\ No newline at end of file
diff --git a/target/classes/uta/cse3310/Chat.class b/target/classes/uta/cse3310/Chat.class
deleted file mode 100644
index 01a40c1..0000000
Binary files a/target/classes/uta/cse3310/Chat.class and /dev/null differ
diff --git a/target/classes/uta/cse3310/Game.class b/target/classes/uta/cse3310/Game.class
deleted file mode 100644
index 050672b..0000000
Binary files a/target/classes/uta/cse3310/Game.class and /dev/null differ
diff --git a/target/classes/uta/cse3310/HttpServer.class b/target/classes/uta/cse3310/HttpServer.class
deleted file mode 100644
index a326f62..0000000
Binary files a/target/classes/uta/cse3310/HttpServer.class and /dev/null differ
diff --git a/target/classes/uta/cse3310/Lobby.class b/target/classes/uta/cse3310/Lobby.class
deleted file mode 100644
index ccfa1ce..0000000
Binary files a/target/classes/uta/cse3310/Lobby.class and /dev/null differ
diff --git a/target/classes/uta/cse3310/Main.class b/target/classes/uta/cse3310/Main.class
deleted file mode 100644
index 5b920a7..0000000
Binary files a/target/classes/uta/cse3310/Main.class and /dev/null differ
diff --git a/target/classes/uta/cse3310/Matrix.class b/target/classes/uta/cse3310/Matrix.class
deleted file mode 100644
index e170e51..0000000
Binary files a/target/classes/uta/cse3310/Matrix.class and /dev/null differ
diff --git a/target/classes/uta/cse3310/Player.class b/target/classes/uta/cse3310/Player.class
deleted file mode 100644
index 67a3f34..0000000
Binary files a/target/classes/uta/cse3310/Player.class and /dev/null differ
diff --git a/target/classes/uta/cse3310/Tasks.txt b/target/classes/uta/cse3310/Tasks.txt
deleted file mode 100644
index 5d1d6eb..0000000
--- a/target/classes/uta/cse3310/Tasks.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-List of known bugs as of 4/3:
-
-
-
-Samriddha Kharel
-Endrit Smajli
-
-TODO LIST:
---> populate scoreBoard with colors (based on index?);
---> possible implement char[][] array with w,r,g,b for coloring.
- when highlighting a single cell, this is done w/o modifying array.
-
- when user clicks the second letter, the game checks the word.
- if word is correct. the game updates the color array, and broadcasts.
- if word is incorrect, the game ignores, and broadcasts anyway.
diff --git a/target/classes/uta/cse3310/UserMsg.class b/target/classes/uta/cse3310/UserMsg.class
deleted file mode 100644
index 6914b56..0000000
Binary files a/target/classes/uta/cse3310/UserMsg.class and /dev/null differ
diff --git a/target/cse3310_sp24_group_28-1.0-SNAPSHOT.jar b/target/cse3310_sp24_group_28-1.0-SNAPSHOT.jar
deleted file mode 100644
index bebbad1..0000000
Binary files a/target/cse3310_sp24_group_28-1.0-SNAPSHOT.jar and /dev/null differ
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
deleted file mode 100644
index fd88e67..0000000
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
+++ /dev/null
@@ -1,19 +0,0 @@
-<<<<<<< HEAD
-com/example/Lobby.class
-com/example/UserMsg.class
-com/example/Matrix.class
-com/example/HttpServer.class
-com/example/Main.class
-com/example/Player.class
-com/example/Game.class
-com/example/Chat.class
-=======
-uta/cse3310/Player.class
-uta/cse3310/HttpServer.class
-uta/cse3310/Matrix.class
-uta/cse3310/Lobby.class
-uta/cse3310/UserMsg.class
-uta/cse3310/Chat.class
-uta/cse3310/Game.class
-uta/cse3310/Main.class
->>>>>>> 6f3bc3d68431e1446fbdc165c5840b713383535d
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
deleted file mode 100644
index 9910d07..0000000
--- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
+++ /dev/null
@@ -1,30 +0,0 @@
-<<<<<<< HEAD
-/home/samriddha/cse3310_sp24_group_28/src/main/java/uta/cse3310/Chat.java
-/home/samriddha/cse3310_sp24_group_28/src/main/java/uta/cse3310/UserMsg.java
-/home/samriddha/cse3310_sp24_group_28/src/main/java/uta/cse3310/Player.java
-/home/samriddha/cse3310_sp24_group_28/src/main/java/uta/cse3310/Lobby.java
-/home/samriddha/cse3310_sp24_group_28/src/main/java/uta/cse3310/HttpServer.java
-/home/samriddha/cse3310_sp24_group_28/src/main/java/uta/cse3310/Main.java
-/home/samriddha/cse3310_sp24_group_28/src/main/java/uta/cse3310/Matrix.java
-/home/samriddha/cse3310_sp24_group_28/src/main/java/uta/cse3310/Game.java
-=======
-<<<<<<< HEAD
-/home/endrit/cse3310_sp24_group_28/src/main/java/com/example/HttpServer.java
-/home/endrit/cse3310_sp24_group_28/src/main/java/com/example/Matrix.java
-/home/endrit/cse3310_sp24_group_28/src/main/java/com/example/Chat.java
-/home/endrit/cse3310_sp24_group_28/src/main/java/com/example/Game.java
-/home/endrit/cse3310_sp24_group_28/src/main/java/com/example/Player.java
-/home/endrit/cse3310_sp24_group_28/src/main/java/com/example/UserMsg.java
-/home/endrit/cse3310_sp24_group_28/src/main/java/com/example/Main.java
-/home/endrit/cse3310_sp24_group_28/src/main/java/com/example/Lobby.java
-=======
-/mnt/c/Users/Thanh/Java Projects/demo/src/main/java/uta/cse3310/Chat.java
-/mnt/c/Users/Thanh/Java Projects/demo/src/main/java/uta/cse3310/UserMsg.java
-/mnt/c/Users/Thanh/Java Projects/demo/src/main/java/uta/cse3310/Player.java
-/mnt/c/Users/Thanh/Java Projects/demo/src/main/java/uta/cse3310/HttpServer.java
-/mnt/c/Users/Thanh/Java Projects/demo/src/main/java/uta/cse3310/Main.java
-/mnt/c/Users/Thanh/Java Projects/demo/src/main/java/uta/cse3310/Game.java
-/mnt/c/Users/Thanh/Java Projects/demo/src/main/java/uta/cse3310/Lobby.java
-/mnt/c/Users/Thanh/Java Projects/demo/src/main/java/uta/cse3310/Matrix.java
->>>>>>> 6f3bc3d68431e1446fbdc165c5840b713383535d
->>>>>>> d6686501edddac08424f8992c971da16b3e4167d
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
deleted file mode 100644
index 0d4ccd9..0000000
--- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
+++ /dev/null
@@ -1 +0,0 @@
-uta/cse3310/GameTest.class
diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
deleted file mode 100644
index 9200da5..0000000
--- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
+++ /dev/null
@@ -1 +0,0 @@
-/mnt/c/Users/Thanh/Java Projects/demo/src/test/java/uta/cse3310/GameTest.java
diff --git a/target/surefire-reports/TEST-uta.cse3310.GameTest.xml b/target/surefire-reports/TEST-uta.cse3310.GameTest.xml
deleted file mode 100644
index a683f3a..0000000
--- a/target/surefire-reports/TEST-uta.cse3310.GameTest.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/target/surefire-reports/uta.cse3310.GameTest.txt b/target/surefire-reports/uta.cse3310.GameTest.txt
deleted file mode 100644
index 9bbaf9d..0000000
--- a/target/surefire-reports/uta.cse3310.GameTest.txt
+++ /dev/null
@@ -1,4 +0,0 @@
--------------------------------------------------------------------------------
-Test set: uta.cse3310.GameTest
--------------------------------------------------------------------------------
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 s - in uta.cse3310.GameTest
diff --git a/target/test-classes/uta/cse3310/GameTest.class b/target/test-classes/uta/cse3310/GameTest.class
deleted file mode 100644
index ef9857d..0000000
Binary files a/target/test-classes/uta/cse3310/GameTest.class and /dev/null differ