Added the ability to reads boats from both race.xml and boat.xml. Linked the two xmls via the StreamedCource class. #story[782]
This commit is contained in:
@@ -1,20 +1,49 @@
|
||||
package seng302.Mock;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Created by jjg64 on 21/04/17.
|
||||
*/
|
||||
public class BoatsXMLTest {
|
||||
BoatXMLReader boatXMLReader;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
try {
|
||||
boatXMLReader = new BoatXMLReader("mockXML/boatXML/boatTest.xml", false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//fail("Cannot find mockXML/raceXML/raceTest.xml in the resources folder");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
||||
new BoatXMLReader("mockXML/boatXML/boatTest.xml");
|
||||
//new BoatXMLReader("mockXML/raceXML/raceTest.xml", true);
|
||||
public void testInvalidParticipant() {
|
||||
Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
|
||||
inputParticipants.put(420, new StreamedBoat(420));
|
||||
boatXMLReader.setParticipants(inputParticipants);
|
||||
boatXMLReader.read();
|
||||
assertEquals(boatXMLReader.getStreamedBoatMap().size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidParticipant() {
|
||||
Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
|
||||
inputParticipants.put(101, new StreamedBoat(101));
|
||||
boatXMLReader.setParticipants(inputParticipants);
|
||||
boatXMLReader.read();
|
||||
assertTrue(boatXMLReader.getStreamedBoatMap().containsKey(101));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ import org.junit.Test;
|
||||
import seng302.GPSCoordinate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
@@ -57,7 +59,9 @@ public class StreamedRaceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRaceSettings() {
|
||||
|
||||
public void testParticipants() {
|
||||
Map<Integer, StreamedBoat> participants = streamedCourseXMLReader.getParticipants();
|
||||
assertTrue(participants.containsKey(107));
|
||||
assertTrue(participants.containsKey(108));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user