Skip to content

Commit 4b66f1b

Browse files
committed
unit test
1 parent 085462f commit 4b66f1b

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/TelemetryHelperTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.apps.AmazonQAppInitConte
4444
import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererClientAdaptor
4545
import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererCustomization
4646
import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererModelConfigurator
47+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.DiagnosticDifferences
4748
import software.aws.toolkits.jetbrains.services.cwc.clients.chat.ChatSession
4849
import software.aws.toolkits.jetbrains.services.cwc.clients.chat.model.ChatRequestData
4950
import software.aws.toolkits.jetbrains.services.cwc.clients.chat.model.CodeNamesImpl
@@ -475,6 +476,7 @@ class TelemetryHelperTest {
475476
val inserTionTargetType = "insertionTargetType"
476477
val eventId = "eventId"
477478
val code = "println()"
479+
val diagnosticDifferences = DiagnosticDifferences(emptyList(), emptyList())
478480

479481
sut.recordInteractWithMessage(
480482
IncomingCwcMessage.InsertCodeAtCursorPosition(
@@ -487,7 +489,8 @@ class TelemetryHelperTest {
487489
eventId,
488490
codeBlockIndex,
489491
totalCodeBlocks,
490-
lang
492+
lang,
493+
diagnosticDifferences
491494
)
492495
)
493496

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererUtil.kt

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -388,21 +388,19 @@ fun getDiagnosticsType(message: String): String {
388388
?.key ?: "OTHER"
389389
}
390390

391-
fun convertSeverity(severity: HighlightSeverity): String {
392-
return when {
393-
severity == HighlightSeverity.ERROR -> "ERROR"
394-
severity == HighlightSeverity.WARNING ||
395-
severity == HighlightSeverity.WEAK_WARNING -> "WARNING"
396-
severity == HighlightSeverity.INFORMATION -> "INFORMATION"
397-
severity.toString().contains("TEXT", ignoreCase = true) -> "HINT"
398-
severity == HighlightSeverity.INFO -> "INFORMATION"
399-
// For severities that might indicate performance issues
400-
severity.toString().contains("PERFORMANCE", ignoreCase = true) -> "WARNING"
401-
// For deprecation warnings
402-
severity.toString().contains("DEPRECATED", ignoreCase = true) -> "WARNING"
403-
// Default case
404-
else -> "INFORMATION"
405-
}
391+
fun convertSeverity(severity: HighlightSeverity): String = when {
392+
severity == HighlightSeverity.ERROR -> "ERROR"
393+
severity == HighlightSeverity.WARNING ||
394+
severity == HighlightSeverity.WEAK_WARNING -> "WARNING"
395+
severity == HighlightSeverity.INFORMATION -> "INFORMATION"
396+
severity.toString().contains("TEXT", ignoreCase = true) -> "HINT"
397+
severity == HighlightSeverity.INFO -> "INFORMATION"
398+
// For severities that might indicate performance issues
399+
severity.toString().contains("PERFORMANCE", ignoreCase = true) -> "WARNING"
400+
// For deprecation warnings
401+
severity.toString().contains("DEPRECATED", ignoreCase = true) -> "WARNING"
402+
// Default case
403+
else -> "INFORMATION"
406404
}
407405

408406
fun getDocumentDiagnostics(document: Document, project: Project): List<IdeDiagnostic> = runCatching {
@@ -437,7 +435,7 @@ fun getDocumentDiagnostics(document: Document, project: Project): List<IdeDiagno
437435
.build()
438436
}
439437
}.getOrElse { e ->
440-
getLogger<CodeWhispererUtil>().warn("Failed to get document diagnostics", e)
438+
getLogger<CodeWhispererUtil>().warn(e) { "Failed to get document diagnostics" }
441439
emptyList()
442440
}
443441

@@ -446,9 +444,7 @@ data class DiagnosticDifferences(
446444
val removed: List<IdeDiagnostic>,
447445
)
448446

449-
fun serializeDiagnostics(diagnostic: IdeDiagnostic): String {
450-
return "${diagnostic.source()}-${diagnostic.severity()}-${diagnostic.ideDiagnosticType()}"
451-
}
447+
fun serializeDiagnostics(diagnostic: IdeDiagnostic): String = "${diagnostic.source()}-${diagnostic.severity()}-${diagnostic.ideDiagnosticType()}"
452448

453449
fun getDiagnosticDifferences(oldDiagnostic: List<IdeDiagnostic>, newDiagnostic: List<IdeDiagnostic>): DiagnosticDifferences {
454450
val oldSet = oldDiagnostic.map { i -> serializeDiagnostics(i) }.toSet()

plugins/amazonq/codewhisperer/jetbrains-community/tstFixtures/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTestUtil.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ fun aRequestContext(
260260
customizationArn = null,
261261
profileArn = null,
262262
workspaceId = null,
263+
diagnostics = emptyList()
263264
)
264265
}
265266

0 commit comments

Comments
 (0)