mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
c08504293b
#story[377] #pair[zyt10, ptg19]
61 lines
1.8 KiB
Java
61 lines
1.8 KiB
Java
package seng302.models.parsers;
|
|
|
|
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import seng302.models.mark.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
/**
|
|
* To test if course parser works as expected.
|
|
* Created by Haoming on 17/03/17.
|
|
*/
|
|
public class CourseParserTest {
|
|
|
|
private CourseParser cp;
|
|
|
|
@Before
|
|
public void initializeParser() throws Exception {
|
|
cp = new CourseParser("doc/examples/course.xml");
|
|
}
|
|
|
|
@Test
|
|
public void getGates() throws Exception {
|
|
ArrayList<Mark> course = cp.getCourse();
|
|
|
|
assertTrue(MarkType.GATE_MARK == course.get(0).getMarkType());
|
|
|
|
GateMark gateMark1 = (GateMark) course.get(0);
|
|
assertEquals(32.293834, gateMark1.getSingleMark2().getLatitude(), 0.00000001);
|
|
assertEquals(-64.855195, gateMark1.getSingleMark2().getLongitude(), 0.00000001);
|
|
|
|
GateMark gateMark2 = (GateMark) course.get(5);
|
|
|
|
assertEquals("Finish1", gateMark2.getSingleMark1().getName());
|
|
assertEquals("Finish2", gateMark2.getSingleMark2().getName());
|
|
assertEquals(32.318303, gateMark2.getSingleMark2().getLatitude(), 0.00000001);
|
|
assertEquals(-64.834974, gateMark2.getSingleMark2().getLongitude(), 0.00000001);
|
|
}
|
|
|
|
@Test
|
|
public void getMarks() throws Exception {
|
|
ArrayList<Mark> course = cp.getCourse();
|
|
assertEquals("Mid Mark", course.get(1).getName());
|
|
}
|
|
|
|
@Test
|
|
public void getOrder() {
|
|
ArrayList<Mark> course = cp.getCourse();
|
|
assertEquals(6, course.size());
|
|
assertEquals("Start", course.get(0).getName());
|
|
assertEquals("Mid Mark", course.get(1).getName());
|
|
assertEquals("Leeward Gate", course.get(2).getName());
|
|
assertEquals("Windward Gate", course.get(3).getName());
|
|
assertEquals("Leeward Gate", course.get(4).getName());
|
|
assertEquals("Finish", course.get(5).getName());
|
|
}
|
|
|
|
} |