Skip to content

Commit

Permalink
[RFR] Automate gradle analysis with open source dependencies (#1219)
Browse files Browse the repository at this point in the history
* automate first gradle analysis

Signed-off-by: Alejandro Brugarolas <[email protected]>

* first commit

Signed-off-by: Alejandro Brugarolas <[email protected]>

* Automate gradle analysis with open source dependencies

Signed-off-by: Alejandro Brugarolas <[email protected]>

* finish

Signed-off-by: Alejandro Brugarolas <[email protected]>

---------

Signed-off-by: Alejandro Brugarolas <[email protected]>
  • Loading branch information
abrugaro authored Sep 13, 2024
1 parent 4c0d1b3 commit 5f87f94
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
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

0 comments on commit 5f87f94

Please sign in to comment.