-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathZipLookupCityTest.java
More file actions
70 lines (63 loc) · 2.19 KB
/
Copy pathZipLookupCityTest.java
File metadata and controls
70 lines (63 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package Model;
import com.lob.model.ZipLookupCity;
import org.testng.annotations.*;
import org.testng.Assert;
public class ZipLookupCityTest {
@DataProvider (name = "zip-lookup-city-data-provider")
public Object[][] zipLookupCityDpMethod(){
return new Object[][] {
{"city", "fake city"},
{"state", "fake state"},
{"county", "fake country"},
{"county_fips", "11111"},
{"preferred", true},
{"preferred", false},
};
}
@Test(enabled=true, dataProvider = "zip-lookup-city-data-provider")
public void zipLookupCityTestWithProvidedValue(String prop, Object val) throws Exception {
ZipLookupCity rec = new ZipLookupCity();
if (prop == "preferred") {
Boolean castedVal = (Boolean)val;
rec.setPreferred(castedVal);
Assert.assertEquals(rec.getPreferred(), castedVal);
} else {
String castedVal = (String)val;
switch (prop) {
case "city": {
rec.setCity(castedVal);
Assert.assertEquals(rec.getCity(), castedVal);
break;
}
case "state": {
rec.setState(castedVal);
Assert.assertEquals(rec.getState(), castedVal);
break;
}
case "county": {
rec.setCounty(castedVal);
Assert.assertEquals(rec.getCounty(), castedVal);
break;
}
case "county_fips": {
rec.setCountyFips(castedVal);
Assert.assertEquals(rec.getCountyFips(), castedVal);
break;
}
default:
throw new Exception("Wrong prop name: " + prop);
}
}
}
@Test(enabled=true)
public void zipLookupCityTestInvalidCountyFips() {
ZipLookupCity rec = new ZipLookupCity();
Assert.assertNull(rec.getCountyFips());
try {
rec.setCountyFips("Nope");
throw new Exception("Should Throw");
} catch (Exception err) {
Assert.assertEquals(err.getMessage(), "Invalid county_fips provided");
}
}
}