Finished team parser to read team info from external xml file

- created team parser unit test
- refactored team parser functions

#fix #refactor #implement
This commit is contained in:
Haoming Yin
2017-03-18 21:32:12 +13:00
parent 8fd06c84ac
commit d10985f890
4 changed files with 122 additions and 15 deletions
@@ -0,0 +1,35 @@
package seng302.models.parsers;
import org.junit.Before;
import org.junit.Test;
import seng302.models.Boat;
import java.util.ArrayList;
import static org.junit.Assert.*;
/**
* Created by Haoming on 18/03/17.
*/
public class TeamsParserTest {
private TeamsParser tp;
@Before
public void readFile() {
tp = new TeamsParser("doc/examples/teams.xml");
}
@Test
public void getBoats() throws Exception {
ArrayList<Boat> boats = tp.getBoats();
assertEquals(6, boats.size(), 1e-10);
assertEquals("Oracle Team USA", boats.get(0).getTeamName());
assertEquals(23.4, boats.get(0).getVelocity(), 1e-10);
assertEquals("Groupama Team France", boats.get(5).getTeamName());
assertEquals(28.8, boats.get(5).getVelocity(), 1e-10);
}
}