Skip to content

Commit

Permalink
RESTEasy can be excluded if using code.quarkus.io
Browse files Browse the repository at this point in the history
Reads the data from code.quarkus.io or code.quarkus.redhat.com
to see which quarkus extensions are required.
This means if code.quarkus.io is used, then resteasy is not required.
Reads the Open API of the code quarkus instance to determine if
the option to prevent sample code being generated is present.
If it is, then it adds another step to the project
generation wizard to specify if sample code should be generated.

Closes redhat-developer#322

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 committed Jul 27, 2021
1 parent 2636c37 commit 8c7c30f
Show file tree
Hide file tree
Showing 13 changed files with 225 additions and 49 deletions.
49 changes: 43 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@
"devDependencies": {
"@types/chai": "^4.2.3",
"@types/chai-fs": "^2.0.2",
"@types/ejs": "^3.0.5",
"@types/fs-extra": "^7.0.0",
"@types/js-yaml": "^4.0.0",
"@types/lodash": "^4.14.149",
"@types/mocha": "^5.2.6",
"@types/node": "^10.14.16",
Expand Down Expand Up @@ -302,6 +304,7 @@
"find-up": "^4.1.0",
"fs-extra": "^8.0.1",
"glob": "^7.1.4",
"js-yaml": "^4.0.0",
"lodash": "^4.17.21",
"request": "^2.88.0",
"request-promise": "^4.2.4",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { WelcomeWebview } from "../webviews/WelcomeWebview";
import { addExtensionsWizard } from "../wizards/addExtensions/addExtensionsWizard";
import { buildBinary } from "../wizards/binary/buildBinary";
import { startDebugging } from "../wizards/debugging/startDebugging";
import { generateProjectWizard } from "../wizards/generateProject/generationWizard";
import { deployToOpenShift } from "../wizards/deployToOpenShift/deployToOpenShift";
import { generateProjectWizard } from "../wizards/generateProject/generationWizard";

const NOT_A_QUARKUS_PROJECT = new Error('No Quarkus projects were detected in this folder');
const STANDARD_MODE_REQUEST_FAILED = new Error('Error occurred while requesting standard mode from the Java language server');
Expand Down
7 changes: 4 additions & 3 deletions src/definitions/QExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export class QExtension {
artifactId: string;
isRequired: boolean;

constructor(name: string, category: string, description: string, labels: string[], groupId: string, artifactId: string) {
constructor(name: string, category: string, description: string, labels: string[], groupId: string, artifactId: string, isRequired: boolean) {
this.name = name;
this.category = category;
this.description = description;
this.labels = labels;
this.groupId = groupId;
this.artifactId = artifactId;
this.isRequired = name === 'RESTEasy JAX-RS'; // 'RESTEasy JAX-RS' is included in every Quarkus project
this.isRequired = isRequired;
}

getGroupIdArtifactIdString() {
Expand All @@ -61,7 +61,7 @@ export function convertToQExtension(extension: APIExtension): QExtension {
artifactId = extension.id;
}
return new QExtension(extension.name, extension.category, extension.description,
extension.labels, groupId, artifactId);
extension.labels, groupId, artifactId, extension.default);
}

/**
Expand All @@ -76,4 +76,5 @@ export interface APIExtension {
shortName: string;
category: string;
order: Number;
default: boolean;
}
1 change: 1 addition & 0 deletions src/definitions/inputState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface ProjectGenState extends State {
packageName: string;
resourceName: string;
targetDir: Uri;
isGenerateSampleCode: boolean;
}

export interface AddExtensionsState extends State {
Expand Down
4 changes: 1 addition & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TelemetryService } from '@redhat-developer/vscode-redhat-telemetry';
import * as path from 'path';
import { commands, ConfigurationChangeEvent, Disposable, ExtensionContext, languages, Terminal, TextDocument, window, workspace } from 'vscode';
import { registerVSCodeCommands } from './commands/registerCommands';
import { VSCODE_QUARKUS_EXTENSION_NAME } from './definitions/constants';
import { ProjectLabelInfo } from './definitions/ProjectLabelInfo';
import { PropertiesLanguageMismatch, QuarkusConfig } from './QuarkusConfig';
import { QuarkusContext } from './QuarkusContext';
import quarkusProjectListener from './QuarkusProjectListener';
import { terminalCommandRunner } from './terminal/terminalCommandRunner';
import { initTelemetryService } from './utils/telemetryUtils';
import { WelcomeWebview } from './webviews/WelcomeWebview';
import { createTerminateDebugListener } from './wizards/debugging/terminateProcess';
import { initTelemetryService } from './utils/telemetryUtils';

export async function activate(context: ExtensionContext) {

Expand Down
21 changes: 18 additions & 3 deletions src/test/vscodeUiTest/ProjectGenerationWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/
import * as _ from 'lodash';

import { InputBox, QuickPickItem, Workbench, WebDriver, WebElement, By, until, Key } from 'vscode-extension-tester';
import { By, InputBox, Key, QuickPickItem, WebDriver, WebElement, Workbench } from 'vscode-extension-tester';
import { DialogHandler, OpenDialog } from 'vscode-extension-tester-native';

/**
Expand All @@ -30,7 +29,7 @@ export class ProjectGenerationWizard extends InputBox {
/**
* The number of steps the wizard has
*/
private lastStep: number = 7;
private lastStep: number = 8;

/**
* Opens the project generation wizard
Expand Down Expand Up @@ -78,6 +77,9 @@ export class ProjectGenerationWizard extends InputBox {
await wizard.confirm();
}
}
await wizard.focusQuickPick(0);
await wizard.next();
await wizard.focusQuickPick(0);
await wizard.next();

const dialog: OpenDialog = await DialogHandler.getOpenDialog();
Expand Down Expand Up @@ -213,6 +215,19 @@ export class ProjectGenerationWizard extends InputBox {
return (await this.getNthQuickPickItemInfo(n)).label;
}

/**
* Focuses on the quick pick with the given index
*
* @param n the index of the quick pick option to focus
* @returns when the quick pick is focused
*/
public async focusQuickPick(n: number): Promise<void> {
const quickPickToFocus: QuickPickItem = await this.findQuickPick(n);
while (!(await quickPickToFocus.getAttribute('class')).includes('focused')) {
await this.sendKeys(Key.DOWN);
}
}

/**
* Returns the `n`th quick pick item's `QuickPickItemInfo`
* @param n
Expand Down
62 changes: 34 additions & 28 deletions src/test/vscodeUiTest/suite/projectGenerationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,76 +100,82 @@ describe('Project generation tests', function() {
expect(resourceName).equals('GreetingResource');
await wizard.next();

await wizard.sendKeys(Key.DOWN, Key.UP);

expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('1 extension selected');
await wizard.sendKeys(Key.DOWN, Key.DOWN);
await wizard.confirm();
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('2 extensions selected');
await wizard.sendKeys(Key.DOWN, Key.DOWN, Key.DOWN);
await wizard.focusQuickPick(0);
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('0 extensions selected');
await wizard.focusQuickPick(2);
await wizard.confirm();
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('3 extensions selected');
await wizard.sendKeys(Key.DOWN);
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('1 extension selected');
await wizard.focusQuickPick(3);
await wizard.confirm();
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('2 extensions selected');
await wizard.sendKeys(Key.DOWN);
await wizard.focusQuickPick(1);
await wizard.confirm();
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('1 extension selected');
await wizard.focusQuickPick(1);
await wizard.confirm();
expect(await wizard.getNthQuickPickItemLabel(0)).to.have.string('0 extensions selected');
await wizard.cancel();
});

/**
* Tests if the project generation wizard has correct
* step values at the wizard's title bar: (1/7), (2/7)
* step values at the wizard's title bar: (1/8), (2/8)
*/
it('should have correct step values', async function() {
this.timeout(30000);
const wizard: ProjectGenerationWizard = await ProjectGenerationWizard.openWizard(driver);
expect(await wizard.getInputBoxTitle()).to.have.string('1/7');
expect(await wizard.getInputBoxTitle()).to.have.string('1/8');
expect(await wizard.getBackButton()).to.not.be.ok;
await wizard.next();

expect(await wizard.getInputBoxTitle()).to.have.string('2/7');
expect(await wizard.getInputBoxTitle()).to.have.string('2/8');
await wizard.next();

expect(await wizard.getInputBoxTitle()).to.have.string('3/7');
expect(await wizard.getInputBoxTitle()).to.have.string('3/8');
await wizard.next();

expect(await wizard.getInputBoxTitle()).to.have.string('4/7');
expect(await wizard.getInputBoxTitle()).to.have.string('4/8');
await wizard.next();

expect(await wizard.getInputBoxTitle()).to.have.string('5/7');
expect(await wizard.getInputBoxTitle()).to.have.string('5/8');
await wizard.next();

expect(await wizard.getInputBoxTitle()).to.have.string('6/7');
expect(await wizard.getInputBoxTitle()).to.have.string('6/8');
await wizard.next();

expect(await wizard.getInputBoxTitle()).to.have.string('7/7');
expect(await wizard.getInputBoxTitle()).to.have.string('7/8');
await wizard.focusQuickPick(0);
await wizard.next();

expect(await wizard.getInputBoxTitle()).to.have.string('8/8');
await wizard.prev();

expect(await wizard.getInputBoxTitle()).to.have.string('7/8');
await wizard.prev();

expect(await wizard.getInputBoxTitle()).to.have.string('6/7');
expect(await wizard.getInputBoxTitle()).to.have.string('6/8');
await wizard.prev();

expect(await wizard.getInputBoxTitle()).to.have.string('5/7');
expect(await wizard.getInputBoxTitle()).to.have.string('5/8');
await wizard.prev();

expect(await wizard.getInputBoxTitle()).to.have.string('4/7');
expect(await wizard.getInputBoxTitle()).to.have.string('4/8');
await wizard.prev();

expect(await wizard.getInputBoxTitle()).to.have.string('3/7');
expect(await wizard.getInputBoxTitle()).to.have.string('3/8');
await wizard.prev();

expect(await wizard.getInputBoxTitle()).to.have.string('2/7');
expect(await wizard.getInputBoxTitle()).to.have.string('2/8');
await wizard.prev();

expect(await wizard.getInputBoxTitle()).to.have.string('1/7');
expect(await wizard.getInputBoxTitle()).to.have.string('1/8');
expect(await wizard.getBackButton()).to.not.be.ok;
await wizard.next();

expect(await wizard.getInputBoxTitle()).to.have.string('2/7');
expect(await wizard.getInputBoxTitle()).to.have.string('2/8');
await wizard.prev();

expect(await wizard.getInputBoxTitle()).to.have.string('1/7');
expect(await wizard.getInputBoxTitle()).to.have.string('1/8');
expect(await wizard.getBackButton()).to.not.be.ok;

await wizard.cancel();
Expand Down Expand Up @@ -333,7 +339,7 @@ describe('Project generation tests', function() {
* validation messages
*/
it('should have correct input validation messages', async function() {
this.timeout(30000);
this.timeout(60000);
const wizard: ProjectGenerationWizard = await ProjectGenerationWizard.openWizard(driver);
await wizard.next();

Expand Down Expand Up @@ -430,7 +436,7 @@ describe('Project generation tests', function() {
* Tests if the extensions picker displays extensions without duplicates.
*/
it('should display extensions without duplicates', async function() {
this.timeout(60000);
this.timeout(120000);
const wizard: ProjectGenerationWizard = await ProjectGenerationWizard.openWizard(driver);
await wizard.next();
await wizard.next();
Expand Down

0 comments on commit 8c7c30f

Please sign in to comment.