-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathEventsTest.java
More file actions
82 lines (74 loc) · 2.61 KB
/
Copy pathEventsTest.java
File metadata and controls
82 lines (74 loc) · 2.61 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.Events;
import com.lob.model.EventType;
import java.time.OffsetDateTime;
import org.testng.annotations.*;
import org.testng.Assert;
public class EventsTest {
@DataProvider (name = "events-data-provider")
public Object[][] eventsDpMethod(){
return new Object[][] {
{"id", "evt_fakeId"},
{"body", new Object()},
{"reference_id", "fake reference id"},
{"event_type", new EventType()},
{"date_created", OffsetDateTime.now()},
{"object", Events.ObjectEnum.EVENT},
};
}
@Test(enabled=true, dataProvider = "events-data-provider")
public void eventsTestWithProvidedValue(String prop, Object val) throws Exception {
Events rec = new Events();
switch (prop) {
case "id": {
String castedVal = (String)val;
rec.setId(castedVal);
Assert.assertEquals(rec.getId(), castedVal);
break;
}
case "body": {
Object castedVal = (Object)val;
rec.setBody(castedVal);
Assert.assertEquals(rec.getBody(), castedVal);
break;
}
case "reference_id": {
String castedVal = (String)val;
rec.setReferenceId(castedVal);
Assert.assertEquals(rec.getReferenceId(), castedVal);
break;
}
case "event_type": {
EventType castedVal = (EventType)val;
rec.setEventType(castedVal);
Assert.assertEquals(rec.getEventType(), castedVal);
break;
}
case "date_created": {
OffsetDateTime castedVal = (OffsetDateTime)val;
rec.setDateCreated(castedVal);
Assert.assertEquals(rec.getDateCreated(), castedVal);
break;
}
case "object": {
Events.ObjectEnum castedVal = (Events.ObjectEnum)val;
rec.setObject(castedVal);
Assert.assertEquals(rec.getObject(), castedVal);
break;
}
default:
throw new Exception("Wrong prop name: " + prop);
}
}
@Test(enabled=true)
public void eventsTestInvalidId() {
Events rec = new Events();
Assert.assertNull(rec.getId());
try {
rec.setId("Nope");
throw new Exception("Should Throw");
} catch (Exception err) {
Assert.assertEquals(err.getMessage(), "Invalid id provided");
}
}
}