Skip to content

Commit

Permalink
Fixed GameTest to accommodate changes to txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
kasryan committed Apr 25, 2024
1 parent bebf278 commit 283de04
Show file tree
Hide file tree
Showing 25 changed files with 276 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/main/java/uta/cse3310/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ private int getColIncrement(int orientation, int i) {
}

// Attempts to place a single word in the grid randomly
private boolean placeWordInGrid(String word) {
int orientation = random.nextInt(2); // 0 for horizontal, 1 for vertical

private boolean placeWordInGrid(String word) {
int orientation = random.nextInt(8); // Updated for 8 orientations
Expand Down Expand Up @@ -425,6 +423,9 @@ public String getLobbyName() {
public String roomID() {
return roomId;
}
public Map<String, Boolean> getWordsPlaced() {
return wordsPlaced;
}

public void startGame() {
initializeGrid(); // first fill with dashes
Expand Down
11 changes: 0 additions & 11 deletions src/test/java/uta/cse3310/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ public static Test suite()
public void testApp()
{

Game g = new Game("TestLobby", "TestRoom"); // New test Room
Player p1 = new Player("josh", null); // new player named josh
Player p2 = new Player("adam", null); // new player named adam
Player p3 = new Player("haney", null); // new player named hane

App a = new App(0);
assertEquals(g.getCurrentNumberOfPlayers(), "0");





}
}
26 changes: 19 additions & 7 deletions src/test/java/uta/cse3310/GameTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package uta.cse3310;
import java.util.ArrayList;
import java.util.List;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
Expand Down Expand Up @@ -35,16 +38,25 @@ public void testCase(){
g.addPlayer(p1);
g.setPlayer1(p1);
g.setPlayer2(p2);

//checkking to see if game is full, adn ready to start
assertTrue(g.isReadyToStart());
assertEquals(g.getCurrentNumberOfPlayers(),"2");

//check to see if words can be correctlr chosen by players
assertTrue(g.checkWord(p1.getUsername(), "Pagani")); // these next few words need to be changed if TXT file changes
g.checkWord(p1.getUsername(), "Pagani"); // josh finds word pagani
g.checkWord(p2.getUsername(), "Maserati"); // adam finds word Maserati
g.checkWord(p2.getUsername(), "Aspark"); // adam finds word Aspark
//insert 3 word into the words placed function
List<String> wordList = new ArrayList<>();
for (String word : g.getWordsPlaced().keySet()) {
// Add each word to the list
wordList.add(word);
}


//check to see if words can be correctly chosen by players
assertTrue(g.checkWord(p1.getUsername(), wordList.get(0)));// test to see if player josh can find first word in grid
g.checkWord(p1.getUsername(),wordList.get(0)); // josh finds first word
g.checkWord(p2.getUsername(), wordList.get(1)); // adam finds second word
g.checkWord(p2.getUsername(), wordList.get(2)); // adam finds third word


// retrieve player scores
String string = String.valueOf(g.getPlayerScores());
Expand All @@ -57,4 +69,4 @@ public void testCase(){
assertEquals(g.getCurrentNumberOfPlayers(),"0");

}
}
}
Binary file added target/WordSearch-1.0-SNAPSHOT.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions target/classes/META-INF/maven/archetype.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<archetype>
<id>WordSearch</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
</archetype>
15 changes: 15 additions & 0 deletions target/classes/archetype-resources/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>$org.example</groupId>
<artifactId>$WordSearch</artifactId>
<version>$1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
13 changes: 13 additions & 0 deletions target/classes/archetype-resources/src/main/java/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package $org.example;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
38 changes: 38 additions & 0 deletions target/classes/archetype-resources/src/test/java/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package $org.example;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}

/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
Binary file added target/classes/uta/cse3310/App.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/Chat.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/Game.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/HttpServer$1.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/HttpServer.class
Binary file not shown.
Binary file added target/classes/uta/cse3310/Player.class
Binary file not shown.
5 changes: 5 additions & 0 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Generated by Maven
#Thu Apr 25 11:30:25 CDT 2024
groupId=org.example
artifactId=WordSearch
version=1.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
uta/cse3310/App.class
uta/cse3310/Player.class
uta/cse3310/HttpServer.class
uta/cse3310/Chat.class
uta/cse3310/HttpServer$1.class
uta/cse3310/Game.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/App.java
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/HttpServer.java
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/Game.java
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/Chat.java
/home/vboxuser/cse3310_sp24_group_18/src/main/java/uta/cse3310/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uta/cse3310/AppTest.class
uta/cse3310/GameTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/home/vboxuser/cse3310_sp24_group_18/src/test/java/uta/cse3310/AppTest.java
/home/vboxuser/cse3310_sp24_group_18/src/test/java/uta/cse3310/GameTest.java
55 changes: 55 additions & 0 deletions target/surefire-reports/TEST-uta.cse3310.AppTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="uta.cse3310.AppTest" time="0.02" tests="1" errors="0" skipped="0" failures="0">
<properties>
<property name="java.specification.version" value="17"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/test-classes:/home/vboxuser/cse3310_sp24_group_18/target/classes:/home/vboxuser/.m2/repository/net/freeutils/jlhttp/2.6/jlhttp-2.6.jar:/home/vboxuser/.m2/repository/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar:/home/vboxuser/.m2/repository/org/java-websocket/Java-WebSocket/1.5.4/Java-WebSocket-1.5.4.jar:/home/vboxuser/.m2/repository/org/slf4j/slf4j-api/2.0.6/slf4j-api-2.0.6.jar:/home/vboxuser/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/vboxuser/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
<property name="java.vm.vendor" value="Private Build"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.vendor.url" value="Unknown"/>
<property name="os.name" value="Linux"/>
<property name="java.vm.specification.version" value="17"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="user.country" value="US"/>
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-17-openjdk-amd64/lib"/>
<property name="sun.java.command" value="/home/vboxuser/cse3310_sp24_group_18/target/surefire/surefirebooter4273243482372522469.jar /home/vboxuser/cse3310_sp24_group_18/target/surefire 2024-04-25T11-30-21_685-jvmRun1 surefire14035829568187834566tmp surefire_04664733525063810608tmp"/>
<property name="jdk.debug" value="release"/>
<property name="surefire.test.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/test-classes:/home/vboxuser/cse3310_sp24_group_18/target/classes:/home/vboxuser/.m2/repository/net/freeutils/jlhttp/2.6/jlhttp-2.6.jar:/home/vboxuser/.m2/repository/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar:/home/vboxuser/.m2/repository/org/java-websocket/Java-WebSocket/1.5.4/Java-WebSocket-1.5.4.jar:/home/vboxuser/.m2/repository/org/slf4j/slf4j-api/2.0.6/slf4j-api-2.0.6.jar:/home/vboxuser/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/vboxuser/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
<property name="sun.cpu.endian" value="little"/>
<property name="user.home" value="/home/vboxuser"/>
<property name="user.language" value="en"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.version.date" value="2023-10-17"/>
<property name="java.home" value="/usr/lib/jvm/java-17-openjdk-amd64"/>
<property name="file.separator" value="/"/>
<property name="basedir" value="/home/vboxuser/cse3310_sp24_group_18"/>
<property name="java.vm.compressedOopsMode" value="Zero based"/>
<property name="line.separator" value="&#10;"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="surefire.real.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/surefire/surefirebooter4273243482372522469.jar"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="java.runtime.version" value="17.0.9+9-Ubuntu-122.04"/>
<property name="user.name" value="vboxuser"/>
<property name="path.separator" value=":"/>
<property name="os.version" value="6.5.0-17-generic"/>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="localRepository" value="/home/vboxuser/.m2/repository"/>
<property name="java.vendor.url.bug" value="Unknown"/>
<property name="java.io.tmpdir" value="/tmp"/>
<property name="java.version" value="17.0.9"/>
<property name="user.dir" value="/home/vboxuser/cse3310_sp24_group_18"/>
<property name="os.arch" value="amd64"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="native.encoding" value="UTF-8"/>
<property name="java.library.path" value="/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib"/>
<property name="java.vm.info" value="mixed mode, sharing"/>
<property name="java.vendor" value="Private Build"/>
<property name="java.vm.version" value="17.0.9+9-Ubuntu-122.04"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="java.class.version" value="61.0"/>
</properties>
<testcase name="testApp" classname="uta.cse3310.AppTest" time="0"/>
</testsuite>
96 changes: 96 additions & 0 deletions target/surefire-reports/TEST-uta.cse3310.GameTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="uta.cse3310.GameTest" time="3.402" tests="1" errors="0" skipped="0" failures="0">
<properties>
<property name="java.specification.version" value="17"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/test-classes:/home/vboxuser/cse3310_sp24_group_18/target/classes:/home/vboxuser/.m2/repository/net/freeutils/jlhttp/2.6/jlhttp-2.6.jar:/home/vboxuser/.m2/repository/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar:/home/vboxuser/.m2/repository/org/java-websocket/Java-WebSocket/1.5.4/Java-WebSocket-1.5.4.jar:/home/vboxuser/.m2/repository/org/slf4j/slf4j-api/2.0.6/slf4j-api-2.0.6.jar:/home/vboxuser/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/vboxuser/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
<property name="java.vm.vendor" value="Private Build"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.vendor.url" value="Unknown"/>
<property name="os.name" value="Linux"/>
<property name="java.vm.specification.version" value="17"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="user.country" value="US"/>
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-17-openjdk-amd64/lib"/>
<property name="sun.java.command" value="/home/vboxuser/cse3310_sp24_group_18/target/surefire/surefirebooter4273243482372522469.jar /home/vboxuser/cse3310_sp24_group_18/target/surefire 2024-04-25T11-30-21_685-jvmRun1 surefire14035829568187834566tmp surefire_04664733525063810608tmp"/>
<property name="jdk.debug" value="release"/>
<property name="surefire.test.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/test-classes:/home/vboxuser/cse3310_sp24_group_18/target/classes:/home/vboxuser/.m2/repository/net/freeutils/jlhttp/2.6/jlhttp-2.6.jar:/home/vboxuser/.m2/repository/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar:/home/vboxuser/.m2/repository/org/java-websocket/Java-WebSocket/1.5.4/Java-WebSocket-1.5.4.jar:/home/vboxuser/.m2/repository/org/slf4j/slf4j-api/2.0.6/slf4j-api-2.0.6.jar:/home/vboxuser/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/vboxuser/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
<property name="sun.cpu.endian" value="little"/>
<property name="user.home" value="/home/vboxuser"/>
<property name="user.language" value="en"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.version.date" value="2023-10-17"/>
<property name="java.home" value="/usr/lib/jvm/java-17-openjdk-amd64"/>
<property name="file.separator" value="/"/>
<property name="basedir" value="/home/vboxuser/cse3310_sp24_group_18"/>
<property name="java.vm.compressedOopsMode" value="Zero based"/>
<property name="line.separator" value="&#10;"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="surefire.real.class.path" value="/home/vboxuser/cse3310_sp24_group_18/target/surefire/surefirebooter4273243482372522469.jar"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="java.runtime.version" value="17.0.9+9-Ubuntu-122.04"/>
<property name="user.name" value="vboxuser"/>
<property name="path.separator" value=":"/>
<property name="os.version" value="6.5.0-17-generic"/>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="localRepository" value="/home/vboxuser/.m2/repository"/>
<property name="java.vendor.url.bug" value="Unknown"/>
<property name="java.io.tmpdir" value="/tmp"/>
<property name="java.version" value="17.0.9"/>
<property name="user.dir" value="/home/vboxuser/cse3310_sp24_group_18"/>
<property name="os.arch" value="amd64"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="native.encoding" value="UTF-8"/>
<property name="java.library.path" value="/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib"/>
<property name="java.vm.info" value="mixed mode, sharing"/>
<property name="java.vendor" value="Private Build"/>
<property name="java.vm.version" value="17.0.9+9-Ubuntu-122.04"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="java.class.version" value="61.0"/>
</properties>
<testcase name="testCase" classname="uta.cse3310.GameTest" time="3.396">
<system-out><![CDATA[Words loaded successfully. Total words loaded: 8650
Creating game with lobby name: TestLobby and room id: TestRoom
D S D A T L O N I M D R K G N I K E E S
R S K K A A F F E C T E D M Y S P A C E
M I T A S S E C N A H C S V O I D S S S
D I E S O T S C H W A L T E O B L S T T
I D N H H C A E O C T R P Q C A H D U L
S O R I T G A N N N I O E R P R A P D U
T O E C S S I T F O N R O T I I E D I D
A R B O V T K H T O B E O L R C J T E A
N D M N D T E C M R R P C Y D N E U S L
C E E C A O S R O U I D S T K S O S E C
E T T E T K W U S L R B E U E E L O O S
S I P R O H X N A V B E U R R D N N N N
G D E N M A S R W H N X S T P G T N T O
N E S E G N S S A P X G P W E A E A Y I
I Y W D Y S A I J U F E O S I T E R R T
M E O A R D K R U O L F U N O M L T Y A
A Z R H I L A C I P Y T N B A I R Y S T
R T I A G N I D O C N E D B E T I T S I
F T N S F A C I L I T Y S S E D A L B C
S A B L A E D I S I L O P A N A I D N I
----------PLACED WORDS-------------
SURGERY DOWN AFFECTED DOOR IDEAL TRAY TITS SEEKING CITATIONS OAKS ATTRIBUTE FACILITY ADULTS SEPTEMBER LAPTOP PASS CONTAIN EDITED BLADES VOID SECRET KENNY TOOL TYPICAL NOON EXHAUST BONES CHANCES CONCERNED STUDIES ATOM FRAMING FLOUR HANS HITS POUNDS PRICES DISTANCES HIGHS SERUM INDIANAPOLIS MYSPACE STANFORD DIANA DAIRY FUJI MEAT MINISTERS BLOCKS ENCODING WALT RICH CONNECTED THEIR MINOLTA SYRIA
Total words: 56
------------------------------------
Density of valid words in the grid: 84.75%
josh found the word: SURGERY
josh has found: [SURGERY]
Word not found or already marked as found: SURGERY
adam found the word: DOWN
adam has found: [DOWN]
adam found the word: AFFECTED
adam has found: [DOWN, AFFECTED]
Resetting game in lobby: TestLobby
Game reset in lobby: TestLobby
]]></system-out>
</testcase>
</testsuite>
4 changes: 4 additions & 0 deletions target/surefire-reports/uta.cse3310.AppTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: uta.cse3310.AppTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.02 s - in uta.cse3310.AppTest
4 changes: 4 additions & 0 deletions target/surefire-reports/uta.cse3310.GameTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: uta.cse3310.GameTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.402 s - in uta.cse3310.GameTest
Binary file added target/test-classes/uta/cse3310/AppTest.class
Binary file not shown.
Binary file added target/test-classes/uta/cse3310/GameTest.class
Binary file not shown.

0 comments on commit 283de04

Please sign in to comment.