Skip to content

Commit d8333ae

Browse files
author
David Hasani
committed
update tests
1 parent 7d3b0ea commit d8333ae

File tree

9 files changed

+21
-32
lines changed

9 files changed

+21
-32
lines changed

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerSession.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.utils.isValidCode
5050
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.pollTransformationStatusAndPlan
5151
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.toTransformationLanguage
5252
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanSession
53-
import software.aws.toolkits.jetbrains.utils.notifyStickyInfo
5453
import software.aws.toolkits.resources.message
5554
import java.io.File
5655
import java.io.FileInputStream
@@ -270,8 +269,7 @@ class CodeModernizerSession(
270269
} finally {
271270
telemetry.uploadProject(payloadSize, startTime, true, telemetryErrorMessage)
272271
if (payload != null) {
273-
// TO-DO: revert
274-
// deleteUploadArtifact(payload)
272+
deleteUploadArtifact(payload)
275273
}
276274
}
277275

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ fun buildObjectiveChosenChatContent(objective: String) = CodeTransformChatMessag
239239
)
240240

241241
fun buildCheckingValidProjectChatContent() = CodeTransformChatMessageContent(
242-
message = message("codemodernizer.chat.message.validation.check_eligible_projects"),
242+
message = message("codemodernizer.chat.message.validation.check_eligible_modules"),
243243
type = CodeTransformChatMessageType.PendingAnswer,
244244
)
245245

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ class CodeTransformChatController(
150150
// Publish a metric when transform is first initiated from chat prompt.
151151
telemetry.initiateTransform()
152152

153-
val isSqlTransformReady = true // feature flag for SQL conversions
153+
val anyModuleContainsOracleSQL = true // TODO: implement, and make sure to say "Checking for eligible modules..." here too
154154

155-
if (isSqlTransformReady) {
155+
if (anyModuleContainsOracleSQL) {
156156
this.getUserObjective(message.tabId)
157157
} else {
158158
this.handleLanguageUpgrade()
@@ -310,7 +310,7 @@ class CodeTransformChatController(
310310
override suspend fun processCodeTransformSelectSQLMetadataAction(message: IncomingCodeTransformMessage.CodeTransformSelectSQLMetadata) {
311311
runInEdt {
312312
val descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor()
313-
.withDescription("Upload metadata file")
313+
.withDescription("Select metadata file")
314314
.withFileFilter { it.extension == "zip" }
315315

316316
val selectedZipFile = FileChooser.chooseFile(descriptor, null, null) ?: return@runInEdt

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.toolwindow.CodeMo
2626
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.getPathToHilArtifactPomFolder
2727
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.getPathToHilDependenciesRootDir
2828
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.getPathToHilUploadZip
29-
import software.aws.toolkits.jetbrains.utils.notifyStickyInfo
3029
import software.aws.toolkits.resources.message
3130
import java.io.File
3231
import java.io.IOException
@@ -57,6 +56,8 @@ const val DS_STORE_FILE_NAME = ".DS_Store"
5756
const val INVALID_SUFFIX_SHA = "sha1"
5857
const val INVALID_SUFFIX_REPOSITORIES = "repositories"
5958
const val ORACLE_DB = "ORACLE"
59+
const val AURORA_DB = "AURORA_POSTGRESQL"
60+
const val RDS_DB = "RDS_POSTGRESQL"
6061
data class CodeModernizerSessionContext(
6162
val project: Project,
6263
var configurationFile: VirtualFile? = null, // used to ZIP module

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformFileUtils.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.constants.HIL_POM
2626
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.HIL_POM_VERSION_PLACEHOLDER
2727
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.HIL_UPLOAD_ZIP_NAME
2828
import software.aws.toolkits.jetbrains.services.codemodernizer.controller.CodeTransformChatController
29+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.AURORA_DB
2930
import software.aws.toolkits.jetbrains.services.codemodernizer.model.DependencyUpdatesReport
3031
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MAVEN_CONFIGURATION_FILE_NAME
32+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.ORACLE_DB
33+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.RDS_DB
3134
import software.aws.toolkits.jetbrains.services.codemodernizer.model.SctMetadata
3235
import software.aws.toolkits.jetbrains.services.codemodernizer.model.SqlMetadataValidationResult
3336
import software.aws.toolkits.jetbrains.services.codewhisperer.util.content
34-
import software.aws.toolkits.jetbrains.utils.notifyStickyInfo
3537
import software.aws.toolkits.resources.message
3638
import java.io.File
3739
import java.io.FileOutputStream
@@ -154,23 +156,23 @@ fun validateSctMetadata(sctFile: File?): SqlMetadataValidationResult {
154156
try {
155157
sctMetadata = xmlMapper.readValue<SctMetadata>(sctFile)
156158
} catch (e: Exception) {
157-
getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file; invalid XML encountered." }
159+
getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file; invalid XML encountered. $e" }
158160
return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_sct"))
159161
}
160162

161163
try {
162164
val projectModel = sctMetadata.instances.projectModel
163165
val sourceDbServer = projectModel.entities.sources.dbServer
164166
val sourceVendor = sourceDbServer.vendor.trim().uppercase()
165-
if (sourceVendor != "ORACLE") {
167+
if (sourceVendor != ORACLE_DB) {
166168
return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_source_db"))
167169
}
168170

169171
val sourceServerName = sourceDbServer.name.trim()
170172

171173
val targetDbServer = projectModel.entities.targets.dbServer
172174
val targetVendor = targetDbServer.vendor.trim().uppercase()
173-
if (targetVendor != "AURORA_POSTGRESQL" && targetVendor != "RDS_POSTGRESQL") {
175+
if (targetVendor != AURORA_DB && targetVendor != RDS_DB) {
174176
return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_target_db"))
175177
}
176178

@@ -183,8 +185,7 @@ fun validateSctMetadata(sctFile: File?): SqlMetadataValidationResult {
183185
}
184186
}
185187
}
186-
notifyStickyInfo("successfully parsed .sct file", "$sourceVendor, $targetVendor, $sourceServerName, $schemaNames")
187-
return SqlMetadataValidationResult(true, "", sourceVendor, targetVendor, sourceServerName!!, schemaNames)
188+
return SqlMetadataValidationResult(true, "", sourceVendor, targetVendor, sourceServerName, schemaNames)
188189
} catch (e: Exception) {
189190
getLogger<CodeTransformChatController>().error { "Error parsing .sct metadata file: $e" }
190191
return SqlMetadataValidationResult(false, message("codemodernizer.chat.message.validation.error.invalid_sct"))

plugins/amazonq/codetransform/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codemodernizer/CodeWhispererCodeModernizerUtilsTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class CodeWhispererCodeModernizerUtilsTest : CodeWhispererCodeModernizerTestBase
250250
</DbServer>
251251
</sources>
252252
<targets>
253-
<DbServer vendor="aurora_postgresql" />
253+
<DbServer vendor="aurora_postgresql" name="sample.aurora.amazonaws.com" />
254254
</targets>
255255
</entities>
256256
<relations>
@@ -309,7 +309,7 @@ class CodeWhispererCodeModernizerUtilsTest : CodeWhispererCodeModernizerTestBase
309309
</DbServer>
310310
</sources>
311311
<targets>
312-
<DbServer vendor="aurora_postgresql" />
312+
<DbServer vendor="aurora_postgresql" name="sample.aurora.amazonaws.com" />
313313
</targets>
314314
</entities>
315315
<relations>
@@ -364,7 +364,7 @@ class CodeWhispererCodeModernizerUtilsTest : CodeWhispererCodeModernizerTestBase
364364
</DbServer>
365365
</sources>
366366
<targets>
367-
<DbServer vendor="aurora_postgresql-invalid" />
367+
<DbServer vendor="aurora_postgresql-invalid" name="sample.aurora.amazonaws.com" />
368368
</targets>
369369
</entities>
370370
<relations>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ object CodeWhispererConstants {
119119
}
120120

121121
object Config {
122-
const val CODEWHISPERER_ENDPOINT = "https://rts.gamma-us-east-1.codewhisperer.ai.aws.dev/" // PROD
122+
const val CODEWHISPERER_ENDPOINT = "https://codewhisperer.us-east-1.amazonaws.com/" // PROD
123123
const val CODEWHISPERER_IDPOOL_ID = "us-east-1:70717e99-906f-4add-908c-bd9074a2f5b9"
124124
val Sigv4ClientRegion = Region.US_EAST_1
125125
val BearerClientRegion = Region.US_EAST_1

plugins/amazonq/mynah-ui/src/mynah-ui/ui/tabs/generator.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ export class TabDataGenerator {
3030
['featuredev', 'Describe your task or issue in detail'],
3131
])
3232

33-
// feature flag for SQL transformations
34-
private isSQLTransformReady: boolean = true
35-
3633
private tabWelcomeMessage: Map<TabType, string> = new Map([
3734
[
3835
'unknown',
@@ -55,16 +52,8 @@ I can generate code to implement new functionality across your workspace. To get
5552
What would you like to work on?`,
5653
],
5754
[
58-
'codetransform', this.isSQLTransformReady ?
59-
`Welcome to Code Transformation!
60-
61-
I can help you upgrade your Java 8 and 11 codebases to Java 17 ("language upgrade") &
62-
I can also convert embedded SQL from Oracle to PostgreSQL ("SQL conversion"). What would you like to do?
63-
` :
64-
`Welcome to Code Transformation!
65-
66-
I can help you upgrade your Java 8 and 11 codebases to Java 17.
67-
`,
55+
'codetransform',
56+
`Welcome to Code Transformation!`,
6857
],
6958
])
7059

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ codemodernizer.chat.message.upload_failed_http_error=Sorry, I couldn''t upload y
632632
codemodernizer.chat.message.upload_failed_other=Sorry, I was unable to upload your project due to an unexpected failure. {0}
633633
codemodernizer.chat.message.upload_failed_ssl_error=Sorry, I was unable to upload your project. This might have been caused by your IDE not trusting the certificate of your HTTP proxy. Ensure all certificates for your proxy client have been configured in your IDE, and then retry transformation.
634634
codemodernizer.chat.message.upload_failed_url_expired=Sorry, I couldn't upload your project to begin the transformation. The Amazon S3 pre-signed URL used to upload your code expired after 30 minutes. This might have been caused by delays introduced by intermediate services in your network infrastructure.\n\nCheck your network configuration for services that might be causing delays. If the issue persists, you might need to allow list the following Amazon S3 bucket: 'amazonq-code-transformation-us-east-1-c6160f047e0.s3.amazonaws.com'.
635-
codemodernizer.chat.message.validation.check_eligible_projects=Checking for eligible projects...
635+
codemodernizer.chat.message.validation.check_eligible_modules=Checking for eligible modules...
636636
codemodernizer.chat.message.validation.check_passed=I can upgrade your Java module. To start the transformation, I need some information from you. Choose the module you want to upgrade and the target code version to upgrade to. Then, choose **Confirm**.\n\nIf you do not see the module you want to transform, you might need to configure your project so that I can find it. Go to File and choose Project Structure. In the Projects tab, set the correct project JDK and language level. In the Modules tab, set the correct module JDK and language level.
637637
codemodernizer.chat.message.validation.error.invalid_sct=It looks like the .sct file you provided isn't valid. Make sure that you've uploaded the .zip file you retrieved from your schema conversion in AWS DMS.
638638
codemodernizer.chat.message.validation.error.invalid_source_db=I can only convert SQL for migrations from an Oracle source database. The provided .sct file indicates another source database for this migration.

0 commit comments

Comments
 (0)