Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Automate gradle analysis with open source dependencies #1219

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cypress/e2e/models/migration/dynamic-report/issues/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from "../../../../types/constants";
import { navMenu } from "../../../../views/menu.view";
import {
affectedFilesTable,
issueColumns,
searchMenuToggle,
singleAppDropList,
Expand Down Expand Up @@ -168,6 +169,32 @@ export class Issues {
});
}

/**
* Opens the side drawer that contains all the affected files of an issue
* @param issueName
*/
public static openAffectedFiles(issueName: string): void {
performWithin(issueName, () => {
cy.get(singleApplicationColumns.files).within(() => {
cy.get(button).click({ force: true });
});
});
}

/**
* Opens the dialog of a single file affected by an Issue
* @param fileName
* @param issueName
*/
public static openAffectedFile(fileName: string, issueName?: string): void {
if (issueName) {
Issues.openAffectedFiles(issueName);
}
cy.get(affectedFilesTable).within(() => {
cy.contains(fileName).click();
});
}

public static validateAllFields(issue: AppIssue): void {
const sections = {
totalAffectedApps: "Total affected",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { Analysis } from "../../../../models/migration/applicationinventory/analysis";
import { AnalysisStatuses } from "../../../../types/constants";
import { Application } from "../../../../models/migration/applicationinventory/application";
import { Issues } from "../../../../models/migration/dynamic-report/issues/issues";

const applications: Analysis[] = [];

Expand Down Expand Up @@ -65,7 +66,31 @@ describe(["@tier2"], "Gradle Analysis", () => {
application.verifyEffort(application.effort);
});

// Automates TC 546
it("Bug MTA-3780: Analysis for Gradle JMH application with Open Source libraries", function () {
const application = new Analysis(
getRandomApplicationData("JMH Gradle OS libs", {
sourceData: this.appData["jmh-gradle-example"],
}),
{
source: "Source code + dependencies",
target: [],
openSourceLibraries: true,
}
);
application.customRule = ["jmh-gradle-serializable-test-rule.yaml"];
application.create();
applications.push(application);
cy.wait("@getApplication");
application.analyze();
application.verifyAnalysisStatus(AnalysisStatuses.completed);
Issues.openSingleApplication(application.name);
// Checks that an incident was raised in an open source library with the provided custom rule
Issues.openAffectedFile("AbstractRealDistribution.java", "Serializable reference test");
});

after("Clear data", function () {
Application.open(true);
deleteByList(applications);
});
});
1 change: 1 addition & 0 deletions cypress/e2e/views/issue.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const archetypeFilterName = "input[class='pf-v5-c-text-input-group__text-
export const searchMenuToggle = 'button[aria-label="Menu toggle"]';
export const singleAppDropList = "#application-select";
export const rightSideBar = "div.pf-v5-c-drawer__panel-main";
export const affectedFilesTable = "table[aria-label='Affected files table']";
export enum singleApplicationColumns {
issue = 'td[data-label="Issue"]',
category = 'td[data-label="Category"]',
Expand Down
10 changes: 10 additions & 0 deletions cypress/fixtures/yaml/jmh-gradle-serializable-test-rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- category: mandatory
customVariables: []
description: Serializable reference test rule for https://github.com/melix/jmh-gradle-example
effort: 1
message: |-
Serializable reference test rule for https://github.com/melix/jmh-gradle-example
ruleID: serializable-reference-test-rule-jmh-gradle
when:
java.referenced:
pattern: java.io.Serializable
Loading