Skip to content

Commit 4aff498

Browse files
chore(internal): add some tests for union classes (#501)
1 parent 35fd786 commit 4aff498

File tree

2 files changed

+173
-0
lines changed

2 files changed

+173
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.tryfinch.api.models
4+
5+
import org.assertj.core.api.Assertions.assertThat
6+
import org.junit.jupiter.api.Test
7+
8+
internal class DocumentRetreiveResponseTest {
9+
10+
@Test
11+
fun ofW42020() {
12+
val w42020 = W42020.builder().build()
13+
14+
val documentRetreiveResponse = DocumentRetreiveResponse.ofW42020(w42020)
15+
16+
assertThat(documentRetreiveResponse.w42020()).contains(w42020)
17+
assertThat(documentRetreiveResponse.w42005()).isEmpty
18+
}
19+
20+
@Test
21+
fun ofW42005() {
22+
val w42005 = W42005.builder().build()
23+
24+
val documentRetreiveResponse = DocumentRetreiveResponse.ofW42005(w42005)
25+
26+
assertThat(documentRetreiveResponse.w42020()).isEmpty
27+
assertThat(documentRetreiveResponse.w42005()).contains(w42005)
28+
}
29+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
3+
package com.tryfinch.api.models
4+
5+
import org.assertj.core.api.Assertions.assertThat
6+
import org.junit.jupiter.api.Test
7+
8+
internal class WebhookEventTest {
9+
10+
@Test
11+
fun ofAccountUpdated() {
12+
val accountUpdated =
13+
AccountUpdateEvent.builder().accountId("account_id").companyId("company_id").build()
14+
15+
val webhookEvent = WebhookEvent.ofAccountUpdated(accountUpdated)
16+
17+
assertThat(webhookEvent.accountUpdated()).contains(accountUpdated)
18+
assertThat(webhookEvent.jobCompletion()).isEmpty
19+
assertThat(webhookEvent.companyUpdated()).isEmpty
20+
assertThat(webhookEvent.directory()).isEmpty
21+
assertThat(webhookEvent.employment()).isEmpty
22+
assertThat(webhookEvent.individual()).isEmpty
23+
assertThat(webhookEvent.payment()).isEmpty
24+
assertThat(webhookEvent.payStatement()).isEmpty
25+
}
26+
27+
@Test
28+
fun ofJobCompletion() {
29+
val jobCompletion =
30+
JobCompletionEvent.builder().accountId("account_id").companyId("company_id").build()
31+
32+
val webhookEvent = WebhookEvent.ofJobCompletion(jobCompletion)
33+
34+
assertThat(webhookEvent.accountUpdated()).isEmpty
35+
assertThat(webhookEvent.jobCompletion()).contains(jobCompletion)
36+
assertThat(webhookEvent.companyUpdated()).isEmpty
37+
assertThat(webhookEvent.directory()).isEmpty
38+
assertThat(webhookEvent.employment()).isEmpty
39+
assertThat(webhookEvent.individual()).isEmpty
40+
assertThat(webhookEvent.payment()).isEmpty
41+
assertThat(webhookEvent.payStatement()).isEmpty
42+
}
43+
44+
@Test
45+
fun ofCompanyUpdated() {
46+
val companyUpdated =
47+
CompanyEvent.builder().accountId("account_id").companyId("company_id").build()
48+
49+
val webhookEvent = WebhookEvent.ofCompanyUpdated(companyUpdated)
50+
51+
assertThat(webhookEvent.accountUpdated()).isEmpty
52+
assertThat(webhookEvent.jobCompletion()).isEmpty
53+
assertThat(webhookEvent.companyUpdated()).contains(companyUpdated)
54+
assertThat(webhookEvent.directory()).isEmpty
55+
assertThat(webhookEvent.employment()).isEmpty
56+
assertThat(webhookEvent.individual()).isEmpty
57+
assertThat(webhookEvent.payment()).isEmpty
58+
assertThat(webhookEvent.payStatement()).isEmpty
59+
}
60+
61+
@Test
62+
fun ofDirectory() {
63+
val directory =
64+
DirectoryEvent.builder().accountId("account_id").companyId("company_id").build()
65+
66+
val webhookEvent = WebhookEvent.ofDirectory(directory)
67+
68+
assertThat(webhookEvent.accountUpdated()).isEmpty
69+
assertThat(webhookEvent.jobCompletion()).isEmpty
70+
assertThat(webhookEvent.companyUpdated()).isEmpty
71+
assertThat(webhookEvent.directory()).contains(directory)
72+
assertThat(webhookEvent.employment()).isEmpty
73+
assertThat(webhookEvent.individual()).isEmpty
74+
assertThat(webhookEvent.payment()).isEmpty
75+
assertThat(webhookEvent.payStatement()).isEmpty
76+
}
77+
78+
@Test
79+
fun ofEmployment() {
80+
val employment =
81+
EmploymentEvent.builder().accountId("account_id").companyId("company_id").build()
82+
83+
val webhookEvent = WebhookEvent.ofEmployment(employment)
84+
85+
assertThat(webhookEvent.accountUpdated()).isEmpty
86+
assertThat(webhookEvent.jobCompletion()).isEmpty
87+
assertThat(webhookEvent.companyUpdated()).isEmpty
88+
assertThat(webhookEvent.directory()).isEmpty
89+
assertThat(webhookEvent.employment()).contains(employment)
90+
assertThat(webhookEvent.individual()).isEmpty
91+
assertThat(webhookEvent.payment()).isEmpty
92+
assertThat(webhookEvent.payStatement()).isEmpty
93+
}
94+
95+
@Test
96+
fun ofIndividual() {
97+
val individual =
98+
IndividualEvent.builder().accountId("account_id").companyId("company_id").build()
99+
100+
val webhookEvent = WebhookEvent.ofIndividual(individual)
101+
102+
assertThat(webhookEvent.accountUpdated()).isEmpty
103+
assertThat(webhookEvent.jobCompletion()).isEmpty
104+
assertThat(webhookEvent.companyUpdated()).isEmpty
105+
assertThat(webhookEvent.directory()).isEmpty
106+
assertThat(webhookEvent.employment()).isEmpty
107+
assertThat(webhookEvent.individual()).contains(individual)
108+
assertThat(webhookEvent.payment()).isEmpty
109+
assertThat(webhookEvent.payStatement()).isEmpty
110+
}
111+
112+
@Test
113+
fun ofPayment() {
114+
val payment = PaymentEvent.builder().accountId("account_id").companyId("company_id").build()
115+
116+
val webhookEvent = WebhookEvent.ofPayment(payment)
117+
118+
assertThat(webhookEvent.accountUpdated()).isEmpty
119+
assertThat(webhookEvent.jobCompletion()).isEmpty
120+
assertThat(webhookEvent.companyUpdated()).isEmpty
121+
assertThat(webhookEvent.directory()).isEmpty
122+
assertThat(webhookEvent.employment()).isEmpty
123+
assertThat(webhookEvent.individual()).isEmpty
124+
assertThat(webhookEvent.payment()).contains(payment)
125+
assertThat(webhookEvent.payStatement()).isEmpty
126+
}
127+
128+
@Test
129+
fun ofPayStatement() {
130+
val payStatement =
131+
PayStatementEvent.builder().accountId("account_id").companyId("company_id").build()
132+
133+
val webhookEvent = WebhookEvent.ofPayStatement(payStatement)
134+
135+
assertThat(webhookEvent.accountUpdated()).isEmpty
136+
assertThat(webhookEvent.jobCompletion()).isEmpty
137+
assertThat(webhookEvent.companyUpdated()).isEmpty
138+
assertThat(webhookEvent.directory()).isEmpty
139+
assertThat(webhookEvent.employment()).isEmpty
140+
assertThat(webhookEvent.individual()).isEmpty
141+
assertThat(webhookEvent.payment()).isEmpty
142+
assertThat(webhookEvent.payStatement()).contains(payStatement)
143+
}
144+
}

0 commit comments

Comments
 (0)