Skip to content

Commit de6247c

Browse files
docs: refine comments on multipart params (#552)
chore(internal): make multipart assertions more robust chore(internal): remove unnecessary `assertNotNull` calls
1 parent 43441d9 commit de6247c

File tree

57 files changed

+6
-184
lines changed

Some content is hidden

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

57 files changed

+6
-184
lines changed

lithic-java-core/src/main/kotlin/com/lithic/api/core/http/HttpRequestBodies.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import com.fasterxml.jackson.databind.json.JsonMapper
99
import com.fasterxml.jackson.databind.node.JsonNodeType
1010
import com.lithic.api.core.MultipartField
1111
import com.lithic.api.errors.LithicInvalidDataException
12-
import java.io.ByteArrayInputStream
1312
import java.io.InputStream
1413
import java.io.OutputStream
1514
import kotlin.jvm.optionals.getOrNull
@@ -74,12 +73,12 @@ internal fun multipartFormData(
7473
when (node.nodeType) {
7574
JsonNodeType.MISSING,
7675
JsonNodeType.NULL -> emptySequence()
77-
JsonNodeType.BINARY -> sequenceOf(name to ByteArrayInputStream(node.binaryValue()))
78-
JsonNodeType.STRING -> sequenceOf(name to node.textValue().toInputStream())
76+
JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream())
77+
JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream())
7978
JsonNodeType.BOOLEAN ->
80-
sequenceOf(name to node.booleanValue().toString().toInputStream())
79+
sequenceOf(name to node.booleanValue().toString().inputStream())
8180
JsonNodeType.NUMBER ->
82-
sequenceOf(name to node.numberValue().toString().toInputStream())
81+
sequenceOf(name to node.numberValue().toString().inputStream())
8382
JsonNodeType.ARRAY ->
8483
sequenceOf(
8584
name to
@@ -104,7 +103,7 @@ internal fun multipartFormData(
104103
}
105104
}
106105
.joinToString(",")
107-
.toInputStream()
106+
.inputStream()
108107
)
109108
JsonNodeType.OBJECT ->
110109
node.fields().asSequence().flatMap { (key, value) ->
@@ -115,7 +114,7 @@ internal fun multipartFormData(
115114
throw LithicInvalidDataException("Unexpected JsonNode type: ${node.nodeType}")
116115
}
117116

118-
private fun String.toInputStream(): InputStream = ByteArrayInputStream(toByteArray())
117+
private fun String.inputStream(): InputStream = toByteArray().inputStream()
119118

120119
override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream)
121120

lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentDocumentReviewParamsTest.kt

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

55
import kotlin.jvm.optionals.getOrNull
6-
import kotlin.test.assertNotNull
76
import org.assertj.core.api.Assertions.assertThat
87
import org.junit.jupiter.api.Test
98

@@ -37,7 +36,6 @@ internal class AccountHolderSimulateEnrollmentDocumentReviewParamsTest {
3736

3837
val body = params._body()
3938

40-
assertNotNull(body)
4139
assertThat(body.documentUploadToken()).isEqualTo("document_upload_token")
4240
assertThat(body.status())
4341
.isEqualTo(AccountHolderSimulateEnrollmentDocumentReviewParams.Status.UPLOADED)
@@ -59,7 +57,6 @@ internal class AccountHolderSimulateEnrollmentDocumentReviewParamsTest {
5957

6058
val body = params._body()
6159

62-
assertNotNull(body)
6360
assertThat(body.documentUploadToken()).isEqualTo("document_upload_token")
6461
assertThat(body.status())
6562
.isEqualTo(AccountHolderSimulateEnrollmentDocumentReviewParams.Status.UPLOADED)

lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewParamsTest.kt

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

55
import kotlin.jvm.optionals.getOrNull
6-
import kotlin.test.assertNotNull
76
import org.assertj.core.api.Assertions.assertThat
87
import org.junit.jupiter.api.Test
98

@@ -35,7 +34,6 @@ internal class AccountHolderSimulateEnrollmentReviewParamsTest {
3534

3635
val body = params._body()
3736

38-
assertNotNull(body)
3937
assertThat(body.accountHolderToken()).contains("1415964d-4400-4d79-9fb3-eee0faaee4e4")
4038
assertThat(body.status())
4139
.contains(AccountHolderSimulateEnrollmentReviewParams.Status.ACCEPTED)
@@ -51,7 +49,5 @@ internal class AccountHolderSimulateEnrollmentReviewParamsTest {
5149
val params = AccountHolderSimulateEnrollmentReviewParams.builder().build()
5250

5351
val body = params._body()
54-
55-
assertNotNull(body)
5652
}
5753
}

lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParamsTest.kt

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

33
package com.lithic.api.models
44

5-
import kotlin.test.assertNotNull
65
import org.assertj.core.api.Assertions.assertThat
76
import org.junit.jupiter.api.Test
87

@@ -42,7 +41,6 @@ internal class AccountHolderUploadDocumentParamsTest {
4241

4342
val body = params._body()
4443

45-
assertNotNull(body)
4644
assertThat(body.documentType())
4745
.isEqualTo(AccountHolderUploadDocumentParams.DocumentType.EIN_LETTER)
4846
assertThat(body.entityToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")

lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountUpdateParamsTest.kt

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

33
package com.lithic.api.models
44

5-
import kotlin.test.assertNotNull
65
import org.assertj.core.api.Assertions.assertThat
76
import org.junit.jupiter.api.Test
87

@@ -64,7 +63,6 @@ internal class AccountUpdateParamsTest {
6463

6564
val body = params._body()
6665

67-
assertNotNull(body)
6866
assertThat(body.dailySpendLimit()).contains(1000L)
6967
assertThat(body.lifetimeSpendLimit()).contains(0L)
7068
assertThat(body.monthlySpendLimit()).contains(0L)
@@ -90,7 +88,5 @@ internal class AccountUpdateParamsTest {
9088
.build()
9189

9290
val body = params._body()
93-
94-
assertNotNull(body)
9591
}
9692
}

lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParamsTest.kt

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

55
import java.time.OffsetDateTime
6-
import kotlin.test.assertNotNull
76
import org.assertj.core.api.Assertions.assertThat
87
import org.junit.jupiter.api.Test
98

@@ -41,7 +40,6 @@ internal class AuthRuleV2BacktestCreateParamsTest {
4140

4241
val body = params._body()
4342

44-
assertNotNull(body)
4543
assertThat(body.end()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
4644
assertThat(body.start()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
4745
}
@@ -54,7 +52,5 @@ internal class AuthRuleV2BacktestCreateParamsTest {
5452
.build()
5553

5654
val body = params._body()
57-
58-
assertNotNull(body)
5955
}
6056
}

lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2DraftParamsTest.kt

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

33
package com.lithic.api.models
44

5-
import kotlin.test.assertNotNull
65
import org.assertj.core.api.Assertions.assertThat
76
import org.junit.jupiter.api.Test
87

@@ -58,7 +57,6 @@ internal class AuthRuleV2DraftParamsTest {
5857

5958
val body = params._body()
6059

61-
assertNotNull(body)
6260
assertThat(body.parameters())
6361
.contains(
6462
AuthRuleV2DraftParams.Parameters.ofConditionalBlock(
@@ -83,7 +81,5 @@ internal class AuthRuleV2DraftParamsTest {
8381
.build()
8482

8583
val body = params._body()
86-
87-
assertNotNull(body)
8884
}
8985
}

lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferCreateParamsTest.kt

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

33
package com.lithic.api.models
44

5-
import kotlin.test.assertNotNull
65
import org.assertj.core.api.Assertions.assertThat
76
import org.junit.jupiter.api.Test
87

@@ -38,7 +37,6 @@ internal class BookTransferCreateParamsTest {
3837

3938
val body = params._body()
4039

41-
assertNotNull(body)
4240
assertThat(body.amount()).isEqualTo(1L)
4341
assertThat(body.category()).isEqualTo(BookTransferCreateParams.Category.ADJUSTMENT)
4442
assertThat(body.fromFinancialAccountToken())
@@ -64,7 +62,6 @@ internal class BookTransferCreateParamsTest {
6462

6563
val body = params._body()
6664

67-
assertNotNull(body)
6865
assertThat(body.amount()).isEqualTo(1L)
6966
assertThat(body.category()).isEqualTo(BookTransferCreateParams.Category.ADJUSTMENT)
7067
assertThat(body.fromFinancialAccountToken())

lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferReverseParamsTest.kt

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

33
package com.lithic.api.models
44

5-
import kotlin.test.assertNotNull
65
import org.assertj.core.api.Assertions.assertThat
76
import org.junit.jupiter.api.Test
87

@@ -38,7 +37,6 @@ internal class BookTransferReverseParamsTest {
3837

3938
val body = params._body()
4039

41-
assertNotNull(body)
4240
assertThat(body.memo()).contains("memo")
4341
}
4442

@@ -50,7 +48,5 @@ internal class BookTransferReverseParamsTest {
5048
.build()
5149

5250
val body = params._body()
53-
54-
assertNotNull(body)
5551
}
5652
}

lithic-java-core/src/test/kotlin/com/lithic/api/models/CardConvertPhysicalParamsTest.kt

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

33
package com.lithic.api.models
44

5-
import kotlin.test.assertNotNull
65
import org.assertj.core.api.Assertions.assertThat
76
import org.junit.jupiter.api.Test
87

@@ -83,7 +82,6 @@ internal class CardConvertPhysicalParamsTest {
8382

8483
val body = params._body()
8584

86-
assertNotNull(body)
8785
assertThat(body.shippingAddress())
8886
.isEqualTo(
8987
ShippingAddress.builder()
@@ -126,7 +124,6 @@ internal class CardConvertPhysicalParamsTest {
126124

127125
val body = params._body()
128126

129-
assertNotNull(body)
130127
assertThat(body.shippingAddress())
131128
.isEqualTo(
132129
ShippingAddress.builder()

0 commit comments

Comments
 (0)