From a2ee112b2261209ecd7f517c3c5e045bc30eaa3a Mon Sep 17 00:00:00 2001 From: kpunwatk Date: Fri, 15 Mar 2024 15:01:23 +0530 Subject: [PATCH] [WIP] Automate MTA-404 custom rules with source technology Signed-off-by: Karishma Punwatkar modified: cypress/e2e/tests/administration/custom-migration-targets/crud.test.ts modified: cypress/fixtures/custom-rules.json new file: cypress/fixtures/xml/corporate-framework-config.windup.xml --- .../custom-migration-targets/crud.test.ts | 44 +++++++++++++ cypress/fixtures/custom-rules.json | 5 ++ .../xml/corporate-framework-config.windup.xml | 64 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 cypress/fixtures/xml/corporate-framework-config.windup.xml 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..96aebe446 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,48 @@ 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 + ); + target.create(); + + const application = new Analysis( + getRandomApplicationData("bookserverApp", { + sourceData: this.appData["bookserver-app"], + }), + getRandomAnalysisData(this.analysisData["source_analysis_on_bookserverapp"]) + ); + + // ToDo add validation to check source technology in advance option + + application.create(); + + 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 }) + .first() + .should("contain", target.name); + clickByText(button, "Cancel"); + + target.delete(); + application.delete(); + }); + }); }); diff --git a/cypress/fixtures/custom-rules.json b/cypress/fixtures/custom-rules.json index e1441cf08..11d159694 100644 --- a/cypress/fixtures/custom-rules.json +++ b/cypress/fixtures/custom-rules.json @@ -24,5 +24,10 @@ "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"] } } 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 + + + + +