Skip to content

Commit a10efa5

Browse files
author
Jonas Saabel
committed
nit: various code cleanup actions
1 parent e1d7039 commit a10efa5

17 files changed

+62
-67
lines changed

src/main/kotlin/it/saabel/kotlinnotionclient/models/comments/CreateCommentRequestBuilder.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package it.saabel.kotlinnotionclient.models.comments
55
import it.saabel.kotlinnotionclient.models.base.Parent
66
import it.saabel.kotlinnotionclient.models.base.RichText
77
import it.saabel.kotlinnotionclient.models.richtext.RichTextBuilder
8-
import it.saabel.kotlinnotionclient.models.richtext.richText
98

109
/**
1110
* DSL marker to prevent nested scopes in comment builders.

src/main/kotlin/it/saabel/kotlinnotionclient/models/pages/PageProperty.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,12 @@ val PageProperty.Date.endLocalDateTimeNaive: kotlinx.datetime.LocalDateTime?
397397
}
398398

399399
/** Returns the end instant as Instant, or null if not set or parsing fails. */
400-
val PageProperty.Date.endInstantValue: kotlinx.datetime.Instant?
400+
val PageProperty.Date.endInstantValue: Instant?
401401
get() =
402402
date?.end?.let {
403403
try {
404404
val normalized = it.replace(Regex("\\.\\d+"), "")
405-
kotlinx.datetime.Instant.parse(normalized)
405+
Instant.parse(normalized)
406406
} catch (e: IllegalArgumentException) {
407407
null
408408
}

src/main/kotlin/it/saabel/kotlinnotionclient/utils/FileUploadUtils.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package it.saabel.kotlinnotionclient.utils
55
import java.io.File
66
import java.io.InputStream
77
import java.nio.file.Path
8-
import kotlin.io.path.extension
98
import kotlin.io.path.name
109

1110
/**

src/test/kotlin/examples/BlocksExamples.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class BlocksExamples :
6868
if (shouldCleanupAfterTest() && testPageId != null) {
6969
println("🧹 Cleaning up test page...")
7070
try {
71-
notion.pages.archive(testPageId!!)
71+
notion.pages.archive(testPageId)
7272
println("✅ Cleanup complete")
7373
} catch (e: Exception) {
7474
println("⚠️ Cleanup failed: ${e.message}")
@@ -110,7 +110,7 @@ class BlocksExamples :
110110

111111
// Verify by retrieving children
112112
delay(1000)
113-
val blocks = notion.blocks.retrieveChildren(testPageId!!)
113+
val blocks = notion.blocks.retrieveChildren(testPageId)
114114

115115
// Validation
116116
blocks.shouldNotBeEmpty()
@@ -144,7 +144,7 @@ class BlocksExamples :
144144

145145
// Verify
146146
delay(1000)
147-
val blocks = notion.blocks.retrieveChildren(testPageId!!)
147+
val blocks = notion.blocks.retrieveChildren(testPageId)
148148

149149
// Validation - should have at least one paragraph with multiple rich text segments
150150
blocks.shouldNotBeEmpty()
@@ -181,7 +181,7 @@ class BlocksExamples :
181181

182182
// Verify
183183
delay(1000)
184-
val blocks = notion.blocks.retrieveChildren(testPageId!!)
184+
val blocks = notion.blocks.retrieveChildren(testPageId)
185185

186186
// Validation
187187
blocks.shouldNotBeEmpty()
@@ -212,7 +212,7 @@ class BlocksExamples :
212212

213213
// Verify
214214
delay(1000)
215-
val blocks = notion.blocks.retrieveChildren(testPageId!!)
215+
val blocks = notion.blocks.retrieveChildren(testPageId)
216216

217217
// Validation
218218
blocks.shouldNotBeEmpty()
@@ -237,7 +237,7 @@ class BlocksExamples :
237237

238238
// Verify
239239
delay(1000)
240-
val blocks = notion.blocks.retrieveChildren(testPageId!!)
240+
val blocks = notion.blocks.retrieveChildren(testPageId)
241241

242242
// Validation
243243
blocks.shouldNotBeEmpty()
@@ -262,7 +262,7 @@ class BlocksExamples :
262262

263263
// Verify
264264
delay(1000)
265-
val blocks = notion.blocks.retrieveChildren(testPageId!!)
265+
val blocks = notion.blocks.retrieveChildren(testPageId)
266266

267267
// Validation
268268
blocks.shouldNotBeEmpty()

src/test/kotlin/integration/RateLimitVerificationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class RateLimitVerificationTest :
4747
),
4848
)
4949

50-
val client = NotionClient.Companion.create(config)
50+
val client = NotionClient.create(config)
5151

5252
var successCount = 0
5353
var rateLimitHandledCount = 0

src/test/kotlin/integration/SearchIntegrationTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package integration
22

3-
import integration.integrationTestEnvVarsAreSet
43
import io.kotest.core.annotation.Tags
54
import io.kotest.core.spec.style.StringSpec
65
import io.kotest.matchers.shouldBe

src/test/kotlin/integration/UsersIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class UsersIntegrationTest :
4949
user.person shouldBe null
5050

5151
// Owner info may or may not be present
52-
if (user.bot?.owner != null) {
52+
if (user.bot.owner != null) {
5353
println("✓ Got bot user: ${user.name} (${user.id}) with owner: ${user.bot.owner.type}")
5454
} else {
5555
println("✓ Got bot user: ${user.name} (${user.id}) - no owner info")

src/test/kotlin/integration/dsl/ApiOverloadsIntegrationTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ApiOverloadsIntegrationTest :
4747
"PagesApi create overload should work with live API" {
4848
val token = System.getenv("NOTION_API_TOKEN")
4949
val parentPageId = System.getenv("NOTION_TEST_PAGE_ID")
50-
val client = NotionClient.Companion.create(NotionConfig(apiToken = token))
50+
val client = NotionClient.create(NotionConfig(apiToken = token))
5151

5252
try {
5353
println("📄 Testing PagesApi.create() overload with live API...")
@@ -120,7 +120,7 @@ class ApiOverloadsIntegrationTest :
120120
"DatabasesApi create overload should work with live API" {
121121
val token = System.getenv("NOTION_API_TOKEN")
122122
val parentPageId = System.getenv("NOTION_TEST_PAGE_ID")
123-
val client = NotionClient.Companion.create(NotionConfig(apiToken = token))
123+
val client = NotionClient.create(NotionConfig(apiToken = token))
124124

125125
try {
126126
println("🗄️ Testing DatabasesApi.create() overload with live API...")
@@ -231,7 +231,7 @@ class ApiOverloadsIntegrationTest :
231231
"BlocksApi appendChildren overload should work with live API" {
232232
val token = System.getenv("NOTION_API_TOKEN")
233233
val parentPageId = System.getenv("NOTION_TEST_PAGE_ID")
234-
val client = NotionClient.Companion.create(NotionConfig(apiToken = token))
234+
val client = NotionClient.create(NotionConfig(apiToken = token))
235235

236236
try {
237237
println("🧱 Testing BlocksApi.appendChildren() overload with live API...")
@@ -318,7 +318,7 @@ class ApiOverloadsIntegrationTest :
318318
"BlocksApi update overload should work with live API" {
319319
val token = System.getenv("NOTION_API_TOKEN")
320320
val parentPageId = System.getenv("NOTION_TEST_PAGE_ID")
321-
val client = NotionClient.Companion.create(NotionConfig(apiToken = token))
321+
val client = NotionClient.create(NotionConfig(apiToken = token))
322322

323323
try {
324324
println("🔄 Testing BlocksApi.update() overload with live API...")
@@ -419,7 +419,7 @@ class ApiOverloadsIntegrationTest :
419419
"BlocksApi delete should work with live API" {
420420
val token = System.getenv("NOTION_API_TOKEN")
421421
val parentPageId = System.getenv("NOTION_TEST_PAGE_ID")
422-
val client = NotionClient.Companion.create(NotionConfig(apiToken = token))
422+
val client = NotionClient.create(NotionConfig(apiToken = token))
423423

424424
try {
425425
println("🗑️ Testing BlocksApi.delete() with live API...")
@@ -508,7 +508,7 @@ class ApiOverloadsIntegrationTest :
508508
"Combined API overloads workflow should work end-to-end" {
509509
val token = System.getenv("NOTION_API_TOKEN")
510510
val parentPageId = System.getenv("NOTION_TEST_PAGE_ID")
511-
val client = NotionClient.Companion.create(NotionConfig(apiToken = token))
511+
val client = NotionClient.create(NotionConfig(apiToken = token))
512512

513513
try {
514514
println("🔄 Testing combined API overloads workflow...")

src/test/kotlin/integration/dsl/RichTextDslIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class RichTextDslIntegrationTest :
3939
"Should create page with rich text DSL mixed formatting and verify with real API" {
4040
val token = System.getenv("NOTION_API_TOKEN")
4141
val parentPageId = System.getenv("NOTION_TEST_PAGE_ID")
42-
val client = NotionClient.Companion.create(NotionConfig(apiToken = token))
42+
val client = NotionClient.create(NotionConfig(apiToken = token))
4343

4444
try {
4545
// Step 1: Create initial page

src/test/kotlin/unit/api/BlocksApiTest.kt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class BlocksApiTest :
4444
httpClient =
4545
mockClient {
4646
addJsonResponse(
47-
method = HttpMethod.Companion.Get,
47+
method = HttpMethod.Get,
4848
path = "/v1/blocks/$blockId",
49-
statusCode = HttpStatusCode.Companion.OK,
49+
statusCode = HttpStatusCode.OK,
5050
responseBody = blockData.toString(),
5151
)
5252
}
@@ -75,9 +75,9 @@ class BlocksApiTest :
7575
httpClient =
7676
mockClient {
7777
addErrorResponse(
78-
method = HttpMethod.Companion.Get,
78+
method = HttpMethod.Get,
7979
urlPattern = "/v1/blocks/$blockId",
80-
statusCode = HttpStatusCode.Companion.NotFound,
80+
statusCode = HttpStatusCode.NotFound,
8181
)
8282
}
8383
blocksApi = BlocksApi(httpClient, config)
@@ -99,9 +99,9 @@ class BlocksApiTest :
9999
httpClient =
100100
mockClient {
101101
addJsonResponse(
102-
method = HttpMethod.Companion.Get,
102+
method = HttpMethod.Get,
103103
path = "/v1/blocks/$parentBlockId/children",
104-
statusCode = HttpStatusCode.Companion.OK,
104+
statusCode = HttpStatusCode.OK,
105105
responseBody = childrenData.toString(),
106106
)
107107
}
@@ -123,9 +123,9 @@ class BlocksApiTest :
123123
httpClient =
124124
mockClient {
125125
addJsonResponse(
126-
method = HttpMethod.Companion.Patch,
126+
method = HttpMethod.Patch,
127127
path = "/v1/blocks/$parentBlockId/children",
128-
statusCode = HttpStatusCode.Companion.OK,
128+
statusCode = HttpStatusCode.OK,
129129
responseBody = appendChildrenResponse.toString(),
130130
)
131131
}
@@ -154,9 +154,9 @@ class BlocksApiTest :
154154
httpClient =
155155
mockClient {
156156
addJsonResponse(
157-
method = HttpMethod.Companion.Patch,
157+
method = HttpMethod.Patch,
158158
path = "/v1/blocks/$parentBlockId/children",
159-
statusCode = HttpStatusCode.Companion.OK,
159+
statusCode = HttpStatusCode.OK,
160160
responseBody = appendChildrenResponse.toString(),
161161
)
162162
}
@@ -181,9 +181,9 @@ class BlocksApiTest :
181181
httpClient =
182182
mockClient {
183183
addJsonResponse(
184-
method = HttpMethod.Companion.Patch,
184+
method = HttpMethod.Patch,
185185
path = "/v1/blocks/$blockId",
186-
statusCode = HttpStatusCode.Companion.OK,
186+
statusCode = HttpStatusCode.OK,
187187
responseBody = updateResponse.toString(),
188188
)
189189
}
@@ -224,9 +224,9 @@ class BlocksApiTest :
224224
httpClient =
225225
mockClient {
226226
addJsonResponse(
227-
method = HttpMethod.Companion.Patch,
227+
method = HttpMethod.Patch,
228228
path = "/v1/blocks/$blockId",
229-
statusCode = HttpStatusCode.Companion.OK,
229+
statusCode = HttpStatusCode.OK,
230230
responseBody = updateResponse.toString(),
231231
)
232232
}
@@ -286,9 +286,9 @@ class BlocksApiTest :
286286
httpClient =
287287
mockClient {
288288
addErrorResponse(
289-
method = HttpMethod.Companion.Patch,
289+
method = HttpMethod.Patch,
290290
urlPattern = "/v1/blocks/$blockId",
291-
statusCode = HttpStatusCode.Companion.BadRequest,
291+
statusCode = HttpStatusCode.BadRequest,
292292
)
293293
}
294294
blocksApi = BlocksApi(httpClient, config)
@@ -318,9 +318,9 @@ class BlocksApiTest :
318318
httpClient =
319319
mockClient {
320320
addJsonResponse(
321-
method = HttpMethod.Companion.Patch,
321+
method = HttpMethod.Patch,
322322
path = "/v1/blocks/$blockId",
323-
statusCode = HttpStatusCode.Companion.OK,
323+
statusCode = HttpStatusCode.OK,
324324
responseBody = deleteResponse.toString(),
325325
)
326326
}
@@ -339,9 +339,9 @@ class BlocksApiTest :
339339
httpClient =
340340
mockClient {
341341
addErrorResponse(
342-
method = HttpMethod.Companion.Patch,
342+
method = HttpMethod.Patch,
343343
urlPattern = "/v1/blocks/$blockId",
344-
statusCode = HttpStatusCode.Companion.NotFound,
344+
statusCode = HttpStatusCode.NotFound,
345345
)
346346
}
347347
blocksApi = BlocksApi(httpClient, config)
@@ -360,9 +360,9 @@ class BlocksApiTest :
360360
httpClient =
361361
mockClient {
362362
addErrorResponse(
363-
method = HttpMethod.Companion.Patch,
363+
method = HttpMethod.Patch,
364364
urlPattern = "/v1/blocks/$blockId",
365-
statusCode = HttpStatusCode.Companion.Forbidden,
365+
statusCode = HttpStatusCode.Forbidden,
366366
)
367367
}
368368
blocksApi = BlocksApi(httpClient, config)

0 commit comments

Comments
 (0)