Skip to content

Commit 069892c

Browse files
fix(client): mark some request bodies as optional (#263)
chore(internal): use `assertNotNull` in tests for type narrowing chore(internal): remove unnecessary non-null asserts in tests
1 parent 4cbbc9f commit 069892c

44 files changed

Lines changed: 123 additions & 88 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForCustomerParamsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package com.withorb.api.models
44

5+
import kotlin.test.assertNotNull
56
import org.assertj.core.api.Assertions.assertThat
67
import org.junit.jupiter.api.Test
78

@@ -29,7 +30,7 @@ class AlertCreateForCustomerParamsTest {
2930

3031
val body = params._body()
3132

32-
assertThat(body).isNotNull
33+
assertNotNull(body)
3334
assertThat(body.currency()).isEqualTo("currency")
3435
assertThat(body.type()).isEqualTo(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED)
3536
assertThat(body.thresholds())
@@ -47,7 +48,7 @@ class AlertCreateForCustomerParamsTest {
4748

4849
val body = params._body()
4950

50-
assertThat(body).isNotNull
51+
assertNotNull(body)
5152
assertThat(body.currency()).isEqualTo("currency")
5253
assertThat(body.type()).isEqualTo(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED)
5354
}

orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParamsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package com.withorb.api.models
44

5+
import kotlin.test.assertNotNull
56
import org.assertj.core.api.Assertions.assertThat
67
import org.junit.jupiter.api.Test
78

@@ -33,7 +34,7 @@ class AlertCreateForExternalCustomerParamsTest {
3334

3435
val body = params._body()
3536

36-
assertThat(body).isNotNull
37+
assertNotNull(body)
3738
assertThat(body.currency()).isEqualTo("currency")
3839
assertThat(body.type()).isEqualTo(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED)
3940
assertThat(body.thresholds())
@@ -53,7 +54,7 @@ class AlertCreateForExternalCustomerParamsTest {
5354

5455
val body = params._body()
5556

56-
assertThat(body).isNotNull
57+
assertNotNull(body)
5758
assertThat(body.currency()).isEqualTo("currency")
5859
assertThat(body.type()).isEqualTo(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED)
5960
}

orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package com.withorb.api.models
44

5+
import kotlin.test.assertNotNull
56
import org.assertj.core.api.Assertions.assertThat
67
import org.junit.jupiter.api.Test
78

@@ -31,7 +32,7 @@ class AlertCreateForSubscriptionParamsTest {
3132

3233
val body = params._body()
3334

34-
assertThat(body).isNotNull
35+
assertNotNull(body)
3536
assertThat(body.thresholds())
3637
.isEqualTo(
3738
listOf(AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build())
@@ -53,7 +54,7 @@ class AlertCreateForSubscriptionParamsTest {
5354

5455
val body = params._body()
5556

56-
assertThat(body).isNotNull
57+
assertNotNull(body)
5758
assertThat(body.thresholds())
5859
.isEqualTo(
5960
listOf(AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build())

orb-java-core/src/test/kotlin/com/withorb/api/models/AlertUpdateParamsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package com.withorb.api.models
44

5+
import kotlin.test.assertNotNull
56
import org.assertj.core.api.Assertions.assertThat
67
import org.junit.jupiter.api.Test
78

@@ -25,7 +26,7 @@ class AlertUpdateParamsTest {
2526

2627
val body = params._body()
2728

28-
assertThat(body).isNotNull
29+
assertNotNull(body)
2930
assertThat(body.thresholds())
3031
.isEqualTo(listOf(AlertUpdateParams.Threshold.builder().value(0.0).build()))
3132
}
@@ -40,7 +41,7 @@ class AlertUpdateParamsTest {
4041

4142
val body = params._body()
4243

43-
assertThat(body).isNotNull
44+
assertNotNull(body)
4445
assertThat(body.thresholds())
4546
.isEqualTo(listOf(AlertUpdateParams.Threshold.builder().value(0.0).build()))
4647
}

orb-java-core/src/test/kotlin/com/withorb/api/models/CouponCreateParamsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package com.withorb.api.models
44

5+
import kotlin.test.assertNotNull
56
import org.assertj.core.api.Assertions.assertThat
67
import org.junit.jupiter.api.Test
78

@@ -29,7 +30,7 @@ class CouponCreateParamsTest {
2930

3031
val body = params._body()
3132

32-
assertThat(body).isNotNull
33+
assertNotNull(body)
3334
assertThat(body.discount())
3435
.isEqualTo(
3536
CouponCreateParams.Discount.ofNewCouponPercentage(
@@ -57,7 +58,7 @@ class CouponCreateParamsTest {
5758

5859
val body = params._body()
5960

60-
assertThat(body).isNotNull
61+
assertNotNull(body)
6162
assertThat(body.discount())
6263
.isEqualTo(
6364
CouponCreateParams.Discount.ofNewCouponPercentage(

orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteCreateParamsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package com.withorb.api.models
44

5+
import kotlin.test.assertNotNull
56
import org.assertj.core.api.Assertions.assertThat
67
import org.junit.jupiter.api.Test
78

@@ -37,7 +38,7 @@ class CreditNoteCreateParamsTest {
3738

3839
val body = params._body()
3940

40-
assertThat(body).isNotNull
41+
assertNotNull(body)
4142
assertThat(body.lineItems())
4243
.isEqualTo(
4344
listOf(
@@ -65,7 +66,7 @@ class CreditNoteCreateParamsTest {
6566

6667
val body = params._body()
6768

68-
assertThat(body).isNotNull
69+
assertNotNull(body)
6970
assertThat(body.lineItems())
7071
.isEqualTo(
7172
listOf(

orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParamsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package com.withorb.api.models
44

5+
import kotlin.test.assertNotNull
56
import org.assertj.core.api.Assertions.assertThat
67
import org.junit.jupiter.api.Test
78

@@ -29,7 +30,7 @@ class CustomerBalanceTransactionCreateParamsTest {
2930

3031
val body = params._body()
3132

32-
assertThat(body).isNotNull
33+
assertNotNull(body)
3334
assertThat(body.amount()).isEqualTo("amount")
3435
assertThat(body.type()).isEqualTo(CustomerBalanceTransactionCreateParams.Type.INCREMENT)
3536
assertThat(body.description()).contains("description")
@@ -46,7 +47,7 @@ class CustomerBalanceTransactionCreateParamsTest {
4647

4748
val body = params._body()
4849

49-
assertThat(body).isNotNull
50+
assertNotNull(body)
5051
assertThat(body.amount()).isEqualTo("amount")
5152
assertThat(body.type()).isEqualTo(CustomerBalanceTransactionCreateParams.Type.INCREMENT)
5253
}

orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreateParamsTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.withorb.api.models
44

55
import com.withorb.api.core.JsonValue
6+
import kotlin.test.assertNotNull
67
import org.assertj.core.api.Assertions.assertThat
78
import org.junit.jupiter.api.Test
89

@@ -157,7 +158,7 @@ class CustomerCreateParamsTest {
157158

158159
val body = params._body()
159160

160-
assertThat(body).isNotNull
161+
assertNotNull(body)
161162
assertThat(body.email()).isEqualTo("dev@stainlessapi.com")
162163
assertThat(body.name()).isEqualTo("x")
163164
assertThat(body.accountingSyncConfiguration())
@@ -241,7 +242,7 @@ class CustomerCreateParamsTest {
241242

242243
val body = params._body()
243244

244-
assertThat(body).isNotNull
245+
assertNotNull(body)
245246
assertThat(body.email()).isEqualTo("dev@stainlessapi.com")
246247
assertThat(body.name()).isEqualTo("x")
247248
}

orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParamsTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest {
9999

100100
val body = params._body()
101101

102-
assertThat(body).isNotNull
103102
assertThat(body)
104103
.isEqualTo(
105104
CustomerCreditLedgerCreateEntryByExternalIdParams.Body
@@ -153,7 +152,6 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest {
153152

154153
val body = params._body()
155154

156-
assertThat(body).isNotNull
157155
assertThat(body)
158156
.isEqualTo(
159157
CustomerCreditLedgerCreateEntryByExternalIdParams.Body

orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParamsTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class CustomerCreditLedgerCreateEntryParamsTest {
9999

100100
val body = params._body()
101101

102-
assertThat(body).isNotNull
103102
assertThat(body)
104103
.isEqualTo(
105104
CustomerCreditLedgerCreateEntryParams.Body
@@ -153,7 +152,6 @@ class CustomerCreditLedgerCreateEntryParamsTest {
153152

154153
val body = params._body()
155154

156-
assertThat(body).isNotNull
157155
assertThat(body)
158156
.isEqualTo(
159157
CustomerCreditLedgerCreateEntryParams.Body

0 commit comments

Comments
 (0)