Skip to content

Commit ae717b6

Browse files
committed
Add happy path
1 parent f85ab02 commit ae717b6

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/clients/FeatureDevClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class FeatureDevClient(
9898
.metricName("Operation")
9999
.metricValue(1.0)
100100
.timestamp(Instant.now())
101-
.product("Amazon Q For JetBrains")
101+
.product("FeatureDev")
102102
.dimensions(
103103
listOf(
104104
Dimension.builder()

plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevControllerTest.kt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,46 @@ class FeatureDevControllerTest : FeatureDevTestBase() {
434434
}
435435

436436
@Test
437-
fun `test handleChat onCodeGeneration sends correct metrics for different errors`() = runTest {
437+
fun `test handleChat onCodeGeneration sends success metrics`() = runTest {
438+
val mockSession = mock<Session>()
439+
val featureDevService = mockk<FeatureDevService>()
440+
val repoContext = mock<FeatureDevSessionContext>()
441+
val sessionStateConfig = SessionStateConfig(testConversationId, repoContext, featureDevService)
442+
val mockInteraction = mock<Interaction>()
443+
whenever(mockSession.send(userMessage)).thenReturn(mockInteraction)
444+
whenever(mockSession.sessionState).thenReturn(
445+
PrepareCodeGenerationState(
446+
testTabId,
447+
CancellationTokenSource(),
448+
"test-command",
449+
sessionStateConfig,
450+
newFileContents,
451+
deletedFiles,
452+
testReferences,
453+
testUploadId,
454+
0,
455+
messenger,
456+
diffMetricsProcessed = DiffMetricsProcessed(HashSet(), HashSet()),
457+
),
458+
)
459+
460+
controller.onCodeGeneration(mockSession, userMessage, testTabId)
461+
462+
val mockInOrder = inOrder(mockSession)
463+
464+
mockInOrder.verify(mockSession).sendMetricDataTelemetry(
465+
MetricDataOperationName.START_CODE_GENERATION.toString(),
466+
MetricDataResult.SUCCESS.toString()
467+
468+
)
469+
mockInOrder.verify(mockSession).sendMetricDataTelemetry(
470+
MetricDataOperationName.END_CODE_GENERATION.toString(),
471+
MetricDataResult.SUCCESS.toString()
472+
)
473+
}
474+
475+
@Test
476+
fun `test handleChat onCodeGeneration sends correct failure metrics for different errors`() = runTest {
438477
data class ErrorTestCase(
439478
val error: Exception,
440479
val expectedMetricResult: MetricDataResult,

0 commit comments

Comments
 (0)