| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
package footleg.cavesurvey.data.model; |
| 20 |
|
| 21 |
import static org.junit.Assert.*; |
| 22 |
|
| 23 |
import org.junit.Test; |
| 24 |
|
| 25 |
import footleg.cavesurvey.data.model.SurveyStation; |
| 26 |
import footleg.cavesurvey.data.model.SurveyStation.FixType; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public class SurveyStationTest { |
| 36 |
|
| 37 |
@Test |
| 38 |
public void testSetEntrance() { |
| 39 |
int stnID = 123; |
| 40 |
|
| 41 |
SurveyStation stn = new SurveyStation( stnID ); |
| 42 |
|
| 43 |
assertFalse( "Station entrance should be false if not set.", stn.isEntrance() ); |
| 44 |
|
| 45 |
stn.setEntrance(true); |
| 46 |
assertTrue( "Checking station was set to be an entrance.", stn.isEntrance() ); |
| 47 |
|
| 48 |
stn.setEntrance(false); |
| 49 |
assertFalse( "Checking station was reset to not be an entrance", stn.isEntrance() ); |
| 50 |
} |
| 51 |
|
| 52 |
@Test |
| 53 |
public void testSetFixed() { |
| 54 |
int stnID = 123; |
| 55 |
double easting = 4800456.0; |
| 56 |
double northing = 4800789.75; |
| 57 |
double altitude = 8900.45; |
| 58 |
double easting2 = 123.45; |
| 59 |
double northing2 = 678.00; |
| 60 |
double altitude2 = 0.0; |
| 61 |
|
| 62 |
SurveyStation stn = new SurveyStation( stnID ); |
| 63 |
|
| 64 |
assertFalse( "Station should not be fixed by default.", stn.isFixed() ); |
| 65 |
|
| 66 |
|
| 67 |
stn.setFixed(FixType.GPS, easting, northing, altitude); |
| 68 |
assertTrue( "Checking station was set to be fixed.", stn.isFixed() ); |
| 69 |
|
| 70 |
assertEquals("Getter for Easting", easting, stn.getEasting(), 0.0 ); |
| 71 |
assertEquals("Getter for Northing", northing, stn.getNorthing(), 0.0 ); |
| 72 |
assertEquals("Getter for Altitude", altitude, stn.getAltitude(), 0.0 ); |
| 73 |
assertEquals("Getter for fix type GPS", FixType.GPS, stn.getFixType() ); |
| 74 |
|
| 75 |
|
| 76 |
stn.setFixed(FixType.OTHER, easting2, northing2, altitude2); |
| 77 |
assertTrue( "Checking station was set to be fixed.", stn.isFixed() ); |
| 78 |
|
| 79 |
assertEquals("Getter for Easting", easting2, stn.getEasting(), 0.0 ); |
| 80 |
assertEquals("Getter for Northing", northing2, stn.getNorthing(), 0.0 ); |
| 81 |
assertEquals("Getter for Altitude", altitude2, stn.getAltitude(), 0.0 ); |
| 82 |
assertEquals("Getter for fix type Other", FixType.OTHER, stn.getFixType() ); |
| 83 |
|
| 84 |
|
| 85 |
stn.clearFixedStn(); |
| 86 |
assertFalse( "Station fix was cleared", stn.isFixed() ); |
| 87 |
} |
| 88 |
|
| 89 |
@Test |
| 90 |
public void testSetId() { |
| 91 |
int stnID = 67899035; |
| 92 |
|
| 93 |
SurveyStation stn = new SurveyStation( stnID ); |
| 94 |
assertEquals("Getter for Id", stnID, stn.getId() ); |
| 95 |
} |
| 96 |
|
| 97 |
@Test |
| 98 |
public void testGetName() { |
| 99 |
int stnID = 12; |
| 100 |
String defaultName = "12"; |
| 101 |
int stnID2 = 345; |
| 102 |
String defaultName2 = "345"; |
| 103 |
String newName = "ABC"; |
| 104 |
|
| 105 |
SurveyStation stn = new SurveyStation( stnID ); |
| 106 |
|
| 107 |
|
| 108 |
assertEquals("Getter for Name based on Id", defaultName, stn.getName() ); |
| 109 |
|
| 110 |
|
| 111 |
stn.setId(stnID2); |
| 112 |
assertEquals("Getter for Name based on changed Id", defaultName2, stn.getName() ); |
| 113 |
|
| 114 |
|
| 115 |
stn.setName(newName); |
| 116 |
assertEquals("Getter for Name set explicitly", newName, stn.getName() ); |
| 117 |
|
| 118 |
|
| 119 |
stn.setId(92364); |
| 120 |
assertEquals("Getter for Name set explicitly", newName, stn.getName() ); |
| 121 |
} |
| 122 |
|
| 123 |
@Test |
| 124 |
public void testSetComment() { |
| 125 |
int stnID = 12; |
| 126 |
String commentText = "This is a station comment. It is quite long can contains\ra line break."; |
| 127 |
|
| 128 |
SurveyStation stn = new SurveyStation( stnID ); |
| 129 |
|
| 130 |
stn.setComment(commentText); |
| 131 |
assertEquals("Getter for Comment", commentText, stn.getComment() ); |
| 132 |
} |
| 133 |
|
| 134 |
@Test |
| 135 |
public void testClone() { |
| 136 |
int stnID = 12; |
| 137 |
String newName = "ABC"; |
| 138 |
String commentText = "This is a station comment. It is quite long can contains\ra line break."; |
| 139 |
double easting = 4800456.0; |
| 140 |
double northing = 4800789.75; |
| 141 |
double altitude = 8900.45; |
| 142 |
|
| 143 |
SurveyStation stn = new SurveyStation( stnID ); |
| 144 |
stn.setName(newName); |
| 145 |
stn.setComment(commentText); |
| 146 |
stn.setEntrance(true); |
| 147 |
stn.setFixed(FixType.GPS, easting, northing, altitude); |
| 148 |
|
| 149 |
SurveyStation clone = stn.clone(); |
| 150 |
|
| 151 |
assertEquals( "Station ID from clone", stnID, clone.getId() ); |
| 152 |
assertEquals( "Station Name from clone", newName, clone.getName() ); |
| 153 |
assertEquals( "Station Comment from clone", commentText, clone.getComment() ); |
| 154 |
assertTrue( "Station is entrance from clone", clone.isEntrance() ); |
| 155 |
assertTrue( "Station is fixed from clone", clone.isFixed() ); |
| 156 |
assertEquals( "Station is fix type from clone", FixType.GPS, clone.getFixType() ); |
| 157 |
assertEquals( "Station easting from clone", easting, clone.getEasting(), 0.0 ); |
| 158 |
assertEquals( "Station northing from clone", northing, clone.getNorthing(), 0.0 ); |
| 159 |
assertEquals( "Station altitude from clone", altitude, clone.getAltitude(), 0.0 ); |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
stn.setId(8765); |
| 164 |
stn.setName("iusdfhbs"); |
| 165 |
stn.setComment("iadrkuKAJ RDFC J JGV JYG BHF HF NJH B CN HJC NGF XB HGF CBNJCFN JFC NJ CF"); |
| 166 |
stn.setEntrance(false); |
| 167 |
stn.setFixed(FixType.OTHER, 1.2, 3.4, 5.6); |
| 168 |
|
| 169 |
assertEquals( "Station ID from clone", stnID, clone.getId() ); |
| 170 |
assertEquals( "Station Name from clone", newName, clone.getName() ); |
| 171 |
assertEquals( "Station Comment from clone", commentText, clone.getComment() ); |
| 172 |
assertTrue( "Station is entrance from clone", clone.isEntrance() ); |
| 173 |
assertTrue( "Station is fixed from clone", clone.isFixed() ); |
| 174 |
assertEquals( "Station is fix type from clone", FixType.GPS, clone.getFixType() ); |
| 175 |
assertEquals( "Station easting from clone", easting, clone.getEasting(), 0.0 ); |
| 176 |
assertEquals( "Station northing from clone", northing, clone.getNorthing(), 0.0 ); |
| 177 |
assertEquals( "Station altitude from clone", altitude, clone.getAltitude(), 0.0 ); |
| 178 |
|
| 179 |
} |
| 180 |
|
| 181 |
} |