Skip to content

Commit d7fd12a

Browse files
author
David Hasani
committed
add E2E test
1 parent 5c1d84d commit d7fd12a

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as path from 'path'
7+
import { setValidConnection } from '../util/connection'
8+
import assert from 'assert'
9+
import { JDKVersion, TransformationType, transformByQState } from '../../codewhisperer'
10+
import {
11+
processLanguageUpgradeTransformFormInput,
12+
setMaven,
13+
startTransformByQ,
14+
} from '../../codewhisperer/commands/startTransformByQ'
15+
import { fs } from '../../shared'
16+
import { TestFolder } from '../../test/testUtil'
17+
18+
describe('transformByQ', async function () {
19+
let tempDir = ''
20+
let tempFileName = ''
21+
let tempFilePath = ''
22+
let validConnection: boolean
23+
24+
const javaFileContents = `public class MyApp {
25+
public static void main(String[] args) {
26+
Integer temp = new Integer("1234");
27+
}
28+
}`
29+
30+
const pomXmlContents = `<?xml version="1.0" encoding="UTF-8"?>
31+
<project xmlns="http://maven.apache.org/POM/4.0.0"
32+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34+
<modelVersion>4.0.0</modelVersion>
35+
36+
<groupId>com.example</groupId>
37+
<artifactId>basic-java-app</artifactId>
38+
<version>1.0-SNAPSHOT</version>
39+
40+
<properties>
41+
<maven.compiler.source>1.8</maven.compiler.source>
42+
<maven.compiler.target>1.8</maven.compiler.target>
43+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
44+
</properties>
45+
46+
<build>
47+
<plugins>
48+
<plugin>
49+
<groupId>org.apache.maven.plugins</groupId>
50+
<artifactId>maven-compiler-plugin</artifactId>
51+
<version>3.8.1</version>
52+
<configuration>
53+
<source>1.8</source>
54+
<target>1.8</target>
55+
</configuration>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
</project>`
60+
61+
before(async function () {
62+
validConnection = await setValidConnection()
63+
if (!validConnection) {
64+
this.skip()
65+
}
66+
tempDir = path.join((await TestFolder.create()).path, 'qct-java-upgrade-test')
67+
tempFileName = 'MyApp.java'
68+
tempFilePath = path.join(tempDir, tempFileName)
69+
await fs.writeFile(tempFilePath, javaFileContents)
70+
tempFileName = 'pom.xml'
71+
tempFilePath = path.join(tempDir, tempFileName)
72+
await fs.writeFile(tempFilePath, pomXmlContents)
73+
})
74+
75+
// TODO: this test 1) is skipped in GitHub CI due to no valid connection (see line 60 above) and
76+
// 2) even locally, fails due to the max test duration being set to 30s (this test takes ~5m)
77+
// Once both of the above are resolved, this test will pass
78+
// You can manually override the 30s limit (in setupUtil.ts) to confirm that the test passes locally
79+
it('WHEN transforming a Java 8 project E2E THEN job is successful', async function () {
80+
transformByQState.setTransformationType(TransformationType.LANGUAGE_UPGRADE)
81+
await setMaven()
82+
await processLanguageUpgradeTransformFormInput(tempDir, JDKVersion.JDK8, JDKVersion.JDK17)
83+
await startTransformByQ()
84+
assert.strictEqual(transformByQState.getPolledJobStatus(), 'COMPLETED')
85+
})
86+
})

0 commit comments

Comments
 (0)