-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMultipleComponentsTest.java
More file actions
79 lines (72 loc) · 2.53 KB
/
Copy pathMultipleComponentsTest.java
File metadata and controls
79 lines (72 loc) · 2.53 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
71
72
73
74
75
76
77
78
79
package Model;
import com.lob.model.MultipleComponents;
import org.testng.annotations.*;
import org.testng.Assert;
public class MultipleComponentsTest {
@DataProvider (name = "multiple-components-data-provider")
public Object[][] multipleComponentsDpMethod(){
return new Object[][] {
{"recipient", "fake recipient"},
{"primary_line", "fake primary_line"},
{"secondary_line", "fake secondary_line"},
{"urbanization", "fake urbanization"},
{"city", "fake city"},
{"state", "fake state"},
{"zip_code", "11111"},
};
}
@Test(enabled=true, dataProvider = "multiple-components-data-provider")
public void multipleComponentsTestWithProvidedValue(String prop, String val) throws Exception {
MultipleComponents rec = new MultipleComponents();
switch (prop) {
case "recipient": {
rec.setRecipient(val);
Assert.assertEquals(rec.getRecipient(), val);
break;
}
case "primary_line": {
rec.setPrimaryLine(val);
Assert.assertEquals(rec.getPrimaryLine(), val);
break;
}
case "secondary_line": {
rec.setSecondaryLine(val);
Assert.assertEquals(rec.getSecondaryLine(), val);
break;
}
case "urbanization": {
rec.setUrbanization(val);
Assert.assertEquals(rec.getUrbanization(), val);
break;
}
case "city": {
rec.setCity(val);
Assert.assertEquals(rec.getCity(), val);
break;
}
case "state": {
rec.setState(val);
Assert.assertEquals(rec.getState(), val);
break;
}
case "zip_code": {
rec.setZipCode(val);
Assert.assertEquals(rec.getZipCode(), val);
break;
}
default:
throw new Exception("Wrong prop name");
}
}
@Test(enabled=true)
public void multipleComponentsTestCatchesException() {
MultipleComponents rec = new MultipleComponents();
Assert.assertNull(rec.getZipCode());
try {
rec.setZipCode("Nope");
throw new Exception("Should Throw");
} catch (Exception err) {
Assert.assertEquals(err.getMessage(), "Invalid zip_code provided");
}
}
}