@@ -7,14 +7,29 @@ import assert from 'assert'
77import { qTestingFramework } from './framework/framework'
88import sinon from 'sinon'
99import { Messenger } from './framework/messenger'
10- import { JDKVersion } from 'aws-core-vscode/codewhisperer'
10+ import { JDKVersion , TransformationType , transformByQState } from 'aws-core-vscode/codewhisperer'
1111import { GumbyController , startTransformByQ , TabsStorage } from 'aws-core-vscode/amazonqGumby'
12+ import { using , registerAuthHook , TestFolder } from 'aws-core-vscode/test'
13+ import { loginToIdC } from './utils/setup'
14+ import { fs } from 'aws-core-vscode/shared'
15+ import path from 'path'
16+ import {
17+ setMaven ,
18+ processLanguageUpgradeTransformFormInput ,
19+ } from '../../../../core/dist/src/codewhisperer/commands/startTransformByQ'
1220
1321describe ( 'Amazon Q Code Transformation' , function ( ) {
1422 let framework : qTestingFramework
1523 let tab : Messenger
1624
25+ before ( async function ( ) {
26+ await using( registerAuthHook ( 'amazonq-test-account' ) , async ( ) => {
27+ await loginToIdC ( )
28+ } )
29+ } )
30+
1731 beforeEach ( ( ) => {
32+ registerAuthHook ( 'amazonq-test-account' )
1833 framework = new qTestingFramework ( 'gumby' , true , [ ] )
1934 tab = framework . createTab ( )
2035 } )
@@ -267,4 +282,69 @@ describe('Amazon Q Code Transformation', function () {
267282 )
268283 } )
269284 } )
285+
286+ describe ( 'Running a Java upgrade from start to finish' , async function ( ) {
287+ let tempDir = ''
288+ let tempFileName = ''
289+ let tempFilePath = ''
290+
291+ const javaFileContents = `public class MyApp {
292+ public static void main(String[] args) {
293+ Integer temp = new Integer("1234");
294+ }
295+ }`
296+
297+ const pomXmlContents = `<?xml version="1.0" encoding="UTF-8"?>
298+ <project xmlns="http://maven.apache.org/POM/4.0.0"
299+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
300+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
301+ <modelVersion>4.0.0</modelVersion>
302+
303+ <groupId>com.example</groupId>
304+ <artifactId>basic-java-app</artifactId>
305+ <version>1.0-SNAPSHOT</version>
306+
307+ <properties>
308+ <maven.compiler.source>1.8</maven.compiler.source>
309+ <maven.compiler.target>1.8</maven.compiler.target>
310+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
311+ </properties>
312+
313+ <build>
314+ <plugins>
315+ <plugin>
316+ <groupId>org.apache.maven.plugins</groupId>
317+ <artifactId>maven-compiler-plugin</artifactId>
318+ <version>3.8.1</version>
319+ <configuration>
320+ <source>1.8</source>
321+ <target>1.8</target>
322+ </configuration>
323+ </plugin>
324+ </plugins>
325+ </build>
326+ </project>`
327+
328+ before ( async function ( ) {
329+ tempDir = path . join ( ( await TestFolder . create ( ) ) . path , 'qct-java-upgrade-test' )
330+ tempFileName = 'MyApp.java'
331+ tempFilePath = path . join ( tempDir , tempFileName )
332+ await fs . writeFile ( tempFilePath , javaFileContents )
333+ tempFileName = 'pom.xml'
334+ tempFilePath = path . join ( tempDir , tempFileName )
335+ await fs . writeFile ( tempFilePath , pomXmlContents )
336+ } )
337+
338+ after ( async function ( ) {
339+ await fs . delete ( tempDir , { recursive : true } )
340+ } )
341+
342+ it ( 'WHEN transforming a Java 8 project E2E THEN job is successful' , async function ( ) {
343+ transformByQState . setTransformationType ( TransformationType . LANGUAGE_UPGRADE )
344+ await setMaven ( )
345+ await processLanguageUpgradeTransformFormInput ( tempDir , JDKVersion . JDK8 , JDKVersion . JDK17 )
346+ await startTransformByQ . startTransformByQ ( )
347+ assert . strictEqual ( transformByQState . getPolledJobStatus ( ) , 'COMPLETED' )
348+ } )
349+ } )
270350} )
0 commit comments