-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBillingGroupTest.java
More file actions
82 lines (74 loc) · 2.74 KB
/
Copy pathBillingGroupTest.java
File metadata and controls
82 lines (74 loc) · 2.74 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
80
81
82
package Model;
import com.lob.model.BillingGroup;
import java.time.OffsetDateTime;
import org.testng.annotations.*;
import org.testng.Assert;
public class BillingGroupTest {
@DataProvider (name = "billing-group-data-provider")
public Object[][] billingGroupDpMethod() {
return new Object[][] {
{"description", "fake description"},
{"name", "fake name"},
{"id", "bg_fakeId"},
{"date_created", OffsetDateTime.now()},
{"date_modified", OffsetDateTime.now()},
{"object", BillingGroup.ObjectEnum.BILLING_GROUP},
};
}
@Test(enabled=true, dataProvider = "billing-group-data-provider")
public void billingGroupTestWithProvidedValue(String prop, Object val) throws Exception {
BillingGroup rec = new BillingGroup();
switch (prop) {
case "description": {
String castedVal = (String)val;
rec.setDescription(castedVal);
Assert.assertEquals(rec.getDescription(), castedVal);
break;
}
case "name": {
String castedVal = (String)val;
rec.setName(castedVal);
Assert.assertEquals(rec.getName(), castedVal);
break;
}
case "id": {
String castedVal = (String)val;
rec.setId(castedVal);
Assert.assertEquals(rec.getId(), castedVal);
break;
}
case "date_created": {
OffsetDateTime castedVal = (OffsetDateTime)val;
rec.setDateCreated(castedVal);
Assert.assertEquals(rec.getDateCreated(), castedVal);
break;
}
case "date_modified": {
OffsetDateTime castedVal = (OffsetDateTime)val;
rec.setDateModified(castedVal);
Assert.assertEquals(rec.getDateModified(), castedVal);
break;
}
case "object": {
BillingGroup.ObjectEnum castedVal = (BillingGroup.ObjectEnum)val;
rec.setObject(castedVal);
Assert.assertEquals(rec.getObject(), castedVal);
break;
}
default:
throw new Exception("Wrong prop name: " + prop);
}
}
@Test(enabled=true)
public void billingGroupTestCatchesInvalidId() {
BillingGroup rec = new BillingGroup();
Assert.assertNull(rec.getId());
String invalidValue = "Nope";
try {
rec.setId(invalidValue);
throw new Exception("Should Throw");
} catch (Exception err) {
Assert.assertEquals(err.getMessage(), "Invalid id provided");
}
}
}