Skip to content

Commit 776e8a2

Browse files
committed
Prefer apply over let for test
1 parent 247a701 commit 776e8a2

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

firebase-ai/src/test/java/com/google/firebase/ai/DevAPIStreamingSnapshotTests.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ internal class DevAPIStreamingSnapshotTests {
4242
withTimeout(testTimeout) {
4343
val responseList = responses.toList()
4444
responseList.isEmpty() shouldBe false
45-
responseList.last().candidates.first().let {
46-
it.finishReason shouldBe FinishReason.STOP
47-
it.content.parts.isEmpty() shouldBe false
45+
responseList.last().candidates.first().apply {
46+
finishReason shouldBe FinishReason.STOP
47+
content.parts.isEmpty() shouldBe false
4848
}
4949
}
5050
}
@@ -57,9 +57,9 @@ internal class DevAPIStreamingSnapshotTests {
5757
withTimeout(testTimeout) {
5858
val responseList = responses.toList()
5959
responseList.isEmpty() shouldBe false
60-
responseList.last().candidates.first().let {
61-
it.finishReason shouldBe FinishReason.STOP
62-
it.content.parts.isEmpty() shouldBe false
60+
responseList.last().candidates.first().apply {
61+
finishReason shouldBe FinishReason.STOP
62+
content.parts.isEmpty() shouldBe false
6363
}
6464
}
6565
}

firebase-ai/src/test/java/com/google/firebase/ai/VertexAIStreamingSnapshotTests.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ internal class VertexAIStreamingSnapshotTests {
5151
withTimeout(testTimeout) {
5252
val responseList = responses.toList()
5353
responseList.isEmpty() shouldBe false
54-
responseList.first().candidates.first().finishReason shouldBe FinishReason.STOP
55-
responseList.first().candidates.first().content.parts.isEmpty() shouldBe false
56-
responseList.first().candidates.first().safetyRatings.isEmpty() shouldBe false
54+
responseList.last().candidates.first().apply {
55+
finishReason shouldBe FinishReason.STOP
56+
content.parts.isEmpty() shouldBe false
57+
safetyRatings.isEmpty() shouldBe false
58+
}
59+
5760
}
5861
}
5962

@@ -65,10 +68,10 @@ internal class VertexAIStreamingSnapshotTests {
6568
withTimeout(testTimeout) {
6669
val responseList = responses.toList()
6770
responseList.isEmpty() shouldBe false
68-
responseList.forEach {
69-
it.candidates.first().finishReason shouldBe FinishReason.STOP
70-
it.candidates.first().content.parts.isEmpty() shouldBe false
71-
it.candidates.first().safetyRatings.isEmpty() shouldBe false
71+
responseList.last().candidates.first().apply {
72+
finishReason shouldBe FinishReason.STOP
73+
content.parts.isEmpty() shouldBe false
74+
safetyRatings.isEmpty() shouldBe false
7275
}
7376
}
7477
}

0 commit comments

Comments
 (0)