mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge branch 'master' of https://eng-git.canterbury.ac.nz/seng302-2017/team-13
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
package seng302;
|
||||
|
||||
import org.junit.Test;
|
||||
import seng302.models.OldFileParser;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Unit test for FileParser class
|
||||
* Created by Haoming on 5/03/17.
|
||||
*/
|
||||
public class OldFileParserTest {
|
||||
|
||||
/**
|
||||
* test if it fails from reading non existed file
|
||||
*/
|
||||
@Test(expected = FileNotFoundException.class)
|
||||
public void readNonExistedFile() throws Exception {
|
||||
OldFileParser fileParser = new OldFileParser("test/java/seng302/non-existed.json");
|
||||
}
|
||||
|
||||
/**
|
||||
* test a valid json file with valid content.
|
||||
*/
|
||||
@Test
|
||||
public void readValidFile() throws Exception {
|
||||
OldFileParser fileParser = new OldFileParser("src/test/java/seng302/valid.json");
|
||||
|
||||
assertEquals("AC35", fileParser.getRaceName());
|
||||
|
||||
assertEquals("Oracle Team USA", fileParser.getTeams().get(0).get("team-name"));
|
||||
assertEquals(20.9, fileParser.getTeams().get(0).get("velocity"));
|
||||
assertEquals(2, fileParser.getRaceSize());
|
||||
assertEquals(6, fileParser.getTotalNumberOfTeams());
|
||||
}
|
||||
|
||||
/**
|
||||
* test an invalid json file within wrong type value and misnamed
|
||||
* variable name.
|
||||
*/
|
||||
@Test
|
||||
public void readInvalidFile() throws Exception {
|
||||
OldFileParser fileParser = new OldFileParser("src/test/java/seng302/invalid.json");
|
||||
|
||||
assertEquals(null, fileParser.getRaceName());
|
||||
assertEquals(null, fileParser.getTeams());
|
||||
//assertEquals(-1, fileParser.getTimeScale());
|
||||
assertEquals(null, fileParser.getTeams());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"time-scale": "abc",
|
||||
"race-name": 123,
|
||||
"teams-with-wrong-name": [
|
||||
"team1",
|
||||
"team2",
|
||||
"team3"
|
||||
]
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class ConfigParserTest {
|
||||
|
||||
@Before
|
||||
public void initializeParser() throws Exception {
|
||||
cp = new ConfigParser("doc/examples/config.xml");
|
||||
cp = new ConfigParser("/config.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,7 +18,7 @@ public class CourseParserTest {
|
||||
|
||||
@Before
|
||||
public void initializeParser() throws Exception {
|
||||
cp = new CourseParser("doc/examples/course.xml");
|
||||
cp = new CourseParser("/course.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TeamsParserTest {
|
||||
private TeamsParser tp;
|
||||
@Before
|
||||
public void readFile() {
|
||||
tp = new TeamsParser("doc/examples/teams.xml");
|
||||
tp = new TeamsParser("/teams.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -26,10 +26,10 @@ public class TeamsParserTest {
|
||||
assertEquals(6, boats.size(), 1e-10);
|
||||
|
||||
assertEquals("Oracle Team USA", boats.get(0).getTeamName());
|
||||
assertEquals(10, boats.get(0).getVelocity(), 1e-10);
|
||||
assertEquals(30.9, boats.get(0).getVelocity(), 1e-10);
|
||||
|
||||
assertEquals("Groupama Team France", boats.get(5).getTeamName());
|
||||
assertEquals(10, boats.get(5).getVelocity(), 1e-10);
|
||||
assertEquals(45.6, boats.get(5).getVelocity(), 1e-10);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"race-name": "AC35",
|
||||
"time-scale": 1,
|
||||
"race-size": 2,
|
||||
"teams": [
|
||||
{
|
||||
"team-name": "Oracle Team USA",
|
||||
"velocity": 20.9
|
||||
},
|
||||
{
|
||||
"team-name": "Artemis Racing",
|
||||
"velocity": 18.3
|
||||
},
|
||||
{
|
||||
"team-name": "Emirates Team New Zealand",
|
||||
"velocity": 21.5
|
||||
},
|
||||
{
|
||||
"team-name": "Groupama Team France",
|
||||
"velocity": 19.9
|
||||
},
|
||||
{
|
||||
"team-name": "Land Rover BAR",
|
||||
"velocity": 17.6
|
||||
},
|
||||
{
|
||||
"team-name": "SoftBank Team Japan",
|
||||
"velocity": 16.6
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user