Skip to content

Commit 808f979

Browse files
committed
tst
1 parent ebf63bc commit 808f979

File tree

3 files changed

+26
-33
lines changed

3 files changed

+26
-33
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererServiceTest.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import org.assertj.core.api.Assertions.assertThat
1313
import org.junit.Before
1414
import org.junit.Test
1515
import org.mockito.kotlin.any
16+
import org.mockito.kotlin.doCallRealMethod
1617
import org.mockito.kotlin.doReturn
1718
import org.mockito.kotlin.mock
1819
import org.mockito.kotlin.spy
19-
import org.mockito.kotlin.stub
2020
import org.mockito.kotlin.whenever
21+
import org.mockito.kotlin.wheneverBlocking
2122
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.textDocument.InlineCompletionTriggerKind
2223
import software.aws.toolkits.jetbrains.services.amazonq.lsp.util.LspEditorUtil.toUriString
2324
import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererCustomization
@@ -55,10 +56,8 @@ class CodeWhispererServiceTest : CodeWhispererTestBase() {
5556
val fileContextProviderSpy = spy(fileContextProvider)
5657
projectRule.project.replaceService(FileContextProvider::class.java, fileContextProviderSpy, disposableRule.disposable)
5758

58-
codewhispererService.stub {
59-
onBlocking {
60-
getRequestContext(any(), any(), any(), any(), any())
61-
}.thenCallRealMethod()
59+
doCallRealMethod().wheneverBlocking(codewhispererService) {
60+
getRequestContext(any(), any(), any(), any(), any())
6261
}
6362

6463
val requestContext = codewhispererService.getRequestContext(
@@ -95,10 +94,8 @@ class CodeWhispererServiceTest : CodeWhispererTestBase() {
9594
}
9695

9796
projectRule.project.replaceService(FileContextProvider::class.java, mockFileContextProvider, disposableRule.disposable)
98-
codewhispererService.stub {
99-
onBlocking {
100-
getRequestContext(any(), any(), any(), any(), any())
101-
}.thenCallRealMethod()
97+
doCallRealMethod().wheneverBlocking(codewhispererService) {
98+
getRequestContext(any(), any(), any(), any(), any())
10299
}
103100

104101
val actual = codewhispererService.getRequestContext(

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTestBase.kt

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import kotlinx.coroutines.Deferred
2020
import kotlinx.coroutines.Job
2121
import kotlinx.coroutines.delay
2222
import kotlinx.coroutines.flow.first
23-
import kotlinx.coroutines.test.TestScope
2423
import kotlinx.coroutines.test.runTest
2524
import kotlinx.coroutines.yield
2625
import org.assertj.core.api.Assertions.assertThat
@@ -33,7 +32,6 @@ import org.mockito.kotlin.any
3332
import org.mockito.kotlin.argumentCaptor
3433
import org.mockito.kotlin.doAnswer
3534
import org.mockito.kotlin.doNothing
36-
import org.mockito.kotlin.doReturn
3735
import org.mockito.kotlin.doSuspendableAnswer
3836
import org.mockito.kotlin.spy
3937
import org.mockito.kotlin.stub
@@ -314,27 +312,26 @@ open class CodeWhispererTestBase {
314312
val projectCaptor = argumentCaptor<Project>()
315313
val psiFileCaptor = argumentCaptor<PsiFile>()
316314
val latencyContextCaptor = argumentCaptor<LatencyContext>()
317-
codewhispererService.stub {
318-
onBlocking {
319-
getRequestContext(
320-
triggerTypeCaptor.capture(),
321-
editorCaptor.capture(),
322-
projectCaptor.capture(),
323-
psiFileCaptor.capture(),
324-
latencyContextCaptor.capture()
325-
)
326-
}.doSuspendableAnswer {
327-
val requestContext = codewhispererService.getRequestContext(
328-
triggerTypeCaptor.firstValue,
329-
editorCaptor.firstValue,
330-
projectCaptor.firstValue,
331-
psiFileCaptor.firstValue,
332-
latencyContextCaptor.firstValue
333-
)
334-
projectRule.fixture.type(userInput)
335-
requestContext
336-
}.thenCallRealMethod()
337-
}
315+
316+
wheneverBlocking {
317+
codewhispererService.getRequestContext(
318+
triggerTypeCaptor.capture(),
319+
editorCaptor.capture(),
320+
projectCaptor.capture(),
321+
psiFileCaptor.capture(),
322+
latencyContextCaptor.capture()
323+
)
324+
}.doSuspendableAnswer {
325+
val requestContext = codewhispererService.getRequestContext(
326+
triggerTypeCaptor.firstValue,
327+
editorCaptor.firstValue,
328+
projectCaptor.firstValue,
329+
psiFileCaptor.firstValue,
330+
latencyContextCaptor.firstValue
331+
)
332+
projectRule.fixture.type(userInput)
333+
requestContext
334+
}.thenCallRealMethod()
338335
}
339336

340337
fun mockLspInlineCompletionResponse(response: InlineCompletionListWithReferences) {

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLspService.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import kotlinx.coroutines.channels.BufferOverflow
3737
import kotlinx.coroutines.delay
3838
import kotlinx.coroutines.flow.MutableSharedFlow
3939
import kotlinx.coroutines.flow.asSharedFlow
40-
import kotlinx.coroutines.flow.firstOrNull
4140
import kotlinx.coroutines.flow.map
4241
import kotlinx.coroutines.future.asCompletableFuture
4342
import kotlinx.coroutines.isActive

0 commit comments

Comments
 (0)