diff --git a/cypress/e2e/models/administration/custom-migration-targets/custom-migration-target.ts b/cypress/e2e/models/administration/custom-migration-targets/custom-migration-target.ts index fe13e4024..75774d9b3 100644 --- a/cypress/e2e/models/administration/custom-migration-targets/custom-migration-target.ts +++ b/cypress/e2e/models/administration/custom-migration-targets/custom-migration-target.ts @@ -18,7 +18,11 @@ import { SEC, } from "../../../types/constants"; import { navMenu } from "../../../views/menu.view"; -import { CustomMigrationTargetView } from "../../../views/custom-migration-target.view"; +import { + CustomMigrationTargetView, + sourcesList, + sourcesToggle, +} from "../../../views/custom-migration-target.view"; import { RulesManualFields, RulesRepositoryFields } from "../../../types/types"; import { actionSelectToggle, submitButton } from "../../../views/common.view"; @@ -28,6 +32,7 @@ export interface CustomMigrationTarget { imagePath?: string; ruleTypeData: RulesRepositoryFields | RulesManualFields; language: Languages; + sources?: string; } export class CustomMigrationTarget { @@ -36,15 +41,17 @@ export class CustomMigrationTarget { description: string, imagePath: string, ruleTypeData: RulesRepositoryFields | RulesManualFields, - language = Languages.Java + language = Languages.Java, + sources?: string ) { this.name = name; this.description = description; this.ruleTypeData = ruleTypeData; this.language = language; + this.sources = sources; } - public static fullUrl = Cypress.env("tackleUrl") + "migration-targets"; + public static fullUrl = Cypress.env("tackleUrl") + "/migration-targets"; public static open(forceReload = false) { if (forceReload) { @@ -184,4 +191,9 @@ export class CustomMigrationTarget { }); }); } + + validateSourceTechnology(sources: string): void { + click(sourcesToggle); + cy.get(sourcesList).should("contain", sources); + } } diff --git a/cypress/e2e/tests/administration/custom-migration-targets/crud.test.ts b/cypress/e2e/tests/administration/custom-migration-targets/crud.test.ts index 163920bcd..359b17364 100644 --- a/cypress/e2e/tests/administration/custom-migration-targets/crud.test.ts +++ b/cypress/e2e/tests/administration/custom-migration-targets/crud.test.ts @@ -224,4 +224,62 @@ describe(["@tier1", "@dc", "@interop"], "Custom Migration Targets CRUD operation application.delete(); }); }); + + Object.values(Languages).forEach((language) => { + it(`${language} | custom rule with source technology`, function () { + const targetData = this.customMigrationTargets["rules_with_source_element"]; + const target = new CustomMigrationTarget( + data.getRandomWord(8), + data.getDescription(), + targetData.image, + getRulesData(targetData), + language, + targetData.sources + ); + target.create(); + + const dragButton = cy + .contains(CustomMigrationTargetView.card, target.name, { timeout: 12 * SEC }) + .find(CustomMigrationTargetView.dragButton); + cy.wait(SEC); + cy.wait("@getRule"); + dragButton.drag(commonView.optionMenu, { + force: true, + waitForAnimations: false, + }); + cy.wait(SEC); + + const application = new Analysis( + getRandomApplicationData("bookserverApp", { + sourceData: this.appData["bookserver-app"], + }), + getRandomAnalysisData(this.analysisData["source_analysis_on_bookserverapp"]) + ); + application.create(); + + // TC MTA-404 + Analysis.open(); + selectItemsPerPage(100); + application.selectApplication(); + cy.contains(button, analyzeButton, { timeout: 20 * SEC }) + .should("be.enabled") + .click(); + + application.selectSourceofAnalysis(application.source); + cy.contains(button, "Next", { timeout: 200 }).click(); + + Analysis.selectLanguage(language); + cy.get(".pf-v5-c-card__body", { timeout: 12 * SEC }) + .should("contain", target.name) + .click(); + cy.contains(button, "Next", { timeout: 200 }).click(); + cy.contains(button, "Next", { timeout: 200 }).click(); + cy.contains(button, "Next", { timeout: 200 }).click(); + target.validateSourceTechnology(targetData.sources); + clickByText(button, "Cancel"); + + target.delete(); + application.delete(); + }); + }); }); diff --git a/cypress/e2e/views/custom-migration-target.view.ts b/cypress/e2e/views/custom-migration-target.view.ts index a0bfe7ce4..457b5e395 100644 --- a/cypress/e2e/views/custom-migration-target.view.ts +++ b/cypress/e2e/views/custom-migration-target.view.ts @@ -1,3 +1,5 @@ +export const sourcesToggle = "#sources-toggle"; +export const sourcesList = "ul#formSources-id.pf-v5-c-select__menu"; export enum CustomMigrationTargetView { createSubmitButton = "button[id='identity-form-submit']:contains('Create')", editSubmitButton = "button[id='identity-form-submit']:contains('Save')", diff --git a/cypress/fixtures/custom-rules.json b/cypress/fixtures/custom-rules.json index e1441cf08..1bdb803c0 100644 --- a/cypress/fixtures/custom-rules.json +++ b/cypress/fixtures/custom-rules.json @@ -24,5 +24,11 @@ "hazelcast_target": { "image": "img/cloud.png", "rulesFiles": ["xml/hazelcast.windup.xml"] + }, + + "rules_with_source_element": { + "image": "img/cloud.png", + "rulesFiles": ["xml/corporate-framework-config.windup.xml"], + "sources": "traditional-corporate-framework" } } diff --git a/cypress/fixtures/xml/corporate-framework-config.windup.xml b/cypress/fixtures/xml/corporate-framework-config.windup.xml new file mode 100644 index 000000000..16e5e7314 --- /dev/null +++ b/cypress/fixtures/xml/corporate-framework-config.windup.xml @@ -0,0 +1,64 @@ + + + + + This ruleset provides rules related to the corporate configuration frameworks. + + + + + + + + configuration + + + + + + VARIABLE_DECLARATION + + + + + + The legacy ApplicationConfiguration class is being used in this application. This is discouraged by the migration + guidelines, and should be replaced by a more standard approach using Spring's @PropertySource annotation and Environment class: + + + ```java + @PropertySource("classpath:persistence.properties") + public class PersistenceConfig { + @Autowired + private Environment env; + + @Bean + public DataSource dataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName")); + dataSource.setUrl(env.getProperty("jdbc.url")); + dataSource.setUsername(env.getProperty("jdbc.user")); + dataSource.setPassword(env.getProperty("jdbc.password")); + + return dataSource; + } + } + ``` + + + + This allows externalizing the configuration in Kubernetes by injecting it as a ConfigMap or a Secret in the lib directory from the + container running the Tomcat instance. + + + + + configuration + + + + +