Skip to content

Commit ded8a03

Browse files
fix(client): mark some request bodies as optional (#242)
chore(internal): use `assertNotNull` in tests for type narrowing chore(internal): remove unnecessary non-null asserts in tests
1 parent 97d3a3c commit ded8a03

24 files changed

+72
-48
lines changed

openai-java-core/src/test/kotlin/com/openai/models/BatchCreateParamsTest.kt

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

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

@@ -36,7 +37,7 @@ class BatchCreateParamsTest {
3637

3738
val body = params._body()
3839

39-
assertThat(body).isNotNull
40+
assertNotNull(body)
4041
assertThat(body.completionWindow()).isEqualTo(BatchCreateParams.CompletionWindow._24H)
4142
assertThat(body.endpoint()).isEqualTo(BatchCreateParams.Endpoint.V1_CHAT_COMPLETIONS)
4243
assertThat(body.inputFileId()).isEqualTo("input_file_id")
@@ -57,7 +58,7 @@ class BatchCreateParamsTest {
5758

5859
val body = params._body()
5960

60-
assertThat(body).isNotNull
61+
assertNotNull(body)
6162
assertThat(body.completionWindow()).isEqualTo(BatchCreateParams.CompletionWindow._24H)
6263
assertThat(body.endpoint()).isEqualTo(BatchCreateParams.Endpoint.V1_CHAT_COMPLETIONS)
6364
assertThat(body.inputFileId()).isEqualTo("input_file_id")

openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantCreateParamsTest.kt

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

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

@@ -107,7 +108,7 @@ class BetaAssistantCreateParamsTest {
107108

108109
val body = params._body()
109110

110-
assertThat(body).isNotNull
111+
assertNotNull(body)
111112
assertThat(body.model()).isEqualTo(ChatModel.O3_MINI)
112113
assertThat(body.description()).contains("description")
113114
assertThat(body.instructions()).contains("instructions")
@@ -161,7 +162,7 @@ class BetaAssistantCreateParamsTest {
161162

162163
val body = params._body()
163164

164-
assertThat(body).isNotNull
165+
assertNotNull(body)
165166
assertThat(body.model()).isEqualTo(ChatModel.O3_MINI)
166167
}
167168
}

openai-java-core/src/test/kotlin/com/openai/models/BetaAssistantUpdateParamsTest.kt

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

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

@@ -78,7 +79,7 @@ class BetaAssistantUpdateParamsTest {
7879

7980
val body = params._body()
8081

81-
assertThat(body).isNotNull
82+
assertNotNull(body)
8283
assertThat(body.description()).contains("description")
8384
assertThat(body.instructions()).contains("instructions")
8485
assertThat(body.metadata())
@@ -118,7 +119,7 @@ class BetaAssistantUpdateParamsTest {
118119

119120
val body = params._body()
120121

121-
assertThat(body).isNotNull
122+
assertNotNull(body)
122123
}
123124

124125
@Test

openai-java-core/src/test/kotlin/com/openai/models/BetaThreadCreateAndRunParamsTest.kt

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

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

@@ -214,7 +215,7 @@ class BetaThreadCreateAndRunParamsTest {
214215

215216
val body = params._body()
216217

217-
assertThat(body).isNotNull
218+
assertNotNull(body)
218219
assertThat(body.assistantId()).isEqualTo("assistant_id")
219220
assertThat(body.instructions()).contains("instructions")
220221
assertThat(body.maxCompletionTokens()).contains(256L)
@@ -329,7 +330,7 @@ class BetaThreadCreateAndRunParamsTest {
329330

330331
val body = params._body()
331332

332-
assertThat(body).isNotNull
333+
assertNotNull(body)
333334
assertThat(body.assistantId()).isEqualTo("assistant_id")
334335
}
335336
}

openai-java-core/src/test/kotlin/com/openai/models/BetaThreadCreateParamsTest.kt

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

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

@@ -123,7 +124,7 @@ class BetaThreadCreateParamsTest {
123124

124125
val body = params._body()
125126

126-
assertThat(body).isNotNull
127+
assertNotNull(body)
127128
assertThat(body.messages())
128129
.contains(
129130
listOf(
@@ -185,6 +186,6 @@ class BetaThreadCreateParamsTest {
185186

186187
val body = params._body()
187188

188-
assertThat(body).isNotNull
189+
assertNotNull(body)
189190
}
190191
}

openai-java-core/src/test/kotlin/com/openai/models/BetaThreadMessageCreateParamsTest.kt

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

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

@@ -48,7 +49,7 @@ class BetaThreadMessageCreateParamsTest {
4849

4950
val body = params._body()
5051

51-
assertThat(body).isNotNull
52+
assertNotNull(body)
5253
assertThat(body.content()).isEqualTo(BetaThreadMessageCreateParams.Content.ofText("string"))
5354
assertThat(body.role()).isEqualTo(BetaThreadMessageCreateParams.Role.USER)
5455
assertThat(body.attachments())
@@ -77,7 +78,7 @@ class BetaThreadMessageCreateParamsTest {
7778

7879
val body = params._body()
7980

80-
assertThat(body).isNotNull
81+
assertNotNull(body)
8182
assertThat(body.content()).isEqualTo(BetaThreadMessageCreateParams.Content.ofText("string"))
8283
assertThat(body.role()).isEqualTo(BetaThreadMessageCreateParams.Role.USER)
8384
}

openai-java-core/src/test/kotlin/com/openai/models/BetaThreadMessageUpdateParamsTest.kt

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

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

@@ -34,7 +35,7 @@ class BetaThreadMessageUpdateParamsTest {
3435

3536
val body = params._body()
3637

37-
assertThat(body).isNotNull
38+
assertNotNull(body)
3839
assertThat(body.metadata())
3940
.contains(
4041
Metadata.builder().putAdditionalProperty("foo", JsonValue.from("string")).build()
@@ -51,7 +52,7 @@ class BetaThreadMessageUpdateParamsTest {
5152

5253
val body = params._body()
5354

54-
assertThat(body).isNotNull
55+
assertNotNull(body)
5556
}
5657

5758
@Test

openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunCreateParamsTest.kt

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

55
import com.openai.core.JsonValue
66
import com.openai.core.http.QueryParams
7+
import kotlin.test.assertNotNull
78
import org.assertj.core.api.Assertions.assertThat
89
import org.junit.jupiter.api.Test
910

@@ -174,7 +175,7 @@ class BetaThreadRunCreateParamsTest {
174175

175176
val body = params._body()
176177

177-
assertThat(body).isNotNull
178+
assertNotNull(body)
178179
assertThat(body.assistantId()).isEqualTo("assistant_id")
179180
assertThat(body.additionalInstructions()).contains("additional_instructions")
180181
assertThat(body.additionalMessages())
@@ -235,7 +236,7 @@ class BetaThreadRunCreateParamsTest {
235236

236237
val body = params._body()
237238

238-
assertThat(body).isNotNull
239+
assertNotNull(body)
239240
assertThat(body.assistantId()).isEqualTo("assistant_id")
240241
}
241242

openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunSubmitToolOutputsParamsTest.kt

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

33
package com.openai.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 BetaThreadRunSubmitToolOutputsParamsTest {
3738

3839
val body = params._body()
3940

40-
assertThat(body).isNotNull
41+
assertNotNull(body)
4142
assertThat(body.toolOutputs())
4243
.isEqualTo(
4344
listOf(
@@ -60,7 +61,7 @@ class BetaThreadRunSubmitToolOutputsParamsTest {
6061

6162
val body = params._body()
6263

63-
assertThat(body).isNotNull
64+
assertNotNull(body)
6465
assertThat(body.toolOutputs())
6566
.isEqualTo(listOf(BetaThreadRunSubmitToolOutputsParams.ToolOutput.builder().build()))
6667
}

openai-java-core/src/test/kotlin/com/openai/models/BetaThreadRunUpdateParamsTest.kt

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

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

@@ -34,7 +35,7 @@ class BetaThreadRunUpdateParamsTest {
3435

3536
val body = params._body()
3637

37-
assertThat(body).isNotNull
38+
assertNotNull(body)
3839
assertThat(body.metadata())
3940
.contains(
4041
Metadata.builder().putAdditionalProperty("foo", JsonValue.from("string")).build()
@@ -48,7 +49,7 @@ class BetaThreadRunUpdateParamsTest {
4849

4950
val body = params._body()
5051

51-
assertThat(body).isNotNull
52+
assertNotNull(body)
5253
}
5354

5455
@Test

0 commit comments

Comments
 (0)