Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create tests #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will build a Java project with Ant
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-ant

name: Java CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Build with Ant
run: ant -noinput -buildfile "GOFO Implementation/build.xml"
- name: Run Tests
run: cd 'GOFO Implementation'; ls -la; ant -noinput -buildfile build.xml; ant test
Binary file modified GOFO Implementation/build/classes/System/Administrator.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/System/PlayGroundSchedule.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/System/Player.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/System/Playground.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/System/PlaygroundOwner.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/System/eWallet.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/System/userProfile.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/UI/AdminUI.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/UI/PlayerUI.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/UI/SystemUI.class
Binary file not shown.
Binary file modified GOFO Implementation/build/classes/UI/playgroundOwnerUI.class
Binary file not shown.
12 changes: 6 additions & 6 deletions GOFO Implementation/nbproject/build-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ is divided into following sections:
</condition>
<condition property="have.tests">
<or>
<available file="${test.src.dir}"/>
<available file="../src/test"/>
</or>
</condition>
<condition property="have.sources">
Expand Down Expand Up @@ -412,7 +412,7 @@ is divided into following sections:
<property name="junit.forkmode" value="perTest"/>
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
<batchtest todir="${build.test.results.dir}">
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<fileset dir="../src/test" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
Expand Down Expand Up @@ -444,7 +444,7 @@ is divided into following sections:
<isset property="test.method"/>
</condition>
<union id="test.set">
<fileset dir="${test.src.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
<fileset dir="../src/test" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
</union>
Expand Down Expand Up @@ -556,7 +556,7 @@ is divided into following sections:
<property name="junit.forkmode" value="perTest"/>
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
<batchtest todir="${build.test.results.dir}">
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<fileset dir="../src/test" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
Expand Down Expand Up @@ -1255,7 +1255,7 @@ is divided into following sections:
<target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
<j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
<fileset dir="../src/test" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
<target name="-post-compile-test">
Expand All @@ -1272,7 +1272,7 @@ is divided into following sections:
<j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
<j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
<fileset dir="../src/test" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
</copy>
</target>
<target name="-post-compile-test-single">
Expand Down
2 changes: 1 addition & 1 deletion GOFO Implementation/nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build.xml.data.CRC32=4c7768cc
build.xml.script.CRC32=2745b79b
build.xml.stylesheet.CRC32=8064a381@1.79.1.48
build.xml.stylesheet.CRC32=f85dc8f2@1.108.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=4c7768cc
Expand Down
2 changes: 1 addition & 1 deletion GOFO Implementation/nbproject/private/private.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
compile.on.save=true
user.properties.file=C:\\Users\\AA\\AppData\\Roaming\\NetBeans\\8.1\\build.properties
user.properties.file=C:\\Users\\pedra\\AppData\\Roaming\\NetBeans\\19\\build.properties
12 changes: 1 addition & 11 deletions GOFO Implementation/nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/PlaygroundOwner.java</file>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/UI/playgroundOwnerUI.java</file>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/Playground.java</file>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/Administrator.java</file>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/PlayGroundSchedule.java</file>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/UI/SystemUI.java</file>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/userProfile.java</file>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/Player.java</file>
<file>file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/eWallet.java</file>
</group>
<group/>
</open-files>
</project-private>
12 changes: 12 additions & 0 deletions GOFO Implementation/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ build.test.results.dir=${build.dir}/test/results
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.modulepath=\
${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
debug.test.modulepath=\
${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
Expand All @@ -34,13 +38,17 @@ javac.classpath=
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.modulepath=\
${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
Expand All @@ -66,9 +74,13 @@ run.classpath=\
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.modulepath=\
${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
run.test.modulepath=\
${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
2 changes: 1 addition & 1 deletion GOFO Implementation/src/System/PlayGroundSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ else if(day.equalsIgnoreCase("saturday"))
* @param time String time
* @param day String day
*/
public void bookSlot(String player, String time,String day)
public void bookSlot(String player, String time, String day)
{
for(int i=0; i<schedule.size(); i++)
{
Expand Down
4 changes: 4 additions & 0 deletions GOFO Implementation/src/System/Playground.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public void setPrice() {
public void setStatus() {
String temp;
temp = input.nextLine();
setStatus(temp);
}

public void setStatus(String temp) {
if (temp.equalsIgnoreCase("available") || temp.equalsIgnoreCase("not available")) {
statusPlayground = temp;
} else {
Expand Down
33 changes: 24 additions & 9 deletions GOFO Implementation/src/UI/PlayerUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public static void playerMenu(Scanner input ,int userIndex, ArrayList<Player> th
System.out.println("Enter the amount to deposit");
temp = input.nextLine();
balance = stringToInt(temp);
thePlayers.get(userIndex).getMoney(balance);
Option1(thePlayers, userIndex, balance);
} else if (choice.equals("2")) {
System.out.println("Your balance is: " + thePlayers.get(userIndex).getBalance());
Option2(thePlayers, userIndex);
} else if (choice.equals("3")) {
Booking(input ,userIndex,thePlayers,currentUser,userBalance);
} else if (choice.equals("4")) {
Expand All @@ -77,14 +77,8 @@ public static void playerMenu(Scanner input ,int userIndex, ArrayList<Player> th
while (true) {
temp = input.nextLine();
teamNum = stringToInt(temp);
if (teamNum >= 1 && teamNum <= 5) {
for (int i = 0; i < teamNum; i++) {
createTeam(thePlayers,currentUser);
}
if(createMembers(teamNum, thePlayers, currentUser))
break;
} else {
System.out.println("please enter number from 1 to 5");
}
}
playerMenu(input ,userIndex,thePlayers,currentUser,userBalance);
} else if (choice.equals("5")) {
Expand Down Expand Up @@ -115,6 +109,27 @@ public static void playerMenu(Scanner input ,int userIndex, ArrayList<Player> th
}
playerMenu(input ,userIndex,thePlayers,currentUser,userBalance);
}

public static boolean createMembers(int teamNum, ArrayList<Player> thePlayers, String currentUser) {
if (teamNum >= 1 && teamNum <= 5) {
for (int i = 0; i < teamNum; i++) {
createTeam(thePlayers,currentUser);
}
return true;
} else {
System.out.println("please enter number from 1 to 5");
return false;
}
}

public static void Option1(ArrayList<Player> thePlayers, int userIndex, int balance) {
thePlayers.get(userIndex).getMoney(balance);
}

public static void Option2(ArrayList<Player> thePlayers, int userIndex) {
System.out.println("Your balance is: " + thePlayers.get(userIndex).getBalance());
}

//Booking a slot for the player

public static void Booking(Scanner input ,int userIndex, ArrayList<Player> thePlayers,String currentUser,int userBalance) {
Expand Down
32 changes: 32 additions & 0 deletions GOFO Implementation/test/EWalletTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import UI.PlayerUI;
import org.junit.Test;
import System.eWallet;

import java.util.ArrayList;

import static org.junit.Assert.assertEquals;

public class EWalletTest {

@Test
public void DepositTest() {

eWallet eWallet = new eWallet();

eWallet.deposit(2);

assertEquals(2, eWallet.getBalance());
}

@Test
public void WithdrawTest() {
eWallet eWallet = new eWallet();

eWallet.deposit(2);

eWallet.withdraw(1);

assertEquals(1, eWallet.getBalance());
}

}
45 changes: 45 additions & 0 deletions GOFO Implementation/test/PlayGroundOwnerUITest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import org.junit.Test;
import System.PlaygroundOwner;
import System.Playground;
import UI.playgroundOwnerUI;

import java.util.ArrayList;

import static org.junit.Assert.assertEquals;

public class PlayGroundOwnerUITest {

@Test
public void PlaygroundExistsTest() {

PlaygroundOwner playgroundOwner = new PlaygroundOwner();
Playground playground = new Playground();
playground.setName("teste");
playgroundOwner.addPlayground(playground);

ArrayList<PlaygroundOwner> playgroundOwners = new ArrayList<>();
playgroundOwners.add(playgroundOwner);

playgroundOwnerUI playgroundOwnerUI = new playgroundOwnerUI();

assertEquals(true, playgroundOwnerUI.playgroundExists(playgroundOwners, "teste"));

}

@Test
public void PlaygroundNotExistsTest() {

PlaygroundOwner playgroundOwner = new PlaygroundOwner();
Playground playground = new Playground();
playground.setName("teste123");
playgroundOwner.addPlayground(playground);

ArrayList<PlaygroundOwner> playgroundOwners = new ArrayList<>();
playgroundOwners.add(playgroundOwner);

playgroundOwnerUI playgroundOwnerUI = new playgroundOwnerUI();

assertEquals(false, playgroundOwnerUI.playgroundExists(playgroundOwners, "teste"));

}
}
48 changes: 48 additions & 0 deletions GOFO Implementation/test/PlayerUiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import System.Player;
import UI.PlayerUI;
import org.junit.Test;

import java.util.ArrayList;

import static org.junit.Assert.assertEquals;

public class PlayerUiTest {

@Test
public void IsExistPlayerTest() {

Player player = new Player();
player.setEmail("[email protected]");

ArrayList<Player> players = new ArrayList<>();
players.add(player);

assertEquals(true, PlayerUI.isExistPlayer(players, "[email protected]"));
}

@Test
public void IsNotExistPlayerTest() {

Player player = new Player();
player.setEmail("[email protected]");

ArrayList<Player> players = new ArrayList<>();
players.add(player);

assertEquals(false, PlayerUI.isExistPlayer(players, "[email protected]"));
}

@Test
public void DepositTest() {

Player player = new Player();
player.setEmail("[email protected]");

ArrayList<Player> players = new ArrayList<>();
players.add(player);

PlayerUI.Option1(players, 0, 2);
assertEquals(2, players.get(0).getBalance());

}
}
32 changes: 32 additions & 0 deletions GOFO Implementation/test/PlaygroundOwnerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import System.Playground;
import System.PlaygroundOwner;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class PlaygroundOwnerTest {

@Test
public void ExistPlaygroundTest() {
PlaygroundOwner playgroundOwner = new PlaygroundOwner();

Playground playground = new Playground();
playground.setName("teste");

playgroundOwner.addPlayground(playground);

assertEquals(true, playgroundOwner.existPlayground("teste"));
}

@Test
public void NotExistPlaygroundTest() {
PlaygroundOwner playgroundOwner = new PlaygroundOwner();

Playground playground = new Playground();
playground.setName("teste123");

playgroundOwner.addPlayground(playground);

assertEquals(false, playgroundOwner.existPlayground("teste"));
}
}
Loading