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

Validator refactoring #165

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
73f4ea9
set AtlasMap version to 2.1.x
kuhy Feb 23, 2021
71bf20b
Test fixes for 2.1.x
asmigala Feb 23, 2021
c9fa137
Merge pull request #163 from atlasmap/atlasmap-2.1.x-fixes
kuhy Feb 24, 2021
c4f8b72
fix warnings checking
kuhy Feb 25, 2021
ff7096c
toggle alert panel in all cases
kuhy Mar 5, 2021
c714c72
add required argument for Concatenate
kuhy Mar 5, 2021
8d1d6a0
reintroduce CSV with custom quote character test
kuhy Mar 8, 2021
f070e43
Merge pull request #164 from atlasmap/atlasmap-2.1.x-fixes-v2
asmigala Mar 8, 2021
04758e2
bump version to 2.2.0
kuhy Mar 16, 2021
f9e6925
support new instance/schema dialog
kuhy Mar 16, 2021
837dd63
Fixes for prod 2.2.x
asmigala Apr 15, 2021
2d77230
Fixes for 2.2.3
asmigala Aug 5, 2021
b0d8373
Don't expect warning for BigDecimal to double
asmigala Aug 6, 2021
d864348
Automatically download correct driver version
asmigala Aug 9, 2021
45b43d3
Merge pull request #166 from atlasmap/webdrivermanager
jbatel Aug 9, 2021
84360fe
Updated instructions for running tests in README.
jbatel Aug 16, 2021
701c38f
Merge pull request #167 from atlasmap/readme-fix
asmigala Aug 17, 2021
986edcd
Fix MappingValidator tests
kuhy Apr 9, 2021
17221f7
Extract mapping logic from MappingValidator
kuhy Apr 10, 2021
2278be3
Refactor test-resources
kuhy Apr 13, 2021
93504e7
Rename packages and enable test classes programmatically
kuhy Apr 13, 2021
29a6194
Refactor ResourceGenerator
kuhy Apr 27, 2021
a217adc
Use constructor injection instead of field injection
kuhy Apr 27, 2021
3e0d835
Support new instance/schema dialog
kuhy Apr 27, 2021
b9b812a
WIP rebase to prod-2.2.x
jbatel Sep 17, 2021
91fd9c7
WIP fixed some issues introduced due to the merge of refactoring
jbatel Mar 22, 2022
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**/build/
**/target/
/target/
/*/target/
**/node
**/*.DS_Store
**/*.iml
Expand Down
23 changes: 2 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ atlasmap.config.ui.browser=chrome
* add `-Datlasmap.version=${VERSION}` to specify AtlasMap version
* add `-Dselenide.headless=true` if you want to run tests in the background
* add `-Dselenide.holdBrowserOpen=true` if you want to keep browser opened after tests
* add `-Dtags='--tags @SmokeTest'` if you want to run only tests tagged with `@SmokeTest`
* add `-Dtags='@SmokeTest'` if you want to run only tests tagged with `@SmokeTest`
* add `-Datlasmap.mappings.root.directory=${mappings_home_dir}` in case you want explicitly specify the mappings root directory, in case it's not inside the test suite - this is set as default
* add `-Datlasmap.fast.init=true` in case you want to setup the tests using
* add `-Datlasmap.adm.resource=${adm_file_path}` in case you want to specify specify the adm file to be used (default is set for _test-resources/src/main/resources/atlasmap-qe.adm_)
Expand All @@ -50,24 +50,5 @@ atlasmap.config.ui.browser=chrome

## Use correct webdriver version for selected browser

By default the testsuite will not download any drivers when running tests. To download drivers, you need to use profile download-drivers, for example `mvn clean install -DskipTests -Pdownload-drivers`. By default the testsuite will download latest drivers which may not work with older browsers. To use older webdriver, find supported version for your browser and set following maven property:

### Chrome

Find supported driver version for chrome browser here: http://chromedriver.chromium.org/downloads

Use following maven parameter when starting the tests: `-Dchrome.driver.version=<selected_version>`

For Chrome version 75, the parameter would be `75.0.3770.8`

For Chrome version 74, the parameter would be `74.0.3729.6`

For Chrome version 73, the parameter would be `73.0.3683.68`

### Firefox

Find supported driver version for your firefox browser here: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/Support.html

Use following maven parameter when starting the tests: ``-Dfirefox.driver.version=<selected_version>``

For firefox 57 the parameter would be `0.24.0`
The correct version of browser driver is automatically detected and downloaded by [WebDriverManager](https://github.com/bonigarcia/webdrivermanager)
48 changes: 11 additions & 37 deletions datamapper-e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
Expand All @@ -71,7 +77,6 @@
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
Expand All @@ -96,6 +101,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>${webdrivermanager.version}</version>
</dependency>
</dependencies>
<build>
<resources>
Expand Down Expand Up @@ -202,41 +212,5 @@
</plugins>
</build>
</profile>
<profile>
<id>download-drivers</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.webdriverextensions</groupId>
<artifactId>webdriverextensions-maven-plugin</artifactId>
<version>${webdriverextensions.version}</version>
<executions>
<execution>
<goals>
<goal>install-drivers</goal>
</goals>
<phase>package</phase>
</execution>
</executions>

<configuration>
<drivers>
<driver>
<name>chromedriver</name>
<version>${chrome.driver.version}</version>
</driver>
<driver>
<name>geckodriver</name>
<version>${firefox.driver.version}</version>
</driver>
</drivers>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
156 changes: 156 additions & 0 deletions datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
package io.atlasmap.qe.test;

import io.atlasmap.qe.test.utils.MappingUtils;
import io.atlasmap.qe.test.utils.TestConfiguration;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;

import java.io.File;
import java.io.IOException;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Optional;
import java.util.function.Consumer;

import io.cucumber.plugin.EventListener;
import io.cucumber.plugin.event.EventHandler;
import io.cucumber.plugin.event.EventPublisher;
import io.cucumber.plugin.event.TestRunFinished;
import io.cucumber.plugin.event.TestRunStarted;


/**
* Loads test resources into AtlasMap.
* It is plugin for {@link CucumberTest} runner.
*
* @author Ondřej Kuhejda
*/
public class AtlasmapInit implements EventListener {

/**
* {@link AtlasmapPage} needed for resources loading.
*/
private final AtlasmapPage atlasmapPage = new AtlasmapPage();

/**
* {@link EventHandler} that is started before all tests.
* Resets all data in AtlasMap.
* Loads JAR file into AtlasMap and then enables classes and imports files.
*/
private final EventHandler<TestRunStarted> setup = event -> runOnPage((page) -> {
page.resetAll();

// Finds file from target folder that was last modified and that ends with ".jar".
Optional<File> jarFile = FileUtils.listFiles(new File(TestConfiguration.getJarFolderPath()),
new WildcardFileFilter("*.jar"), TrueFileFilter.TRUE)
.stream().max(Comparator.comparingLong(File::lastModified));

// Imports JAR file.
if (jarFile.isPresent()) {
try {
page.importJAR(jarFile.get().getCanonicalPath());
} catch (IOException e) {
throw new IllegalStateException("Error when getting canonical path of JAR file.", e);
}
} else {
throw new IllegalStateException("Cannot find JAR file with test classes!");
}

// Source classes:
page.enableSourceClass("io.atlasmap.qe.data.source", "SourceMappingTestClass");
page.enableSourceClass("io.atlasmap.qe.data", "DatesObject");
page.enableSourceClass("io.atlasmap.qe.data.source", "SourceListsClass");
page.enableSourceClass("io.atlasmap.qe.data", "SmallMappingTestClass");
page.enableSourceClass("io.atlasmap.qe.data.source", "SourceNestedCollectionClass");

// Target classes:
page.enableTargetClass("io.atlasmap.qe.data.target", "TargetMappingTestClass");
page.enableTargetClass("io.atlasmap.qe.data", "StringObject");
page.enableTargetClass("io.atlasmap.qe.data.target", "TargetListsClass");
page.enableTargetClass("io.atlasmap.qe.data.target", "TargetNestedCollectionClass");

// Source documents:
page.enableSourceDocumentInstance(TestConfiguration.getDocumentsFolderPath() + "sourceArrays.json");
page.enableSourceDocumentInstance(TestConfiguration.getDocumentsFolderPath() + "sourceJsonArray.json");
page.enableSourceDocumentInstance(TestConfiguration.getDocumentsFolderPath() + "sourceXMLInstance.xml");

page.enableSourceDocumentSchema(TestConfiguration.getDocumentsFolderPath() + "sourceJson.schema.json");
page.enableSourceDocumentSchema(TestConfiguration.getDocumentsFolderPath() + "sourceXMLSchema.xsd");

page.enableCsvSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceCsv.csv", "Default",
new HashMap<String, String>() {{
put("First Record As Header", "true");
}}
);

// Target documents:
page.enableTargetDocumentInstance(TestConfiguration.getDocumentsFolderPath() + "targetArrays.json");
page.enableTargetDocumentInstance(TestConfiguration.getDocumentsFolderPath() + "targetJsonArray.json");
page.enableTargetDocumentInstance(TestConfiguration.getDocumentsFolderPath() + "targetXMLInstance.xml");

page.enableTargetDocumentSchema(TestConfiguration.getDocumentsFolderPath() + "targetJson.schema.json");
page.enableTargetDocumentSchema(TestConfiguration.getDocumentsFolderPath() + "targetXMLSchema.xsd");

page.enableCsvTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetCsv.csv", "Default",
new HashMap<String, String>() {{
put("First Record As Header", "true");
}}
);

// TODO: find more dynamic way for initialization check
MappingUtils.sleep(1000);
try {
MappingUtils.backupAdmFile();
} catch (IOException e) {
throw new IllegalStateException("Error when backing up initial ADM file.", e);
}
});

/**
* Alternative setup {@link EventHandler} that imports required resources into the AtlasMap using ADM file.
*/
private final EventHandler<TestRunStarted> setupFast = event -> runOnPage((page) -> {
page.resetAll();

File admFile = new File(TestConfiguration.getAdmFile());

// Imports ADM file.
try {
page.importAdmFile(admFile.getCanonicalPath());
MappingUtils.backupAdmFile();
} catch (IOException e) {
throw new IllegalStateException("Error when getting canonical path of ADM file.", e);
}
});

/**
* {@link EventHandler} that is started after all tests.
* Resets all data in AtlasMap.
*/
private final EventHandler<TestRunFinished> teardown = event -> runOnPage(AtlasmapPage::resetAll);

/**
* Opens browser and executes steps defined in {@code pageConsumer}.
*
* @param pageConsumer that will be executed inside web browser on {@link AtlasmapInit#atlasmapPage}.
*/
private void runOnPage(Consumer<AtlasmapPage> pageConsumer) {
pageConsumer.accept(atlasmapPage);
}

/**
* Registers handlers for {@link TestRunStarted} and {@link TestRunFinished}.
*
* @param eventPublisher that handles registration.
*/
@Override
public void setEventPublisher(EventPublisher eventPublisher) {
if (TestConfiguration.getFastInit()) {
eventPublisher.registerHandlerFor(TestRunStarted.class, setupFast);
} else {
eventPublisher.registerHandlerFor(TestRunStarted.class, setup);
}
eventPublisher.registerHandlerFor(TestRunFinished.class, teardown);
}
}
Loading