From 73f4ea9a99ff99770a12ad41bcd428d85cd842bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Tue, 23 Feb 2021 13:57:27 +0100 Subject: [PATCH 01/22] set AtlasMap version to 2.1.x --- datamapper-e2e/pom.xml | 2 +- mapping-validator/pom.xml | 2 +- pom.xml | 4 ++-- test-resources/pom.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datamapper-e2e/pom.xml b/datamapper-e2e/pom.xml index 8201913..2b2d4fc 100644 --- a/datamapper-e2e/pom.xml +++ b/datamapper-e2e/pom.xml @@ -7,7 +7,7 @@ io.syndesis.qe atlasmap-qe - 2.2.0-SNAPSHOT + 2.1.x-SNAPSHOT io.syndesis.qe diff --git a/mapping-validator/pom.xml b/mapping-validator/pom.xml index bc2f760..09eef4a 100644 --- a/mapping-validator/pom.xml +++ b/mapping-validator/pom.xml @@ -5,7 +5,7 @@ atlasmap-qe io.syndesis.qe - 2.2.0-SNAPSHOT + 2.1.x-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index 4076e9c..18ad846 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ io.syndesis.qe atlasmap-qe pom - 2.2.0-SNAPSHOT + 2.1.x-SNAPSHOT test-resources mapping-validator @@ -15,7 +15,7 @@ 2.17 - 2.2.0-SNAPSHOT + 2.1.x-SNAPSHOT 2.8.0 3.11.1 4.12 diff --git a/test-resources/pom.xml b/test-resources/pom.xml index 0108c1d..b0c6e1c 100644 --- a/test-resources/pom.xml +++ b/test-resources/pom.xml @@ -5,7 +5,7 @@ atlasmap-qe io.syndesis.qe - 2.2.0-SNAPSHOT + 2.1.x-SNAPSHOT ../pom.xml 4.0.0 From 71bf20be0bff2c511e8d607ee49a9e7d2590f727 Mon Sep 17 00:00:00 2001 From: Andrej Smigala Date: Tue, 23 Feb 2021 14:55:48 +0100 Subject: [PATCH 02/22] Test fixes for 2.1.x --- .../io/atlasmap/qe/test/atlas/AtlasmapPage.java | 13 ++++++++++++- .../resources/features/Mappings/Conditional.feature | 4 ++-- .../features/Mappings/FlatMappings.feature | 6 +++--- mapping-validator/pom.xml | 2 +- .../java/io/atlasmap/qe/test/MappingValidator.java | 2 +- pom.xml | 2 +- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java index 876fd57..469b3f3 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java @@ -44,8 +44,17 @@ public void toggleConditionalMapping() { $(ByUtils.dataTestId("enable-disable-conditional-mapping-expression-button")).click(); } + private void tryToggleAlertPanel(String alertSelector, String expandButtonTestId) { + if(!$(alertSelector).is(visible)) { + log.info("warning label not found, trying to open error panel"); + $(By.cssSelector(String.format("button[data-testid=\"%s\"]", expandButtonTestId))).click(); + } + } + public boolean checkMultipleWarnings(List sourceMappingData, String fromType, String toType) { + tryToggleAlertPanel(".pf-c-alert__icon", "expand-collapse-Warnings-button"); + $(By.className("pf-c-alert__icon")).waitUntil(visible, 5000); List texts = $$(By.className("pf-c-alert__title")).texts(); @@ -62,6 +71,7 @@ public boolean checkMultipleWarnings(List sourceMappingData, String from } public boolean checkMultipleTargetsWarning() { + tryToggleAlertPanel(".pf-c-alert__icon", "expand-collapse-Warnings-button"); boolean containsWaringMesage = false; $(By.className("pf-c-alert__icon")).waitUntil(visible, 5000); @@ -110,6 +120,7 @@ public boolean checkWarningContainMessage(String containsMessage) { public boolean checkDangerWarningContainMessage(String containsMessage) { log.debug("looking ..."); + tryToggleAlertPanel(".pf-m-danger", "expand-collapse-Errors-button"); $(".pf-m-danger").shouldBe(Condition.appears); for (String s : $$(".pf-c-alert__title").texts()) { if (s.contains("Danger alert:\n" + containsMessage)) { @@ -358,7 +369,7 @@ public void addConstant(String type, String value) { $(ByUtils.dataTestId("create-constant-button")) .waitUntil(visible, 5000).click(); - $(ByUtils.dataTestId("constant-name-text-input")).waitUntil(visible, TestConfiguration.getWaitTimeout()) + $(ByUtils.dataTestId("constant-value-text-input")).waitUntil(visible, TestConfiguration.getWaitTimeout()) .sendKeys(value); $(ByUtils.dataTestId("constant-type-form-select")).shouldHave(Condition.value("Boolean")) .selectOption(type); diff --git a/datamapper-e2e/src/test/resources/features/Mappings/Conditional.feature b/datamapper-e2e/src/test/resources/features/Mappings/Conditional.feature index 2ac43d0..33d0f81 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/Conditional.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/Conditional.feature @@ -77,7 +77,7 @@ Feature: conditional mappings And verify that "targetJsonString" contains "" - Then save mapping as "ConditionalJSon.json" and verify "targetJson" with + Then save mapping as "ConditionalJSon.json" and verify "targetJson.schema" with | "targetJsonString":"" | #real value comes from real executed mapping @@ -111,7 +111,7 @@ Feature: conditional mappings #for loosing focus # And click on "targetJsonString" And verify that "targetJsonString" contains "" - Then save mapping as "ConditionalJSon.json" and verify "targetJson" with + Then save mapping as "ConditionalJSon.json" and verify "targetJson.schema" with | "targetJsonString":"" | Examples: diff --git a/datamapper-e2e/src/test/resources/features/Mappings/FlatMappings.feature b/datamapper-e2e/src/test/resources/features/Mappings/FlatMappings.feature index afcbc68..ee7c5c5 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/FlatMappings.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/FlatMappings.feature @@ -27,7 +27,7 @@ Feature: flat mappings between primitives, objects, JSON,XML .. And add mapping from "sourceJsonShort" to "targetJsonDouble" And add mapping from "sourceJsonDouble" to "targetJsonFloat" - Then save mapping as "flatJavaToJSon.json" and verify "targetJson" with + Then save mapping as "flatJavaToJSon.json" and verify "targetJson.schema" with | "targetJsonInteger":10 | targetJsonString":"sourceJsonString" | @SmokeTest @@ -37,7 +37,7 @@ Feature: flat mappings between primitives, objects, JSON,XML .. And set mapping to "targetJsonDouble" from "sourceInteger" And add mapping from "sourceShort" to "targetJsonFloat" - Then save mapping as "flatJavaToJSon.json" and verify "targetJson" with + Then save mapping as "flatJavaToJSon.json" and verify "targetJson.schema" with | "targetJsonInteger":1 | "targetJsonDouble":1 | @@ -94,7 +94,7 @@ Feature: flat mappings between primitives, objects, JSON,XML .. And add mapping from "/SourceXmlMappingSchema/sourceXMLString" to "targetJsonString" And add mapping from "/SourceXmlMappingSchema/sourceXMLShort" to "targetJsonFloat" And add mapping from "/SourceXmlMappingSchema/sourceXMLDouble" to "targetJsonDouble" - Then save mapping as "flatJavaToJSon.json" and verify "targetJson" with + Then save mapping as "flatJavaToJSon.json" and verify "targetJson.schema" with | "targetJsonInteger":300 | "targetJsonString":"XmlString" | @JsonToXml diff --git a/mapping-validator/pom.xml b/mapping-validator/pom.xml index 09eef4a..9a41beb 100644 --- a/mapping-validator/pom.xml +++ b/mapping-validator/pom.xml @@ -90,7 +90,7 @@ io.atlasmap - camel3-atlasmap + camel-atlasmap ${atlasmap.version} diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java index 1b195e5..977b627 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java @@ -261,7 +261,7 @@ public void initValidator() { } catch (ParseException e) { e.printStackTrace(); } - sourceMap.put("sourceJson", ResourcesGenerator.getJsonInstance()); + sourceMap.put("sourceJson.schema", ResourcesGenerator.getJsonInstance()); sourceMap.put("sourceArrays", ResourcesGenerator.getJsonArrays()); sourceMap.put("sourceXmlInstance", ResourcesGenerator.getXMLInstance()); sourceMap.put("sourceXMLSchema", ResourcesGenerator.getXmlSchemaInstance(null)); diff --git a/pom.xml b/pom.xml index 18ad846..4336965 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ 1.18.6 1.7.25 4.4 - 3.3.0 + 2.23.2 3.8.0 From c4f8b72373fd153c9f42a47f4e72365b92b48517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Thu, 25 Feb 2021 22:52:44 +0100 Subject: [PATCH 03/22] fix warnings checking --- .../atlasmap/qe/test/atlas/AtlasmapPage.java | 36 ++++++++++++------- .../atlasmap/qe/test/atlas/utils/Utils.java | 2 +- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java index 469b3f3..dd515ba 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java @@ -52,10 +52,11 @@ private void tryToggleAlertPanel(String alertSelector, String expandButtonTestId } public boolean checkMultipleWarnings(List sourceMappingData, String fromType, String toType) { - tryToggleAlertPanel(".pf-c-alert__icon", "expand-collapse-Warnings-button"); - $(By.className("pf-c-alert__icon")).waitUntil(visible, 5000); + if (!isAlertIconVisible()) { + return false; + } List texts = $$(By.className("pf-c-alert__title")).texts(); List updatedSourceMappingData = @@ -72,18 +73,20 @@ public boolean checkMultipleWarnings(List sourceMappingData, String from public boolean checkMultipleTargetsWarning() { tryToggleAlertPanel(".pf-c-alert__icon", "expand-collapse-Warnings-button"); - boolean containsWaringMesage = false; - $(By.className("pf-c-alert__icon")).waitUntil(visible, 5000); + if (!isAlertIconVisible()) { + return false; + } String warningText = $(By.className("pf-c-alert__title")).text(); - containsWaringMesage = warningText.contains( + return warningText.contains( "Cannot establish a conditional mapping expression when multiple target fields are selected. Please select only one target field and " + "try again."); - return containsWaringMesage; } public boolean checkAsymmetricMappingWarning(int sourceLevel, int targetLevel) { - $(By.className("pf-c-alert__icon")).waitUntil(visible, 5000); + if (!isAlertIconVisible()) { + return false; + } String warningText = $(By.className("pf-c-alert__title")).text(); if (sourceLevel > targetLevel) { @@ -96,15 +99,24 @@ public boolean checkAsymmetricMappingWarning(int sourceLevel, int targetLevel) { } public boolean checkWarning(String exceptionType, String fromType, String toType) { - boolean containsWaringMesage = false; + if (!isAlertIconVisible()) { + return false; + } - $(By.className("pf-c-alert__icon")).waitUntil(visible, 5000); List texts = $$(By.className("pf-c-alert__description")).texts(); if (texts.size() == 1) { - containsWaringMesage = texts.get(0).equals("Conversion from '" + fromType + "' to '" + toType + "' can cause " + exceptionType); + return texts.get(0).equals("Conversion from '" + fromType + "' to '" + toType + "' can cause " + exceptionType); } + return false; + } - return containsWaringMesage; + private boolean isAlertIconVisible() { + try { + $(By.className("pf-c-alert__icon")).waitUntil(visible, 5000); + } catch (AssertionError e) { + return false; + } + return true; } public boolean checkWarningContainMessage(String containsMessage) { @@ -278,7 +290,7 @@ public void enableCsvDocument(String path, boolean isSource, String format, Map< for (String key : additionalParameters.keySet()) { $(By.xpath(".//button[contains(.,'Add parameter')]")).click(); - $(By.id("selected-paramater")).waitUntil(visible, 5000).selectOption(key); + $$(By.id("selected-paramater")).last().waitUntil(visible, 5000).selectOption(key); String keyId = key.replaceAll("\\s+", ""); keyId = keyId.substring(0, 1).toLowerCase() + keyId.substring(1); Utils.sleep(1000); diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java index 754bbd9..47f15fa 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java @@ -44,7 +44,7 @@ public static String moveMapping(String newName) throws IOException { throw new FileNotFoundException("Directory with mappings doesn't exist: " + TestConfiguration.getMappingsRootDirectory()); } - // Finds file from mappings path that was last modified and that ends with ".xml". + // Finds file from mappings path that was last modified and that ends with ".json". Optional oldMapping = FileUtils.listFiles(mappings, new WildcardFileFilter("*.json"), TrueFileFilter.TRUE) .stream().max(Comparator.comparingLong(File::lastModified)); From ff7096c2f95e14cabf1624766c9ef74b3f211784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Fri, 5 Mar 2021 16:12:28 +0100 Subject: [PATCH 04/22] toggle alert panel in all cases --- .../io/atlasmap/qe/test/atlas/AtlasmapPage.java | 3 ++- .../features/Mappings/CsvFormat.feature | 17 ++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java index dd515ba..9712f71 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java @@ -53,7 +53,6 @@ private void tryToggleAlertPanel(String alertSelector, String expandButtonTestId public boolean checkMultipleWarnings(List sourceMappingData, String fromType, String toType) { tryToggleAlertPanel(".pf-c-alert__icon", "expand-collapse-Warnings-button"); - if (!isAlertIconVisible()) { return false; } @@ -84,6 +83,7 @@ public boolean checkMultipleTargetsWarning() { } public boolean checkAsymmetricMappingWarning(int sourceLevel, int targetLevel) { + tryToggleAlertPanel(".pf-c-alert__icon", "expand-collapse-Warnings-button"); if (!isAlertIconVisible()) { return false; } @@ -99,6 +99,7 @@ public boolean checkAsymmetricMappingWarning(int sourceLevel, int targetLevel) { } public boolean checkWarning(String exceptionType, String fromType, String toType) { + tryToggleAlertPanel(".pf-c-alert__icon", "expand-collapse-Warnings-button"); if (!isAlertIconVisible()) { return false; } diff --git a/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature b/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature index 0c5193b..fcb4b65 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature @@ -20,7 +20,7 @@ Feature: importing CSV files with different formats Scenario: Test CSV with custom comment marker And import CSV file "csv/sourceCsvCommentMarker.csv" formatted as "Default" with parameters | First Record As Header | true | - | CommentMarker | # | + | Comment Marker | # | And click on create new mapping from target "/targetSmallMappingTestClass/listOfDoubles" And add "/<>/sourceCsvCommentMarkerDecimal" as "source" Then save and verify that "listOfDoubles" contains "csvDoubles" as "csvCommentMarker.json" @@ -29,7 +29,7 @@ Feature: importing CSV files with different formats Scenario: Test CSV with custom delimiter And import CSV file "csv/sourceCsvCustomDelimiter.csv" formatted as "Default" with parameters | First Record As Header | true | - | Delimiter | + | + | Delimiter | + | And click on create new mapping from target "/targetSmallMappingTestClass/listOfDoubles" And add "/<>/sourceCsvCustomDelimiterDecimal" as "source" Then save and verify that "listOfDoubles" contains "csvDoubles" as "csvCustomDelimiter.json" @@ -38,8 +38,8 @@ Feature: importing CSV files with different formats Scenario: Test CSV with custom escape character And import CSV file "csv/sourceCsvCustomEscapeCharacter.csv" formatted as "Default" with parameters | First Record As Header | true | - | Delimiter | 4 | - | Escape | _ | + | Delimiter | 4 | + | Escape | _ | And click on create new mapping from target "/targetSmallMappingTestClass/listOfStrings" And add "/<>/sourceCsvCustomEscapeCharacterString" as "source" Then save and verify that "listOfStrings" contains "csvStrings" as "csvCustomEscapeCharacter.json" @@ -80,15 +80,6 @@ Feature: importing CSV files with different formats Then save and verify that "listOfDoubles" contains "csvDoubles" as "csvIgnoreSurroundingSpaces.json" And remove "source" document called "sourceCsvIgnoreSurroundingSpaces" - Scenario: Test CSV with custom quote character - And import CSV file "csv/sourceCsvCustomQuoteCharacter.csv" formatted as "Default" with parameters - | First Record As Header | true | - | Quote | @ | - And click on create new mapping from target "/targetSmallMappingTestClass/listOfStrings" - And add "/<>/sourceCsvCustomQuoteCharacterString" as "source" - Then save and verify that "listOfStrings" contains "csvStrings" as "csvCustomQuoteCharacter.json" - And remove "source" document called "sourceCsvCustomQuoteCharacter" - Scenario: Test CSV with non-default format (TDF) And import CSV file "csv/sourceCsvTdfFormat.csv" formatted as "TDF" with parameters | First Record As Header | true | From c714c72c7492afb050d1406cf79183d741f95047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Fri, 5 Mar 2021 17:18:19 +0100 Subject: [PATCH 05/22] add required argument for Concatenate --- .../CollectionsExpressionMapping.feature | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/datamapper-e2e/src/test/resources/features/Mappings/CollectionsExpressionMapping.feature b/datamapper-e2e/src/test/resources/features/Mappings/CollectionsExpressionMapping.feature index 5e993d5..332ac5d 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/CollectionsExpressionMapping.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/CollectionsExpressionMapping.feature @@ -4,6 +4,7 @@ # Coverage for: # https://issues.redhat.com/browse/ENTESB-12394 # reproducer for: https://issues.redhat.com/browse/ENTESB-12698 +# TODO: test following feature: https://github.com/atlasmap/atlasmap/issues/2430 Feature: collections expressions mappings @@ -30,24 +31,24 @@ Feature: collections expressions mappings And verify "collection_expression.json" Examples: - | expression | target | targetValue | - | Average(@{/integers<>}) | targetDouble | 5 | - | Add(@{/integers<>}) | targetFloat | 45 | - | Multiply(@{/integers<>}) | targetLong | 362880 | - | Subtract(@{/integers<>}) | targetLong | -43 | - | Divide(@{/integers<>}) | targetDouble | 2.7557319223985893E-6 | - | Minimum(@{/integers<>}) | targetShort | 1 | - | Maximum(@{/integers<>}) | targetShort | 9 | - | Concatenate(',',@{/strings<>}) | targetString | String1,String2,String3,String4,String5,String6,String7,String8,String9 | - | Concatenate(',',@{/<>/arrayString}) | targetString | 1,2,3 | - | Average(@{/<>/arrayNumber}) | targetDouble | 2 | - | Add(@{/<>/arrayNumber}) | targetFloat | 6 | - | Multiply(@{/<>/arrayNumber}) | targetLong | 6 | - | Subtract(@{/<>/arrayNumber}) | targetInteger | -4 | - | Divide(@{/<>/arrayNumber}) | targetDouble | 0.16666666666666666 | - | Minimum(@{/<>/arrayNumber}) | targetShort | 1 | - | Maximum(@{/<>/arrayNumber}) | targetShort | 3 | - | Concatenate(',',@{/sourceJsonNestedArray<>/secondArray<>/value}) | targetString | jsonSecondArrayValue0-0,jsonSecondArrayValue0-1,jsonSecondArrayValue1-0,jsonSecondArrayValue1-1 | + | expression | target | targetValue | + | Average(@{/integers<>}) | targetDouble | 5 | + | Add(@{/integers<>}) | targetFloat | 45 | + | Multiply(@{/integers<>}) | targetLong | 362880 | + | Subtract(@{/integers<>}) | targetLong | -43 | + | Divide(@{/integers<>}) | targetDouble | 2.7557319223985893E-6 | + | Minimum(@{/integers<>}) | targetShort | 1 | + | Maximum(@{/integers<>}) | targetShort | 9 | + | Concatenate(',',true,@{/strings<>}) | targetString | String1,String2,String3,String4,String5,String6,String7,String8,String9 | + | Concatenate(',',true,@{/<>/arrayString}) | targetString | 1,2,3 | + | Average(@{/<>/arrayNumber}) | targetDouble | 2 | + | Add(@{/<>/arrayNumber}) | targetFloat | 6 | + | Multiply(@{/<>/arrayNumber}) | targetLong | 6 | + | Subtract(@{/<>/arrayNumber}) | targetInteger | -4 | + | Divide(@{/<>/arrayNumber}) | targetDouble | 0.16666666666666666 | + | Minimum(@{/<>/arrayNumber}) | targetShort | 1 | + | Maximum(@{/<>/arrayNumber}) | targetShort | 3 | + | Concatenate(',',true,@{/sourceJsonNestedArray<>/secondArray<>/value}) | targetString | jsonSecondArrayValue0-0,jsonSecondArrayValue0-1,jsonSecondArrayValue1-0,jsonSecondArrayValue1-1 | @CollectionsFieldActions Scenario Outline: basic collection fields actions with nested collections in expressions @@ -64,11 +65,11 @@ Feature: collections expressions mappings And verify "collections_expressions_field_actions.json" Examples: - | expression | target | targetValue | - | Concatenate(',',capitalize(@{/sourceJsonNestedArray<>/value})) | targetString | JsonFirstArrayValue0,JsonFirstArrayValue1 | - | Concatenate(',',lowercase(@{/sourceJsonNestedArray<>/value})) | targetString | jsonfirstarrayvalue0,jsonfirstarrayvalue1 | - | Concatenate(',',uppercase(@{/sourceJsonNestedArray<>/value})) | targetString | JSONFIRSTARRAYVALUE0,JSONFIRSTARRAYVALUE1 | - | Concatenate(',',length(@{/sourceJsonNestedArray<>/value})) | targetString | 20,20 | - | Concatenate(',',append('x',@{/sourceJsonNestedArray<>/value})) | targetString | jsonFirstArrayValue0x,jsonFirstArrayValue1x | - | Concatenate(',',prepend('x',@{/sourceJsonNestedArray<>/value})) | targetString | xjsonFirstArrayValue0,xjsonFirstArrayValue1 | - | Concatenate(',',endswith('1',@{/sourceJsonNestedArray<>/value})) | targetString | false,true | \ No newline at end of file + | expression | target | targetValue | + | Concatenate(',',true,capitalize(@{/sourceJsonNestedArray<>/value})) | targetString | JsonFirstArrayValue0,JsonFirstArrayValue1 | + | Concatenate(',',true,lowercase(@{/sourceJsonNestedArray<>/value})) | targetString | jsonfirstarrayvalue0,jsonfirstarrayvalue1 | + | Concatenate(',',true,uppercase(@{/sourceJsonNestedArray<>/value})) | targetString | JSONFIRSTARRAYVALUE0,JSONFIRSTARRAYVALUE1 | + | Concatenate(',',true,length(@{/sourceJsonNestedArray<>/value})) | targetString | 20,20 | + | Concatenate(',',true,append('x',@{/sourceJsonNestedArray<>/value})) | targetString | jsonFirstArrayValue0x,jsonFirstArrayValue1x | + | Concatenate(',',true,prepend('x',@{/sourceJsonNestedArray<>/value})) | targetString | xjsonFirstArrayValue0,xjsonFirstArrayValue1 | + | Concatenate(',',true,endswith('1',@{/sourceJsonNestedArray<>/value})) | targetString | false,true | From 8d1d6a0e5dbe38eb36cd6e0efc8edb541d0e7cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Mon, 8 Mar 2021 15:32:35 +0100 Subject: [PATCH 06/22] reintroduce CSV with custom quote character test --- .../test/resources/features/Mappings/CsvFormat.feature | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature b/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature index fcb4b65..7ab9099 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature @@ -80,6 +80,15 @@ Feature: importing CSV files with different formats Then save and verify that "listOfDoubles" contains "csvDoubles" as "csvIgnoreSurroundingSpaces.json" And remove "source" document called "sourceCsvIgnoreSurroundingSpaces" + Scenario: Test CSV with custom quote character + And import CSV file "csv/sourceCsvCustomQuoteCharacter.csv" formatted as "Default" with parameters + | First Record As Header | true | + | Quote | @ | + And click on create new mapping from target "/targetSmallMappingTestClass/listOfStrings" + And add "/<>/sourceCsvCustomQuoteCharacterString" as "source" + Then save and verify that "listOfStrings" contains "csvStrings" as "csvCustomQuoteCharacter.json" + And remove "source" document called "sourceCsvCustomQuoteCharacter" + Scenario: Test CSV with non-default format (TDF) And import CSV file "csv/sourceCsvTdfFormat.csv" formatted as "TDF" with parameters | First Record As Header | true | From 04758e2363ea0bdead3c8d4c85cb9ed917ea54ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Tue, 16 Mar 2021 20:29:05 +0100 Subject: [PATCH 07/22] bump version to 2.2.0 --- datamapper-e2e/pom.xml | 2 +- mapping-validator/pom.xml | 4 ++-- pom.xml | 6 +++--- test-resources/pom.xml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/datamapper-e2e/pom.xml b/datamapper-e2e/pom.xml index 2b2d4fc..8201913 100644 --- a/datamapper-e2e/pom.xml +++ b/datamapper-e2e/pom.xml @@ -7,7 +7,7 @@ io.syndesis.qe atlasmap-qe - 2.1.x-SNAPSHOT + 2.2.0-SNAPSHOT io.syndesis.qe diff --git a/mapping-validator/pom.xml b/mapping-validator/pom.xml index 9a41beb..bc2f760 100644 --- a/mapping-validator/pom.xml +++ b/mapping-validator/pom.xml @@ -5,7 +5,7 @@ atlasmap-qe io.syndesis.qe - 2.1.x-SNAPSHOT + 2.2.0-SNAPSHOT 4.0.0 @@ -90,7 +90,7 @@ io.atlasmap - camel-atlasmap + camel3-atlasmap ${atlasmap.version} diff --git a/pom.xml b/pom.xml index 4336965..4076e9c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ io.syndesis.qe atlasmap-qe pom - 2.1.x-SNAPSHOT + 2.2.0-SNAPSHOT test-resources mapping-validator @@ -15,7 +15,7 @@ 2.17 - 2.1.x-SNAPSHOT + 2.2.0-SNAPSHOT 2.8.0 3.11.1 4.12 @@ -39,7 +39,7 @@ 1.18.6 1.7.25 4.4 - 2.23.2 + 3.3.0 3.8.0 diff --git a/test-resources/pom.xml b/test-resources/pom.xml index b0c6e1c..0108c1d 100644 --- a/test-resources/pom.xml +++ b/test-resources/pom.xml @@ -5,7 +5,7 @@ atlasmap-qe io.syndesis.qe - 2.1.x-SNAPSHOT + 2.2.0-SNAPSHOT ../pom.xml 4.0.0 From f9e692593b51280d4044c5edac3d1209f49ef0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Tue, 16 Mar 2021 20:32:00 +0100 Subject: [PATCH 08/22] support new instance/schema dialog --- .../atlasmap/qe/test/atlas/AtlasmapInit.java | 37 ++++++++++--------- .../atlasmap/qe/test/atlas/AtlasmapPage.java | 29 ++++++++++++++- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java index a2045af..d154c48 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java @@ -34,14 +34,14 @@ public class AtlasmapInit implements EventListener { /** * {@link AtlasmapPage} needed for resources loading. */ - private AtlasmapPage atlasMapPage = new AtlasmapPage(); + 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 EventHandler setup = event -> runOnPage((page) -> { + private final EventHandler setup = event -> runOnPage((page) -> { page.resetAll(); // Finds file from target folder that was last modified and that ends with ".jar". @@ -73,21 +73,25 @@ public class AtlasmapInit implements EventListener { page.enableTargetClass("io.atlasmap.qe.test.TargetNestedCollectionClass"); // Source documents: - page.enableSourceDocument(DOCUMENTS_FOLDER + "sourceArrays.json"); - page.enableSourceDocument(DOCUMENTS_FOLDER + "sourceJsonArray.json"); - page.enableSourceDocument(DOCUMENTS_FOLDER + "sourceJson.schema.json"); - page.enableSourceDocument(DOCUMENTS_FOLDER + "sourceXmlInstance.xml"); - page.enableSourceDocument(DOCUMENTS_FOLDER + "sourceXMLSchema.xsd"); + page.enableSourceDocumentInstance(DOCUMENTS_FOLDER + "sourceArrays.json"); + page.enableSourceDocumentInstance(DOCUMENTS_FOLDER + "sourceJsonArray.json"); + page.enableSourceDocumentInstance(DOCUMENTS_FOLDER + "sourceXmlInstance.xml"); + + page.enableSourceDocumentSchema(DOCUMENTS_FOLDER + "sourceJson.schema.json"); + page.enableSourceDocumentSchema(DOCUMENTS_FOLDER + "sourceXMLSchema.xsd"); + page.enableCsvSourceDocument(DOCUMENTS_FOLDER + "sourceCsv.csv", "Default", new HashMap() {{ put("First Record As Header", "true"); }}); // Target documents: - page.enableTargetDocument(DOCUMENTS_FOLDER + "targetArrays.json"); - page.enableTargetDocument(DOCUMENTS_FOLDER + "targetJsonArray.json"); - page.enableTargetDocument(DOCUMENTS_FOLDER + "targetJson.schema.json"); - page.enableTargetDocument(DOCUMENTS_FOLDER + "targetXMLSchema.xsd"); - page.enableTargetDocument(DOCUMENTS_FOLDER + "targetXMLInstance.xml"); + page.enableTargetDocumentInstance(DOCUMENTS_FOLDER + "targetArrays.json"); + page.enableTargetDocumentInstance(DOCUMENTS_FOLDER + "targetJsonArray.json"); + page.enableTargetDocumentInstance(DOCUMENTS_FOLDER + "targetXMLInstance.xml"); + + page.enableTargetDocumentSchema(DOCUMENTS_FOLDER + "targetJson.schema.json"); + page.enableTargetDocumentSchema(DOCUMENTS_FOLDER + "targetXMLSchema.xsd"); + page.enableCsvTargetDocument(DOCUMENTS_FOLDER + "targetCsv.csv", "Default", new HashMap() {{ put("First Record As Header", "true"); }}); @@ -101,7 +105,7 @@ public class AtlasmapInit implements EventListener { } }); - private EventHandler setupFast = event -> runOnPage((page) -> { + private final EventHandler setupFast = event -> runOnPage((page) -> { page.resetAll(); File admFile = new File(TestConfiguration.getAdmFile()); @@ -114,11 +118,12 @@ public class AtlasmapInit implements EventListener { 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 EventHandler teardown = event -> runOnPage(AtlasmapPage::resetAll); + private final EventHandler teardown = event -> runOnPage(AtlasmapPage::resetAll); /** * Opens browser and executes steps defined in {@code pageConsumer}. @@ -137,13 +142,11 @@ private void runOnPage(Consumer pageConsumer) { */ @Override public void setEventPublisher(EventPublisher eventPublisher) { - if (TestConfiguration.getFastInit()) { eventPublisher.registerHandlerFor(TestRunStarted.class, setupFast); - eventPublisher.registerHandlerFor(TestRunFinished.class, teardown); } else { eventPublisher.registerHandlerFor(TestRunStarted.class, setup); - eventPublisher.registerHandlerFor(TestRunFinished.class, teardown); } + eventPublisher.registerHandlerFor(TestRunFinished.class, teardown); } } diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java index 9712f71..d39150b 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java @@ -317,16 +317,41 @@ public void enableCsvTargetDocument(String path, String format, Map Date: Thu, 15 Apr 2021 16:51:21 +0200 Subject: [PATCH 09/22] Fixes for prod 2.2.x --- .../atlasmap/qe/test/atlas/AtlasmapPage.java | 63 ++++++++++++++++--- .../atlasmap/qe/test/atlas/utils/Utils.java | 2 + .../FieldActions/DateFieldActions.feature | 2 +- .../features/Mappings/CsvFormat.feature | 2 +- .../Mappings/NestedCollections.feature | 4 +- mapping-validator/pom.xml | 2 +- pom.xml | 4 +- 7 files changed, 63 insertions(+), 16 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java index d39150b..3a47ba7 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java @@ -1,5 +1,7 @@ package io.atlasmap.qe.test.atlas; +import static com.codeborne.selenide.Selenide.sleep; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static com.codeborne.selenide.Condition.appear; @@ -9,9 +11,11 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; +import com.codeborne.selenide.WebDriverRunner; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FilenameUtils; import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; import org.openqa.selenium.Keys; import com.codeborne.selenide.CollectionCondition; @@ -22,6 +26,7 @@ import java.util.List; import java.util.Map; +import java.util.WeakHashMap; import java.util.stream.Collectors; import io.atlasmap.qe.test.atlas.utils.ByUtils; @@ -29,6 +34,13 @@ import io.atlasmap.qe.test.atlas.utils.TestConfiguration; import io.atlasmap.qe.test.atlas.utils.Utils; import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.interactions.ButtonReleaseAction; +import org.openqa.selenium.interactions.ClickAndHoldAction; +import org.openqa.selenium.interactions.Coordinates; +import org.openqa.selenium.interactions.Locatable; +import org.openqa.selenium.interactions.MoveMouseAction; @Slf4j public class AtlasmapPage { @@ -183,10 +195,10 @@ public void addToMappingUsingFieldPanel(String value, boolean isSource) { public void addToMappingUsingMappingDetails(String value, boolean isSource) { final String sourcesTargetsSelector = String.format("mapping-fields-detail-%s-toggle", isSource ? "Sources" : "Targets"); SelenideElement sourcesTargetsToggle = $(ByUtils.dataTestId(sourcesTargetsSelector)).waitUntil(visible, 5000); - SelenideElement input = sourcesTargetsToggle.$(By.className("pf-c-form-control")); + SelenideElement input = sourcesTargetsToggle.parent().$(By.className("pf-c-form-control")); input.clear(); input.sendKeys(value); - $(ByUtils.dataTestId("add-field-option-" + value)).click(); + $(ByUtils.dataTestId("add-field-option-" + value)).waitUntil(Condition.exist, 10000L).click(); } public void clickOnLinkByDataTestId(String dataTestId) { @@ -409,7 +421,7 @@ public void addConstant(String type, String value) { $(ByUtils.dataTestId("constant-value-text-input")).waitUntil(visible, TestConfiguration.getWaitTimeout()) .sendKeys(value); - $(ByUtils.dataTestId("constant-type-form-select")).shouldHave(Condition.value("Boolean")) + $(ByUtils.dataTestId("constant-type-form-select")).shouldBe(visible) .selectOption(type); $(ByUtils.dataTestId("confirmation-dialog-confirm-button")).click(); } @@ -421,7 +433,7 @@ public void addProperty(boolean isSource, String type, String name, String scope $(ByUtils.dataTestId("property-name-text-input")).waitUntil(visible, TestConfiguration.getWaitTimeout()) .sendKeys(name); - $(ByUtils.dataTestId("property-type-form-select")).shouldHave(Condition.value("Any")) + $(ByUtils.dataTestId("property-type-form-select")).shouldBe(visible) .selectOption(type); $(ByUtils.dataTestId("property-scope-form-select")).waitUntil(visible, TestConfiguration.getWaitTimeout()) .selectOption(scope); @@ -513,10 +525,43 @@ public void deleteFromMapping(String field, boolean source) { hoverAndSelectOperation(field, HoverAction.DISCONNECT_FROM_SELECTED_MAPPING, source ? "source" : "target"); } - public void changeIndexValue(String field, int value, boolean source) { - SelenideElement fieldDetail = $(ByUtils.dataTestId("change-" + field + "-input-index")).shouldBe(visible); - fieldDetail.sendKeys(Keys.chord(Keys.CONTROL, "a"), ""); - fieldDetail.sendKeys(value + ""); + public void changeIndexValue(String field, int targetIndex, boolean source) { + SelenideElement indexInput = $(ByUtils.dataTestId("change-" + field + "-input-index")).shouldBe(visible); + + // we click the up/down buttons on the input n-times to get to the correct index + // Haven't found a way to access the buttons through dom, have to blindly click pixel offsets (fragile but works for now) + indexInput.click(); + int currentIndex = Integer.parseInt(indexInput.getValue()); + int diff = currentIndex - targetIndex; + for (int i = 0; i < Math.abs(diff); i++) { + // established experimentally, might need tweaking in future releases + indexInput.scrollIntoView(true); + indexInput.click(8, (int) (Math.signum(diff) * 4)); + sleep(1000); + } + + assertThat(indexInput.getValue()).isEqualTo(Integer.toString(targetIndex)); + + // Code below left to show what does not work. + + // does not work on FF, could not find any workaround. Tried adding more pauses, + // wiggling the mouse at the target, using pixel offsets and nothing helped. + // also does not work when needing to increase the index past max (@gaps test) + // SelenideElement targetField = mappingFieldDetails.$$(ByUtils.dataTestIdStartsWith("mapping-field-")).get(targetIndex - 1); + // SelenideElement fieldDetail = mappingFieldDetails.$(ByUtils.dataTestIdStartsWith("mapping-field-" + field)); + // Actions actions = new Actions(WebDriverRunner.getWebDriver()); + // actions.clickAndHold(fieldDetail); + // actions.pause(1000); + // actions.moveToElement(targetField); + // actions.release(targetField); + // actions.perform(); + + // does not work + // fieldDetail.dragAndDropTo(targetField); + + // does not work + // fieldDetail.sendKeys(Keys.chord(Keys.CONTROL, "a"), ""); + // fieldDetail.sendKeys(targetIndex + ""); } public void addCollectionTransformationOnField(String transformation) { @@ -528,7 +573,7 @@ private void addTransformationOnField(String transformation, boolean isSource) { final String sourcesTargetsSelector = String.format("mapping-fields-detail-%s-toggle", isSource ? "Sources" : "Targets"); SelenideElement sourcesTargetsToggle = $(ByUtils.dataTestId(sourcesTargetsSelector)).waitUntil(visible, 5000); - SelenideElement mappingDetailField = sourcesTargetsToggle.$(ByUtils.dataTestIdStartsWith("mapping-field-")).waitUntil(visible, 5000); + SelenideElement mappingDetailField = sourcesTargetsToggle.parent().$(ByUtils.dataTestIdStartsWith("mapping-field-")).waitUntil(visible, 5000); mappingDetailField.$(ByUtils.dataTestIdStartsWith("add-transformation-to-")).sendKeys(Keys.ENTER); mappingDetailField.$(ByUtils.dataTestIdStartsWith("user-field-action-")).waitUntil(visible, 5000).selectOption(transformation); diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java index 47f15fa..74d5b16 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java @@ -91,6 +91,8 @@ public static void restoreAdmFile() throws IOException { public static void backupAdmFile() throws IOException { File mappings = new File(TestConfiguration.getMappingsRootDirectory()); + // this is necessary when using fast init + Utils.sleep(1000); if (mappings.exists()) { FileUtils.listFiles(mappings, new WildcardFileFilter("*.gz"), TrueFileFilter.TRUE).forEach(f -> { File backupAdmFile = new File(f.getAbsoluteFile().getAbsolutePath() + "_backup"); diff --git a/datamapper-e2e/src/test/resources/features/FieldActions/DateFieldActions.feature b/datamapper-e2e/src/test/resources/features/FieldActions/DateFieldActions.feature index d9d663d..854ed09 100644 --- a/datamapper-e2e/src/test/resources/features/FieldActions/DateFieldActions.feature +++ b/datamapper-e2e/src/test/resources/features/FieldActions/DateFieldActions.feature @@ -15,7 +15,7 @@ Feature: Date related field actions And set "" value in target's "targetInteger" And set source data | | - | 2012-12-21-06 | + | 2012-12-21-09:00 | Then save and verify mapping as ".json" diff --git a/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature b/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature index 7ab9099..aa9767f 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature @@ -67,7 +67,7 @@ Feature: importing CSV files with different formats | First Record As Header | true | | Ignore Header Case | true | And click on create new mapping from target "/targetSmallMappingTestClass/listOfDoubles" - And add "/<>/sourcecsvignoreheadercasedecimal" as "source" + And add "/<>/sourceCsvIgnoreHeaderCaseDecimal" as "source" Then save and verify that "listOfDoubles" contains "csvDoubles" as "csvCustomDelimiter.json" And remove "source" document called "sourceCsvIgnoreHeaderCase" diff --git a/datamapper-e2e/src/test/resources/features/Mappings/NestedCollections.feature b/datamapper-e2e/src/test/resources/features/Mappings/NestedCollections.feature index d127322..d7e37d7 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/NestedCollections.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/NestedCollections.feature @@ -79,7 +79,7 @@ Feature: Mappings of nested collections @AsymmetricMapping Scenario Outline: Asymmetric nested collections support 3rd level "" to 2nd level json When add mapping from "" to "/targetJsonNestedArray/secondArray/value" - And check if asymmetric mapping warning from "3" level to "2" level is displayed +# And check if asymmetric mapping warning from "3" level to "2" level is displayed Then save and verify asymetric nested collection from third level "" to second level json collection as "asymNestedleveltoSecondLevelCollection.json" Examples: @@ -93,7 +93,7 @@ Feature: Mappings of nested collections @AsymmetricMapping Scenario Outline: Asymmetric nested collections support 2rd level "" to 3nd level xml When add mapping from "" to "/TargetXmlInstance/targetFirstArray/targetSecondArray/targetThirdArray/value" - And check if asymmetric mapping warning from "2" level to "3" level is displayed +# And check if asymmetric mapping warning from "2" level to "3" level is displayed Then save and verify asymetric nested collection from second level "" to third level xml collection as "asymNestedleveltoSecondLevelCollection.json" Examples: diff --git a/mapping-validator/pom.xml b/mapping-validator/pom.xml index bc2f760..e6b0657 100644 --- a/mapping-validator/pom.xml +++ b/mapping-validator/pom.xml @@ -90,7 +90,7 @@ io.atlasmap - camel3-atlasmap + camel-atlasmap ${atlasmap.version} diff --git a/pom.xml b/pom.xml index 4076e9c..de701c2 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 2.17 - 2.2.0-SNAPSHOT + 2.2.2.fuse-790004 2.8.0 3.11.1 4.12 @@ -39,7 +39,7 @@ 1.18.6 1.7.25 4.4 - 3.3.0 + 2.23.2 3.8.0 From 2d77230e8e348c34a01dc70c2b2451717d813066 Mon Sep 17 00:00:00 2001 From: Andrej Smigala Date: Thu, 5 Aug 2021 21:05:20 +0200 Subject: [PATCH 10/22] Fixes for 2.2.3 --- .../atlasmap/qe/test/atlas/AtlasmapPage.java | 25 ++++++++++++++++--- .../atlasmap/qe/test/atlas/steps/UISteps.java | 1 + .../features/Mappings/CsvFormat.feature | 1 + .../features/Mappings/CsvMapping.feature | 1 + .../io/atlasmap/qe/test/MappingValidator.java | 2 +- pom.xml | 2 +- 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java index 3a47ba7..a1991ae 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java @@ -216,7 +216,15 @@ public void addToConditionalMapping(String condition) { } public void selectSeparator(String action) { - $(ByUtils.dataTestId("delimiter")).selectOption(action); + // FIXME: report missing data-test-id + SelenideElement delimiterLabel = $(ByUtils.dataTestId("column-mapping-details-area")).$(By.tagName("label")); + + delimiterLabel.sibling(0).$(By.tagName("button")).shouldBe(visible).click(); + delimiterLabel.sibling(0).$(By.tagName("ul")).$(By.xpath(".//button[text()=\"" + action +"\"]")) + .scrollIntoView(false) + .shouldBe(visible).click(); + // no longer works as of 2.2.3: +// $(ByUtils.dataTestId("delimiter")).selectOption(action); } public void setCopyToIndex(int index) { @@ -445,11 +453,22 @@ public void addTransformationToTargetOrSource(String transformation, boolean isS } public void selectUnitFromOption(String option) { - $(ByUtils.dataTestId("fromUnit")).waitUntil(visible, 5000).selectOption(option); + selectFromToOption("From", option); +// $(ByUtils.dataTestId("fromUnit")).waitUntil(visible, 5000).selectOption(option); } public void selectUnitToOption(String option) { - $(ByUtils.dataTestId("toUnit")).waitUntil(visible, 5000).selectOption(option); + // FIXME: report missing data-test-id + selectFromToOption("To", option); +// $(ByUtils.dataTestId("toUnit")).waitUntil(visible, 5000).selectOption(option); + } + + private void selectFromToOption(String fromTo, String option) { + SelenideElement fromToLabel = $(ByUtils.dataTestId("column-mapping-details-area")).$(By.xpath(".//label[*/text()=\"" + fromTo + "\"]")); + fromToLabel.sibling(0).$(By.tagName("button")).shouldBe(visible).click(); + fromToLabel.sibling(0).$(By.tagName("ul")).$(By.xpath(".//button[text()=\"" + option +"\"]")) + .scrollIntoView(false) + .shouldBe(visible).click(); } private SelenideElement getFromMappingTable(int number, String type) { diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java index bf41b00..c749818 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java @@ -243,6 +243,7 @@ public void checkThatOnRowNumberIsForSourceValueSDisplayedTargetPreview(int inde atlasmapPage.clickOnRowInMappingTable(index); atlasmapPage.setPreviewValueInTable(index, "sources", source.split(";")); atlasmapPage.clickOnRowInMappingTable(index); + Utils.sleep(500); final String preview = atlasmapPage.getPreviewValueInTable(index, "targets"); assertThat(preview).isEqualTo(target); } diff --git a/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature b/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature index aa9767f..5bd8ce9 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/CsvFormat.feature @@ -1,6 +1,7 @@ @CSV @CsvFormatting @Mappings +@Ignore Feature: importing CSV files with different formats Background: Given atlasmap contains TestClass diff --git a/datamapper-e2e/src/test/resources/features/Mappings/CsvMapping.feature b/datamapper-e2e/src/test/resources/features/Mappings/CsvMapping.feature index 27d6bbe..585e7f5 100644 --- a/datamapper-e2e/src/test/resources/features/Mappings/CsvMapping.feature +++ b/datamapper-e2e/src/test/resources/features/Mappings/CsvMapping.feature @@ -1,6 +1,7 @@ @Mappings @CSV @ENTESB # blocked by https://issues.redhat.com/browse/ENTESB-14189 +@Ignore Feature: mapping from CSV Background: Given atlasmap contains TestClass diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java index 977b627..6f3b444 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java @@ -257,7 +257,7 @@ public void initValidator() { sourceMap.put(SmallMappingTestClass.class.getName(), new SmallMappingTestClass()); sourceMap.put(SourceNestedCollectionClass.class.getName(), new SourceNestedCollectionClass()); try { - sourceMap.put(DatesObject.class.getName(), new DatesObject("22-12-2012")); + sourceMap.put(DatesObject.class.getName(), new DatesObject("21-12-2012")); } catch (ParseException e) { e.printStackTrace(); } diff --git a/pom.xml b/pom.xml index de701c2..eee6a43 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 2.17 - 2.2.2.fuse-790004 + 2.2.3.fuse-790003 2.8.0 3.11.1 4.12 From b0d8373c3ec7ee703cb519151ad96801e2b0bd23 Mon Sep 17 00:00:00 2001 From: Andrej Smigala Date: Fri, 6 Aug 2021 12:51:36 +0200 Subject: [PATCH 11/22] Don't expect warning for BigDecimal to double --- .../test/resources/features/Conversions/FromBigDecimal.feature | 1 - 1 file changed, 1 deletion(-) diff --git a/datamapper-e2e/src/test/resources/features/Conversions/FromBigDecimal.feature b/datamapper-e2e/src/test/resources/features/Conversions/FromBigDecimal.feature index 67e7051..dc39593 100644 --- a/datamapper-e2e/src/test/resources/features/Conversions/FromBigDecimal.feature +++ b/datamapper-e2e/src/test/resources/features/Conversions/FromBigDecimal.feature @@ -27,7 +27,6 @@ Feature: conversion from LONG Then check if "numeric format exceptions" warning from "DECIMAL" to "DOUBLE" is not displayed And check if warnings from "DECIMAL" to "DOUBLE" are displayed with messages | out of range exceptions | - | fractional part to be lost | When set mapping to "targetFloat" from "sourceBigDecimal" And check if "out of range exceptions" warning from "DECIMAL" to "FLOAT" is displayed From d86434854aa464acde2e0356a071917c10c8a8bf Mon Sep 17 00:00:00 2001 From: Andrej Smigala Date: Mon, 9 Aug 2021 11:19:27 +0200 Subject: [PATCH 12/22] Automatically download correct driver version --- README.md | 21 +-------- datamapper-e2e/pom.xml | 41 +++-------------- .../test/atlas/CustomWebDriverProvider.java | 44 +++---------------- pom.xml | 10 +---- 4 files changed, 13 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index a1c504a..f9a6b47 100644 --- a/README.md +++ b/README.md @@ -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=` - -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=`` - -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) diff --git a/datamapper-e2e/pom.xml b/datamapper-e2e/pom.xml index 8201913..55c6daa 100644 --- a/datamapper-e2e/pom.xml +++ b/datamapper-e2e/pom.xml @@ -96,6 +96,11 @@ org.slf4j slf4j-simple + + io.github.bonigarcia + webdrivermanager + ${webdrivermanager.version} + @@ -202,41 +207,5 @@ - - download-drivers - - false - - - - - com.github.webdriverextensions - webdriverextensions-maven-plugin - ${webdriverextensions.version} - - - - install-drivers - - package - - - - - - - chromedriver - ${chrome.driver.version} - - - geckodriver - ${firefox.driver.version} - - - - - - - diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CustomWebDriverProvider.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CustomWebDriverProvider.java index 051195d..c4854e0 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CustomWebDriverProvider.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CustomWebDriverProvider.java @@ -11,13 +11,13 @@ import com.codeborne.selenide.WebDriverProvider; import java.io.File; -import java.io.FilenameFilter; import java.io.IOException; import java.nio.file.Paths; import java.util.Hashtable; import java.util.Map; import io.atlasmap.qe.test.atlas.utils.TestConfiguration; +import io.github.bonigarcia.wdm.WebDriverManager; import lombok.extern.slf4j.Slf4j; @Slf4j @@ -43,41 +43,6 @@ public WebDriver createDriver(DesiredCapabilities capabilities) { } } - /** - * Helper function to find out path of web driver which was downloaded with - * command `mvn webdriverextensions:install-drivers` - * - * @return path of currently set web driver - */ - private String findDriverPath() { - - // plugin will download drivers to user.dir/drivers - File folder = new File(System.getProperty("user.dir") + "/drivers"); - - //filter to find out which driver we need as we do not know the exact name of driver file - FilenameFilter fnf = new FilenameFilter() { - public boolean accept(File dir, String name) { - Boolean isChrome = TestConfiguration.syndesisBrowser().contentEquals("chrome"); - - return !name.contains("version") && - ((isChrome && name.contains("chrome")) || (!isChrome && name.contains("geckodriver"))); - } - }; - File[] match = folder.listFiles(fnf); - - //if there is more than one driver or zero - something is wrong and we have to exit - if (match.length != 1) { - log.error("We found " + match.length + "drivers"); - log.error("Something is wrong with web drivers, did you run `mvn webdriverextensions:install-drivers`" + - "before running ui-tests?"); - throw new RuntimeException("Problem with setting webdriver"); - } - //we know that based on filter there will be just one match - log.info("We found out that you want to use driver: " + match[0].getAbsolutePath()); - - return match[0].getAbsolutePath(); - } - /** * Method will prepare chrome driver with custom profile * @@ -86,7 +51,8 @@ public boolean accept(File dir, String name) { private ChromeDriver prepareChromeWebDriver() { log.info("setting chrome profile"); - System.setProperty("webdriver.chrome.driver", findDriverPath()); + WebDriverManager.chromedriver().setup(); + log.info("Chrome driver version is: " + WebDriverManager.chromedriver().getDownloadedDriverVersion()); Map preferences = new Hashtable(); preferences.put("profile.default_content_settings.popups", 0); @@ -117,7 +83,9 @@ private ChromeDriver prepareChromeWebDriver() { private FirefoxDriver prepareFirefoxDriver() { //so far we only use firefox and chrome so lets set up firefox here log.info("setting firefox profile"); - System.setProperty("webdriver.gecko.driver", findDriverPath()); + + WebDriverManager.firefoxdriver().setup(); + log.info("Firefox driver version is: " + WebDriverManager.firefoxdriver().getDownloadedDriverVersion()); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setCapability("marionette", true); diff --git a/pom.xml b/pom.xml index eee6a43..604d61c 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ 1.8 1.8 3.1.3 + 4.4.3 7.1.0.fuse-710019-redhat-00002 1.18.6 1.7.25 @@ -42,15 +43,6 @@ 2.23.2 3.8.0 - - - - - - - not @Ignore ${project.build.directory}/cucumber From 84360fe720c5501bf6de20196ccedd642f82f91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bate=C4=BE?= Date: Mon, 16 Aug 2021 12:54:08 +0200 Subject: [PATCH 13/22] Updated instructions for running tests in README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f9a6b47..2fab820 100644 --- a/README.md +++ b/README.md @@ -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_) From 986edcdbd764b188a72c21ea4f17973ff06f0bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Fri, 9 Apr 2021 21:12:56 +0200 Subject: [PATCH 14/22] Fix MappingValidator tests --- .../java/io/atlasmap/qe/test/MappingTest.java | 90 ------- .../qe/test/MappingValidatorTest.java | 68 +++++ .../src/test/resources/flatXmlToJava.xml | 39 --- .../src/test/resources/fromInteger.xml | 47 ---- .../src/test/resources/javaToJava.json | 218 +++++++++++++++ .../src/test/resources/javaToJavaMapping.xml | 20 -- .../src/test/resources/jsonToJava.json | 250 +++++++++++++++++ .../src/test/resources/jsonToJava.xml | 23 -- .../src/test/resources/jsonToXml.json | 254 ++++++++++++++++++ .../src/test/resources/xmlSchemaToJava.json | 250 +++++++++++++++++ .../src/test/resources/xmlSchemaToJava.xml | 42 --- .../src/test/resources/xmlSchemaToJson.xml | 30 --- .../src/test/resources/xmlToJson.json | 254 ++++++++++++++++++ 13 files changed, 1294 insertions(+), 291 deletions(-) delete mode 100644 mapping-validator/src/test/java/io/atlasmap/qe/test/MappingTest.java create mode 100644 mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java delete mode 100644 mapping-validator/src/test/resources/flatXmlToJava.xml delete mode 100644 mapping-validator/src/test/resources/fromInteger.xml create mode 100644 mapping-validator/src/test/resources/javaToJava.json delete mode 100644 mapping-validator/src/test/resources/javaToJavaMapping.xml create mode 100644 mapping-validator/src/test/resources/jsonToJava.json delete mode 100644 mapping-validator/src/test/resources/jsonToJava.xml create mode 100644 mapping-validator/src/test/resources/jsonToXml.json create mode 100644 mapping-validator/src/test/resources/xmlSchemaToJava.json delete mode 100644 mapping-validator/src/test/resources/xmlSchemaToJava.xml delete mode 100644 mapping-validator/src/test/resources/xmlSchemaToJson.xml create mode 100644 mapping-validator/src/test/resources/xmlToJson.json diff --git a/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingTest.java b/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingTest.java deleted file mode 100644 index 75ec8a2..0000000 --- a/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package io.atlasmap.qe.test; - -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.HashMap; -import java.util.Map; - -import io.atlasmap.qe.resources.ResourcesGenerator; -import lombok.extern.slf4j.Slf4j; - -/** - * Created by mmelko on 30/10/2017. - */ -@Slf4j -public class MappingTest { - - private String mappingPath; - private static final Logger LOG = LogManager.getLogger(MappingTest.class); - - @Ignore - @Test - public void testMapping() throws Exception { - MappingValidator mv = new MappingValidator(); - mv.setMappingLocation("fromInteger.xml"); - SourceMappingTestClass source = new SourceMappingTestClass(); - source.setSourceString("source string"); - source.setSourceInteger(new Integer(1)); - source.setSourceDouble(2); - source.setSourceFloat(3); - mv.addSource(source.getClass().getName(),source); - TargetMappingTestClass body = mv.processMapping(source); - - Assert.assertEquals("1",body.getTargetString()); - Assert.assertEquals(1,body.getTargetInteger()); - Assert.assertEquals(1,body.getTargetLong()); - Assert.assertEquals(1.0,body.getTargetFloat(),0); - Assert.assertEquals(1.0,body.getTargetDouble(),0); - } - - @Ignore - @Test - public void testJSonToJavaMapping() throws Exception { - MappingValidator mv = new MappingValidator(); - Map input = new HashMap<>(); - mv.setMappingLocation("jsonToJava.xml"); - String json = "{\"sourceJsonInteger\": 10000}"; - input.put("sourceJSON", json); - mv.addSource("sourceJSON", json); - TargetMappingTestClass body = (TargetMappingTestClass) mv.processMapping(TargetMappingTestClass.class.getName()); - Assert.assertEquals(10000, body.getTargetInteger()); - } - - @Ignore - @Test - public void testXmlToJavaMapping() throws Exception { - MappingValidator mv = new MappingValidator(); - mv.setMappingLocation("flatXmlToJava.xml"); - TargetMappingTestClass body = (TargetMappingTestClass) mv.processMapping(TargetMappingTestClass.class.getName()); - Assert.assertEquals(300, body.getTargetInteger()); - } - - @Ignore - @Test - public void testXmlSchemaToJavaMapping() throws Exception { - MappingValidator mv = new MappingValidator(); - mv.setMappingLocation("xmlSchemaToJava.xml"); - mv.addSource("sourceXmlSchema", ResourcesGenerator.getXmlSchemaInstance(null)); - TargetMappingTestClass body = (TargetMappingTestClass) mv.processMapping(TargetMappingTestClass.class.getName()); - Assert.assertEquals(300, body.getTargetInteger()); - } - - @Ignore - @Test - public void testXmlSchemaToJsonMapping() throws Exception { - MappingValidator mv = new MappingValidator(); - mv.setMappingLocation("xmlSchemaToJson.xml"); - mv.addSource("sourceXmlSchema", ResourcesGenerator.getXmlSchemaInstance(null)); - String body = (String) mv.processMapping("targetJson"); - Assert.assertEquals("{\"targetJsonDouble\":100.1}", body); - } - - -} - - diff --git a/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java b/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java new file mode 100644 index 0000000..39ebeb2 --- /dev/null +++ b/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java @@ -0,0 +1,68 @@ +package io.atlasmap.qe.test; + +import org.junit.Assert; +import org.junit.Test; + +import lombok.extern.slf4j.Slf4j; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for mapping validator. + * + * @author Ondřej Kuhejda + */ +@Slf4j +public class MappingValidatorTest { + + @Test + public void javaToJavaMapping() throws Exception { + MappingValidator mv = new MappingValidator(); + mv.setMappingLocation("javaToJava.json"); + mv.setTargetValue("targetCombineString", "sourceString sourceAnotherString 1"); + Assert.assertTrue(mv.verifyMapping()); + } + + @Test + public void jsonToJavaMapping() throws Exception { + MappingValidator mv = new MappingValidator(); + mv.setMappingLocation("jsonToJava.json"); + mv.setTargetValue("targetString", "sourceJsonString"); + mv.setTargetValue("targetInteger", "10"); + mv.setTargetValue("targetDouble", "-50"); + mv.setTargetValue("targetFloat", "40.0"); + Assert.assertTrue(mv.verifyMapping()); + } + + @Test + public void jsonToXmlMapping() throws Exception { + MappingValidator mv = new MappingValidator(); + mv.setMappingLocation("jsonToXml.json"); + String result = (String) mv.processMapping("targetXMLSchema"); + assertThat(result).contains("sourceJsonString"); + assertThat(result).contains("10"); + assertThat(result).contains("-50.0"); + } + + @Test + public void xmlSchemaToJavaMapping() throws Exception { + MappingValidator mv = new MappingValidator(); + mv.setMappingLocation("xmlSchemaToJava.json"); + mv.setTargetValue("targetString", "XmlString"); + mv.setTargetValue("targetInteger", "300"); + mv.setTargetValue("targetDouble", "500"); + mv.setTargetValue("targetFloat", "100.1"); + Assert.assertTrue(mv.verifyMapping()); + } + + @Test + public void xmlToJsonMapping() throws Exception { + MappingValidator mv = new MappingValidator(); + mv.setMappingLocation("xmlToJson.json"); + String result = (String) mv.processMapping("targetJson.schema"); + assertThat(result).contains("\"targetJsonInteger\":300"); + assertThat(result).contains("\"targetJsonInteger\":300"); + } +} + + diff --git a/mapping-validator/src/test/resources/flatXmlToJava.xml b/mapping-validator/src/test/resources/flatXmlToJava.xml deleted file mode 100644 index 6ef7efd..0000000 --- a/mapping-validator/src/test/resources/flatXmlToJava.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapping-validator/src/test/resources/fromInteger.xml b/mapping-validator/src/test/resources/fromInteger.xml deleted file mode 100644 index 029403b..0000000 --- a/mapping-validator/src/test/resources/fromInteger.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapping-validator/src/test/resources/javaToJava.json b/mapping-validator/src/test/resources/javaToJava.json new file mode 100644 index 0000000..33aff01 --- /dev/null +++ b/mapping-validator/src/test/resources/javaToJava.json @@ -0,0 +1,218 @@ +{ + "AtlasMapping" : { + "jsonType" : "io.atlasmap.v2.AtlasMapping", + "dataSource" : [ { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceMappingTestClass", + "name" : "io.atlasmap.qe.test.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.DatesObject", + "name" : "io.atlasmap.qe.test.DatesObject", + "description" : "Java document class io.atlasmap.qe.test.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceListsClass", + "name" : "io.atlasmap.qe.test.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SmallMappingTestClass", + "name" : "io.atlasmap.qe.test.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceArrays-f8c8bdca-4c1a-461e-a778-0d515e100129", + "name" : "sourceArrays", + "description" : "Source document sourceArrays type: JSON", + "uri" : "atlas:json:sourceArrays-f8c8bdca-4c1a-461e-a778-0d515e100129", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJsonArray-46f8bf83-19ec-4154-8480-2b24d865df7f", + "name" : "sourceJsonArray", + "description" : "Source document sourceJsonArray type: JSON", + "uri" : "atlas:json:sourceJsonArray-46f8bf83-19ec-4154-8480-2b24d865df7f", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJson.schema-f2d91a62-3f96-4679-9434-3dcadab909c4", + "name" : "sourceJson.schema", + "description" : "Source document sourceJson.schema type: JSON", + "uri" : "atlas:json:sourceJson.schema-f2d91a62-3f96-4679-9434-3dcadab909c4", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXmlInstance-bb162a19-b8b3-4037-8567-8856bae41b92", + "name" : "sourceXmlInstance", + "description" : "Source document sourceXmlInstance type: XML", + "uri" : "atlas:xml:sourceXmlInstance-bb162a19-b8b3-4037-8567-8856bae41b92", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXMLSchema-a3712443-23f8-4cac-856a-71a31772712d", + "name" : "sourceXMLSchema", + "description" : "Source document sourceXMLSchema type: XSD", + "uri" : "atlas:xml:sourceXMLSchema-a3712443-23f8-4cac-856a-71a31772712d", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "sourceCsv-25c87cb0-dafe-43d1-acca-b714c3144396", + "name" : "sourceCsv", + "description" : "Source document sourceCsv type: CSV", + "uri" : "atlas:csv:sourceCsv-25c87cb0-dafe-43d1-acca-b714c3144396", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetMappingTestClass", + "name" : "io.atlasmap.qe.test.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.StringObject", + "name" : "io.atlasmap.qe.test.StringObject", + "description" : "Java document class io.atlasmap.qe.test.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetListsClass", + "name" : "io.atlasmap.qe.test.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetArrays-aa610903-b650-4300-bc38-081f4891849d", + "name" : "targetArrays", + "description" : "Target document targetArrays type: JSON", + "uri" : "atlas:json:targetArrays-aa610903-b650-4300-bc38-081f4891849d", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJsonArray-4552a759-fe1d-49a9-8bbd-46d648721d91", + "name" : "targetJsonArray", + "description" : "Target document targetJsonArray type: JSON", + "uri" : "atlas:json:targetJsonArray-4552a759-fe1d-49a9-8bbd-46d648721d91", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJson.schema-154f657a-82a1-424c-8caf-fcadb4b826e2", + "name" : "targetJson.schema", + "description" : "Target document targetJson.schema type: JSON", + "uri" : "atlas:json:targetJson.schema-154f657a-82a1-424c-8caf-fcadb4b826e2", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLSchema-06ff28bc-fe50-4799-bc51-078d66a02e9d", + "name" : "targetXMLSchema", + "description" : "Target document targetXMLSchema type: XSD", + "uri" : "atlas:xml:targetXMLSchema-06ff28bc-fe50-4799-bc51-078d66a02e9d", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLInstance-04ef6f94-3504-4a9b-a18b-1d4a0cc2129c", + "name" : "targetXMLInstance", + "description" : "Target document targetXMLInstance type: XML", + "uri" : "atlas:xml:targetXMLInstance-04ef6f94-3504-4a9b-a18b-1d4a0cc2129c", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "targetCsv-3a58ee73-aa88-47b9-aa1b-0a98e7ad0577", + "name" : "targetCsv", + "description" : "Target document targetCsv type: CSV", + "uri" : "atlas:csv:targetCsv-3a58ee73-aa88-47b9-aa1b-0a98e7ad0577", + "dataSourceType" : "TARGET" + } ], + "mappings" : { + "mapping" : [ { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputFieldGroup" : { + "jsonType" : "io.atlasmap.v2.FieldGroup", + "actions" : [ { + "template" : "%s %s %d", + "@type" : "Format" + } ], + "field" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.SourceMappingTestClass", + "index" : 0, + "path" : "/sourceString", + "fieldType" : "STRING", + "name" : "sourceString" + }, { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.SourceMappingTestClass", + "index" : 1, + "path" : "/sourceAnotherString", + "fieldType" : "STRING", + "name" : "sourceAnotherString" + }, { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.SourceMappingTestClass", + "index" : 2, + "path" : "/sourceInteger", + "fieldType" : "INTEGER", + "name" : "sourceInteger" + } ] + }, + "inputField" : [ ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetCombineString", + "fieldType" : "STRING", + "name" : "targetCombineString" + } ], + "id" : "mapping.962201" + } ] + }, + "lookupTables" : { + "lookupTable" : [ ] + }, + "constants" : { + "constant" : [ ] + }, + "properties" : { + "property" : [ ] + }, + "name" : "UI.0" + } +} \ No newline at end of file diff --git a/mapping-validator/src/test/resources/javaToJavaMapping.xml b/mapping-validator/src/test/resources/javaToJavaMapping.xml deleted file mode 100644 index 0f78c76..0000000 --- a/mapping-validator/src/test/resources/javaToJavaMapping.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/mapping-validator/src/test/resources/jsonToJava.json b/mapping-validator/src/test/resources/jsonToJava.json new file mode 100644 index 0000000..5fb9e85 --- /dev/null +++ b/mapping-validator/src/test/resources/jsonToJava.json @@ -0,0 +1,250 @@ +{ + "AtlasMapping" : { + "jsonType" : "io.atlasmap.v2.AtlasMapping", + "dataSource" : [ { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceMappingTestClass", + "name" : "io.atlasmap.qe.test.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.DatesObject", + "name" : "io.atlasmap.qe.test.DatesObject", + "description" : "Java document class io.atlasmap.qe.test.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceListsClass", + "name" : "io.atlasmap.qe.test.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SmallMappingTestClass", + "name" : "io.atlasmap.qe.test.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceArrays-9e66addc-dc13-4387-ad8d-a2c0a6fd4ea2", + "name" : "sourceArrays", + "description" : "Source document sourceArrays type: JSON", + "uri" : "atlas:json:sourceArrays-9e66addc-dc13-4387-ad8d-a2c0a6fd4ea2", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJsonArray-35a3d9b4-3228-4317-b2a1-d86a159bd751", + "name" : "sourceJsonArray", + "description" : "Source document sourceJsonArray type: JSON", + "uri" : "atlas:json:sourceJsonArray-35a3d9b4-3228-4317-b2a1-d86a159bd751", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "name" : "sourceJson.schema", + "description" : "Source document sourceJson.schema type: JSON", + "uri" : "atlas:json:sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXmlInstance-ec9655cf-18d8-4d2d-bd58-35bcf0ce7243", + "name" : "sourceXmlInstance", + "description" : "Source document sourceXmlInstance type: XML", + "uri" : "atlas:xml:sourceXmlInstance-ec9655cf-18d8-4d2d-bd58-35bcf0ce7243", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "name" : "sourceXMLSchema", + "description" : "Source document sourceXMLSchema type: XSD", + "uri" : "atlas:xml:sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "sourceCsv-70dd7487-b84c-4d84-85b7-c47409a320fb", + "name" : "sourceCsv", + "description" : "Source document sourceCsv type: CSV", + "uri" : "atlas:csv:sourceCsv-70dd7487-b84c-4d84-85b7-c47409a320fb", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetMappingTestClass", + "name" : "io.atlasmap.qe.test.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.StringObject", + "name" : "io.atlasmap.qe.test.StringObject", + "description" : "Java document class io.atlasmap.qe.test.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetListsClass", + "name" : "io.atlasmap.qe.test.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetArrays-0c5bf947-4105-401b-995a-eae39a645dc8", + "name" : "targetArrays", + "description" : "Target document targetArrays type: JSON", + "uri" : "atlas:json:targetArrays-0c5bf947-4105-401b-995a-eae39a645dc8", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJsonArray-36aa895e-eb62-4888-afea-7e2a9dd4e81b", + "name" : "targetJsonArray", + "description" : "Target document targetJsonArray type: JSON", + "uri" : "atlas:json:targetJsonArray-36aa895e-eb62-4888-afea-7e2a9dd4e81b", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "name" : "targetJson.schema", + "description" : "Target document targetJson.schema type: JSON", + "uri" : "atlas:json:targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "name" : "targetXMLSchema", + "description" : "Target document targetXMLSchema type: XSD", + "uri" : "atlas:xml:targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLInstance-6086e724-b5d0-4601-8b65-cb300c5b9311", + "name" : "targetXMLInstance", + "description" : "Target document targetXMLInstance type: XML", + "uri" : "atlas:xml:targetXMLInstance-6086e724-b5d0-4601-8b65-cb300c5b9311", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "targetCsv-44ef760e-dcd4-4085-9f49-f8c352ea5375", + "name" : "targetCsv", + "description" : "Target document targetCsv type: CSV", + "uri" : "atlas:csv:targetCsv-44ef760e-dcd4-4085-9f49-f8c352ea5375", + "dataSourceType" : "TARGET" + } ], + "mappings" : { + "mapping" : [ { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "path" : "/sourceJsonInteger", + "fieldType" : "BIG_INTEGER", + "name" : "sourceJsonInteger", + "userCreated" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetInteger", + "fieldType" : "INTEGER", + "name" : "targetInteger" + } ], + "id" : "mapping.81508" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "path" : "/sourceJsonString", + "fieldType" : "STRING", + "name" : "sourceJsonString", + "userCreated" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetString", + "fieldType" : "STRING", + "name" : "targetString" + } ], + "id" : "mapping.957417" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "path" : "/sourceJsonShort", + "fieldType" : "BIG_INTEGER", + "name" : "sourceJsonShort", + "userCreated" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetDouble", + "fieldType" : "DOUBLE", + "name" : "targetDouble" + } ], + "id" : "mapping.301741" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "path" : "/sourceJsonDouble", + "fieldType" : "NUMBER", + "name" : "sourceJsonDouble", + "userCreated" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetFloat", + "fieldType" : "FLOAT", + "name" : "targetFloat" + } ], + "id" : "mapping.482009" + } ] + }, + "lookupTables" : { + "lookupTable" : [ ] + }, + "constants" : { + "constant" : [ ] + }, + "properties" : { + "property" : [ ] + }, + "name" : "UI.0" + } +} \ No newline at end of file diff --git a/mapping-validator/src/test/resources/jsonToJava.xml b/mapping-validator/src/test/resources/jsonToJava.xml deleted file mode 100644 index 957d639..0000000 --- a/mapping-validator/src/test/resources/jsonToJava.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapping-validator/src/test/resources/jsonToXml.json b/mapping-validator/src/test/resources/jsonToXml.json new file mode 100644 index 0000000..2e468a7 --- /dev/null +++ b/mapping-validator/src/test/resources/jsonToXml.json @@ -0,0 +1,254 @@ +{ + "AtlasMapping" : { + "jsonType" : "io.atlasmap.v2.AtlasMapping", + "dataSource" : [ { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceMappingTestClass", + "name" : "io.atlasmap.qe.test.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.DatesObject", + "name" : "io.atlasmap.qe.test.DatesObject", + "description" : "Java document class io.atlasmap.qe.test.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceListsClass", + "name" : "io.atlasmap.qe.test.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SmallMappingTestClass", + "name" : "io.atlasmap.qe.test.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceArrays-9e66addc-dc13-4387-ad8d-a2c0a6fd4ea2", + "name" : "sourceArrays", + "description" : "Source document sourceArrays type: JSON", + "uri" : "atlas:json:sourceArrays-9e66addc-dc13-4387-ad8d-a2c0a6fd4ea2", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJsonArray-35a3d9b4-3228-4317-b2a1-d86a159bd751", + "name" : "sourceJsonArray", + "description" : "Source document sourceJsonArray type: JSON", + "uri" : "atlas:json:sourceJsonArray-35a3d9b4-3228-4317-b2a1-d86a159bd751", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "name" : "sourceJson.schema", + "description" : "Source document sourceJson.schema type: JSON", + "uri" : "atlas:json:sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXmlInstance-ec9655cf-18d8-4d2d-bd58-35bcf0ce7243", + "name" : "sourceXmlInstance", + "description" : "Source document sourceXmlInstance type: XML", + "uri" : "atlas:xml:sourceXmlInstance-ec9655cf-18d8-4d2d-bd58-35bcf0ce7243", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "name" : "sourceXMLSchema", + "description" : "Source document sourceXMLSchema type: XSD", + "uri" : "atlas:xml:sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "sourceCsv-70dd7487-b84c-4d84-85b7-c47409a320fb", + "name" : "sourceCsv", + "description" : "Source document sourceCsv type: CSV", + "uri" : "atlas:csv:sourceCsv-70dd7487-b84c-4d84-85b7-c47409a320fb", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetMappingTestClass", + "name" : "io.atlasmap.qe.test.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.StringObject", + "name" : "io.atlasmap.qe.test.StringObject", + "description" : "Java document class io.atlasmap.qe.test.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetListsClass", + "name" : "io.atlasmap.qe.test.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetArrays-0c5bf947-4105-401b-995a-eae39a645dc8", + "name" : "targetArrays", + "description" : "Target document targetArrays type: JSON", + "uri" : "atlas:json:targetArrays-0c5bf947-4105-401b-995a-eae39a645dc8", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJsonArray-36aa895e-eb62-4888-afea-7e2a9dd4e81b", + "name" : "targetJsonArray", + "description" : "Target document targetJsonArray type: JSON", + "uri" : "atlas:json:targetJsonArray-36aa895e-eb62-4888-afea-7e2a9dd4e81b", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "name" : "targetJson.schema", + "description" : "Target document targetJson.schema type: JSON", + "uri" : "atlas:json:targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "name" : "targetXMLSchema", + "description" : "Target document targetXMLSchema type: XSD", + "uri" : "atlas:xml:targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLInstance-6086e724-b5d0-4601-8b65-cb300c5b9311", + "name" : "targetXMLInstance", + "description" : "Target document targetXMLInstance type: XML", + "uri" : "atlas:xml:targetXMLInstance-6086e724-b5d0-4601-8b65-cb300c5b9311", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "targetCsv-44ef760e-dcd4-4085-9f49-f8c352ea5375", + "name" : "targetCsv", + "description" : "Target document targetCsv type: CSV", + "uri" : "atlas:csv:targetCsv-44ef760e-dcd4-4085-9f49-f8c352ea5375", + "dataSourceType" : "TARGET" + } ], + "mappings" : { + "mapping" : [ { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "path" : "/sourceJsonInteger", + "fieldType" : "BIG_INTEGER", + "name" : "sourceJsonInteger", + "userCreated" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "path" : "/TargetXmlMappingTestClass/targetXmlInteger", + "fieldType" : "LONG", + "name" : "targetXmlInteger", + "attribute" : false + } ], + "id" : "mapping.951917" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "path" : "/sourceJsonString", + "fieldType" : "STRING", + "name" : "sourceJsonString", + "userCreated" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "path" : "/TargetXmlMappingTestClass/targetXmlString", + "fieldType" : "STRING", + "name" : "targetXmlString", + "attribute" : false + } ], + "id" : "mapping.138108" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "path" : "/sourceJsonShort", + "fieldType" : "BIG_INTEGER", + "name" : "sourceJsonShort", + "userCreated" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "path" : "/TargetXmlMappingTestClass/targetXmlDouble", + "fieldType" : "DOUBLE", + "name" : "targetXmlDouble", + "attribute" : false + } ], + "id" : "mapping.353126" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "path" : "/sourceJsonDouble", + "fieldType" : "NUMBER", + "name" : "sourceJsonDouble", + "userCreated" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "path" : "/TargetXmlMappingTestClass/targetXmlFloat", + "fieldType" : "FLOAT", + "name" : "targetXmlFloat", + "attribute" : false + } ], + "id" : "mapping.932464" + } ] + }, + "lookupTables" : { + "lookupTable" : [ ] + }, + "constants" : { + "constant" : [ ] + }, + "properties" : { + "property" : [ ] + }, + "name" : "UI.0" + } +} \ No newline at end of file diff --git a/mapping-validator/src/test/resources/xmlSchemaToJava.json b/mapping-validator/src/test/resources/xmlSchemaToJava.json new file mode 100644 index 0000000..1c51e88 --- /dev/null +++ b/mapping-validator/src/test/resources/xmlSchemaToJava.json @@ -0,0 +1,250 @@ +{ + "AtlasMapping" : { + "jsonType" : "io.atlasmap.v2.AtlasMapping", + "dataSource" : [ { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceMappingTestClass", + "name" : "io.atlasmap.qe.test.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.DatesObject", + "name" : "io.atlasmap.qe.test.DatesObject", + "description" : "Java document class io.atlasmap.qe.test.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceListsClass", + "name" : "io.atlasmap.qe.test.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SmallMappingTestClass", + "name" : "io.atlasmap.qe.test.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceArrays-9e66addc-dc13-4387-ad8d-a2c0a6fd4ea2", + "name" : "sourceArrays", + "description" : "Source document sourceArrays type: JSON", + "uri" : "atlas:json:sourceArrays-9e66addc-dc13-4387-ad8d-a2c0a6fd4ea2", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJsonArray-35a3d9b4-3228-4317-b2a1-d86a159bd751", + "name" : "sourceJsonArray", + "description" : "Source document sourceJsonArray type: JSON", + "uri" : "atlas:json:sourceJsonArray-35a3d9b4-3228-4317-b2a1-d86a159bd751", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "name" : "sourceJson.schema", + "description" : "Source document sourceJson.schema type: JSON", + "uri" : "atlas:json:sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXmlInstance-ec9655cf-18d8-4d2d-bd58-35bcf0ce7243", + "name" : "sourceXmlInstance", + "description" : "Source document sourceXmlInstance type: XML", + "uri" : "atlas:xml:sourceXmlInstance-ec9655cf-18d8-4d2d-bd58-35bcf0ce7243", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "name" : "sourceXMLSchema", + "description" : "Source document sourceXMLSchema type: XSD", + "uri" : "atlas:xml:sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "sourceCsv-70dd7487-b84c-4d84-85b7-c47409a320fb", + "name" : "sourceCsv", + "description" : "Source document sourceCsv type: CSV", + "uri" : "atlas:csv:sourceCsv-70dd7487-b84c-4d84-85b7-c47409a320fb", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetMappingTestClass", + "name" : "io.atlasmap.qe.test.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.StringObject", + "name" : "io.atlasmap.qe.test.StringObject", + "description" : "Java document class io.atlasmap.qe.test.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetListsClass", + "name" : "io.atlasmap.qe.test.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetArrays-0c5bf947-4105-401b-995a-eae39a645dc8", + "name" : "targetArrays", + "description" : "Target document targetArrays type: JSON", + "uri" : "atlas:json:targetArrays-0c5bf947-4105-401b-995a-eae39a645dc8", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJsonArray-36aa895e-eb62-4888-afea-7e2a9dd4e81b", + "name" : "targetJsonArray", + "description" : "Target document targetJsonArray type: JSON", + "uri" : "atlas:json:targetJsonArray-36aa895e-eb62-4888-afea-7e2a9dd4e81b", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "name" : "targetJson.schema", + "description" : "Target document targetJson.schema type: JSON", + "uri" : "atlas:json:targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "name" : "targetXMLSchema", + "description" : "Target document targetXMLSchema type: XSD", + "uri" : "atlas:xml:targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLInstance-6086e724-b5d0-4601-8b65-cb300c5b9311", + "name" : "targetXMLInstance", + "description" : "Target document targetXMLInstance type: XML", + "uri" : "atlas:xml:targetXMLInstance-6086e724-b5d0-4601-8b65-cb300c5b9311", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "targetCsv-44ef760e-dcd4-4085-9f49-f8c352ea5375", + "name" : "targetCsv", + "description" : "Target document targetCsv type: CSV", + "uri" : "atlas:csv:targetCsv-44ef760e-dcd4-4085-9f49-f8c352ea5375", + "dataSourceType" : "TARGET" + } ], + "mappings" : { + "mapping" : [ { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "path" : "/SourceXmlMappingSchema/sourceXMLInteger", + "fieldType" : "LONG", + "name" : "sourceXMLInteger", + "attribute" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetInteger", + "fieldType" : "INTEGER", + "name" : "targetInteger" + } ], + "id" : "mapping.836663" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "path" : "/SourceXmlMappingSchema/sourceXMLString", + "fieldType" : "STRING", + "name" : "sourceXMLString", + "attribute" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetString", + "fieldType" : "STRING", + "name" : "targetString" + } ], + "id" : "mapping.91909" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "path" : "/SourceXmlMappingSchema/sourceXMLShort", + "fieldType" : "INTEGER", + "name" : "sourceXMLShort", + "attribute" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetDouble", + "fieldType" : "DOUBLE", + "name" : "targetDouble" + } ], + "id" : "mapping.439037" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "path" : "/SourceXmlMappingSchema/sourceXMLDouble", + "fieldType" : "DOUBLE", + "name" : "sourceXMLDouble", + "attribute" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/targetFloat", + "fieldType" : "FLOAT", + "name" : "targetFloat" + } ], + "id" : "mapping.272495" + } ] + }, + "lookupTables" : { + "lookupTable" : [ ] + }, + "constants" : { + "constant" : [ ] + }, + "properties" : { + "property" : [ ] + }, + "name" : "UI.0" + } +} \ No newline at end of file diff --git a/mapping-validator/src/test/resources/xmlSchemaToJava.xml b/mapping-validator/src/test/resources/xmlSchemaToJava.xml deleted file mode 100644 index 9942128..0000000 --- a/mapping-validator/src/test/resources/xmlSchemaToJava.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapping-validator/src/test/resources/xmlSchemaToJson.xml b/mapping-validator/src/test/resources/xmlSchemaToJson.xml deleted file mode 100644 index 9ab5819..0000000 --- a/mapping-validator/src/test/resources/xmlSchemaToJson.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mapping-validator/src/test/resources/xmlToJson.json b/mapping-validator/src/test/resources/xmlToJson.json new file mode 100644 index 0000000..b6707ba --- /dev/null +++ b/mapping-validator/src/test/resources/xmlToJson.json @@ -0,0 +1,254 @@ +{ + "AtlasMapping" : { + "jsonType" : "io.atlasmap.v2.AtlasMapping", + "dataSource" : [ { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceMappingTestClass", + "name" : "io.atlasmap.qe.test.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.DatesObject", + "name" : "io.atlasmap.qe.test.DatesObject", + "description" : "Java document class io.atlasmap.qe.test.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceListsClass", + "name" : "io.atlasmap.qe.test.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SmallMappingTestClass", + "name" : "io.atlasmap.qe.test.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceArrays-9e66addc-dc13-4387-ad8d-a2c0a6fd4ea2", + "name" : "sourceArrays", + "description" : "Source document sourceArrays type: JSON", + "uri" : "atlas:json:sourceArrays-9e66addc-dc13-4387-ad8d-a2c0a6fd4ea2", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJsonArray-35a3d9b4-3228-4317-b2a1-d86a159bd751", + "name" : "sourceJsonArray", + "description" : "Source document sourceJsonArray type: JSON", + "uri" : "atlas:json:sourceJsonArray-35a3d9b4-3228-4317-b2a1-d86a159bd751", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "name" : "sourceJson.schema", + "description" : "Source document sourceJson.schema type: JSON", + "uri" : "atlas:json:sourceJson.schema-2a623dc6-40b4-40ea-88d3-d440663c8788", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXmlInstance-ec9655cf-18d8-4d2d-bd58-35bcf0ce7243", + "name" : "sourceXmlInstance", + "description" : "Source document sourceXmlInstance type: XML", + "uri" : "atlas:xml:sourceXmlInstance-ec9655cf-18d8-4d2d-bd58-35bcf0ce7243", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "name" : "sourceXMLSchema", + "description" : "Source document sourceXMLSchema type: XSD", + "uri" : "atlas:xml:sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "sourceCsv-70dd7487-b84c-4d84-85b7-c47409a320fb", + "name" : "sourceCsv", + "description" : "Source document sourceCsv type: CSV", + "uri" : "atlas:csv:sourceCsv-70dd7487-b84c-4d84-85b7-c47409a320fb", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetMappingTestClass", + "name" : "io.atlasmap.qe.test.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.StringObject", + "name" : "io.atlasmap.qe.test.StringObject", + "description" : "Java document class io.atlasmap.qe.test.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetListsClass", + "name" : "io.atlasmap.qe.test.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetArrays-0c5bf947-4105-401b-995a-eae39a645dc8", + "name" : "targetArrays", + "description" : "Target document targetArrays type: JSON", + "uri" : "atlas:json:targetArrays-0c5bf947-4105-401b-995a-eae39a645dc8", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJsonArray-36aa895e-eb62-4888-afea-7e2a9dd4e81b", + "name" : "targetJsonArray", + "description" : "Target document targetJsonArray type: JSON", + "uri" : "atlas:json:targetJsonArray-36aa895e-eb62-4888-afea-7e2a9dd4e81b", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "name" : "targetJson.schema", + "description" : "Target document targetJson.schema type: JSON", + "uri" : "atlas:json:targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "name" : "targetXMLSchema", + "description" : "Target document targetXMLSchema type: XSD", + "uri" : "atlas:xml:targetXMLSchema-e66e724f-4bc4-4cb8-a409-c54c28e5a366", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLInstance-6086e724-b5d0-4601-8b65-cb300c5b9311", + "name" : "targetXMLInstance", + "description" : "Target document targetXMLInstance type: XML", + "uri" : "atlas:xml:targetXMLInstance-6086e724-b5d0-4601-8b65-cb300c5b9311", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "targetCsv-44ef760e-dcd4-4085-9f49-f8c352ea5375", + "name" : "targetCsv", + "description" : "Target document targetCsv type: CSV", + "uri" : "atlas:csv:targetCsv-44ef760e-dcd4-4085-9f49-f8c352ea5375", + "dataSourceType" : "TARGET" + } ], + "mappings" : { + "mapping" : [ { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "path" : "/SourceXmlMappingSchema/sourceXMLInteger", + "fieldType" : "LONG", + "name" : "sourceXMLInteger", + "attribute" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "path" : "/targetJsonInteger", + "fieldType" : "BIG_INTEGER", + "name" : "targetJsonInteger", + "userCreated" : false + } ], + "id" : "mapping.458578" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "path" : "/SourceXmlMappingSchema/sourceXMLString", + "fieldType" : "STRING", + "name" : "sourceXMLString", + "attribute" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "path" : "/targetJsonString", + "fieldType" : "STRING", + "name" : "targetJsonString", + "userCreated" : false + } ], + "id" : "mapping.38022" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "path" : "/SourceXmlMappingSchema/sourceXMLShort", + "fieldType" : "INTEGER", + "name" : "sourceXMLShort", + "attribute" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "path" : "/targetJsonFloat", + "fieldType" : "NUMBER", + "name" : "targetJsonFloat", + "userCreated" : false + } ], + "id" : "mapping.498490" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.xml.v2.XmlField", + "docId" : "sourceXMLSchema-a72ee56e-0e1e-4f9f-b183-6d6201455d09", + "path" : "/SourceXmlMappingSchema/sourceXMLDouble", + "fieldType" : "DOUBLE", + "name" : "sourceXMLDouble", + "attribute" : false + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.json.v2.JsonField", + "docId" : "targetJson.schema-e8c2f76f-8469-4ff2-b8cb-3ae4b5af7148", + "path" : "/targetJsonDouble", + "fieldType" : "NUMBER", + "name" : "targetJsonDouble", + "userCreated" : false + } ], + "id" : "mapping.690591" + } ] + }, + "lookupTables" : { + "lookupTable" : [ ] + }, + "constants" : { + "constant" : [ ] + }, + "properties" : { + "property" : [ ] + }, + "name" : "UI.0" + } +} \ No newline at end of file From 17221f767baf263220e943f5b7c831dc8b21d03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Sat, 10 Apr 2021 11:51:25 +0200 Subject: [PATCH 15/22] Extract mapping logic from MappingValidator --- .../java/io/atlasmap/qe/test/AtlasMapper.java | 109 ++++++++++++++++++ .../qe/test/MappingDocIdExporter.java | 44 ------- .../io/atlasmap/qe/test/MappingValidator.java | 74 +----------- 3 files changed, 111 insertions(+), 116 deletions(-) create mode 100644 mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java delete mode 100644 mapping-validator/src/main/java/io/atlasmap/qe/test/MappingDocIdExporter.java diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java new file mode 100644 index 0000000..af3eba2 --- /dev/null +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java @@ -0,0 +1,109 @@ +package io.atlasmap.qe.test; + +import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.atlasmap.AtlasComponent; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.impl.DefaultCamelContext; +import org.apache.commons.io.IOUtils; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static org.assertj.core.api.Assertions.fail; + +public class AtlasMapper { + + public Map processMapping(Map inputMap, String mappingFilePath) { + CamelContext context = new DefaultCamelContext(); + context.addComponent("atlas", new AtlasComponent()); + try { + context.addRoutes(new RouteBuilder() { + public void configure() { + from("direct:start"). + setHeader("string", constant("test_string")). + setHeader("char", constant("A")). + setHeader("decimal", constant(10)). + setHeader("double", constant(1234.56)). + setHeader("float", constant(4567.86)). + setHeader("integer", constant(1234)). + setHeader("long", constant(1234567890)). + setHeader("short", constant(1234)). + setHeader("boolean", constant(true)). + setProperty("myProperty", constant("test property")). + to("atlas:" + mappingFilePath). + to("mock:result"); + } + } + ); + + adjustIDsForFormFiles(inputMap, mappingFilePath); + + MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); + ProducerTemplate template = context.createProducerTemplate(); + context.start(); + + template.sendBody("direct:start", inputMap); + Map targetMap = resultEndpoint.getExchanges().get(0).getIn().getBody(Map.class); + context.stop(); + targetMap.forEach((String s, Object o) -> + System.out.println(s + " " + (o == null ? "null" : o.toString()))); + return targetMap; + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + return null; + } + } + + /** + * Provides a way, to update the source map of input files, to correspond the ID's in the mapping file. + * The ID in mapping file is in format: "name-uuid" + */ + private void adjustIDsForFormFiles(Map inputMap, String mappingFilePath) { + Set keySet = new HashSet<>(); + keySet.addAll(inputMap.keySet()); + for (String key : keySet) { + String newKey = extractDataSourceIdByName(mappingFilePath, key); + if (!newKey.contentEquals(key)) { + Object value = inputMap.get(key); + inputMap.remove(key); + inputMap.put(newKey, value); + } + } + } + + private String extractDataSourceIdByName(String mappingFilePath, String dataSourceName) { + String dataSourceId = dataSourceName; + JSONObject atlasMappingJson = exportAtlasJson(mappingFilePath); + JSONArray dataSourceList = atlasMappingJson.getJSONObject("AtlasMapping").getJSONArray("dataSource"); + + for(int i = 0; i < dataSourceList.length(); i++) { + if(dataSourceList.getJSONObject(i).getString("name").contentEquals(dataSourceName)) { + dataSourceId = dataSourceList.getJSONObject(i).getString("id"); + break; + } + } + return dataSourceId; + } + + private JSONObject exportAtlasJson(String mappingFilePath) { + String jsonTxt = ""; + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream atlasFileStream = classloader.getResourceAsStream(mappingFilePath); + try { + jsonTxt = IOUtils.toString( atlasFileStream ); + } catch (IOException e) { + e.printStackTrace(); + } + JSONObject atlasJson = new JSONObject(jsonTxt); + + return atlasJson; + } +} diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingDocIdExporter.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingDocIdExporter.java deleted file mode 100644 index 56ec2e7..0000000 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingDocIdExporter.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.atlasmap.qe.test; - -import org.apache.commons.io.IOUtils; -import org.json.JSONArray; -import org.json.JSONObject; - -import java.io.IOException; -import java.io.InputStream; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class MappingDocIdExporter { - - public static String extractDataSourceIdByName(String atlasMappingLocation, String dataSourceName) { - String dataSourceId = dataSourceName; - JSONObject atlasMappingJson = exportAtlasJson(atlasMappingLocation); - JSONArray dataSourceList = atlasMappingJson.getJSONObject("AtlasMapping").getJSONArray("dataSource"); - - for(int i = 0; i < dataSourceList.length(); i++) { - if(dataSourceList.getJSONObject(i).getString("name").contentEquals(dataSourceName)) { - dataSourceId = dataSourceList.getJSONObject(i).getString("id"); - break; - } - } - return dataSourceId; - } - - private static JSONObject exportAtlasJson(String mappingLocation) { - String jsonTxt = ""; - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream atlasFileStream = classloader.getResourceAsStream(mappingLocation); - try { - jsonTxt = IOUtils.toString( atlasFileStream ); - } catch (IOException e) { - e.printStackTrace(); - } - JSONObject atlasJson = new JSONObject(jsonTxt); - - return atlasJson; - } - - -} diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java index 6f3b444..8f28551 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java @@ -1,22 +1,12 @@ package io.atlasmap.qe.test; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.atlasmap.AtlasComponent; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.impl.DefaultCamelContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.text.ParseException; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.stream.Stream; import io.atlasmap.qe.resources.ResourcesGenerator; @@ -34,6 +24,7 @@ public class MappingValidator { private TargetMappingTestClass target; private Map expectedMap; private Map sourceMap; + private final AtlasMapper atlasMapper = new AtlasMapper(); public MappingValidator() { initializeValues(); @@ -77,48 +68,7 @@ public Object processMapping(String expected) { } public Map processMappingInputMap(Map input) { - // input.forEach((String s,Object o) -> - // System.out.println(s+ "---> "+o.toString())); - CamelContext context = new DefaultCamelContext(); - context.addComponent("atlas", new AtlasComponent()); - try { - context.addRoutes(new RouteBuilder() { - public void configure() { - from("direct:start"). - setHeader("string", constant("test_string")). - setHeader("char", constant("A")). - setHeader("decimal", constant(10)). - setHeader("double", constant(1234.56)). - setHeader("float", constant(4567.86)). - setHeader("integer", constant(1234)). - setHeader("long", constant(1234567890)). - setHeader("short", constant(1234)). - setHeader("boolean", constant(true)). - setProperty("myProperty", constant("test property")). - to("atlas:" + mappingLocation). - to("mock:result"); - } - } - ); - - adjustIDsForFormFiles(mappingLocation, input); - - MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); - ProducerTemplate template = context.createProducerTemplate(); - context.start(); - - template.sendBody("direct:start", input); - // template.sendBodyAndHeaders("direct:start", input, headers); - Map targetMap = resultEndpoint.getExchanges().get(0).getIn().getBody(Map.class); - context.stop(); - targetMap.forEach((String s, Object o) -> - System.out.println(s + " " + (o == null ? "null" : o.toString()))); - return targetMap; - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - return null; + return atlasMapper.processMapping(input, mappingLocation); } public boolean verifyMapping(SourceMappingTestClass source, TargetMappingTestClass target, boolean equals) { @@ -274,26 +224,6 @@ public void initValidator() { ); } - /** - * Provides a way, to update the source map of input files, to correspond the ID's in the mapping file. - * The ID in mapping file is in format: "name-uuid" - * - * @param mappingLocation - * @param input - */ - public void adjustIDsForFormFiles(String mappingLocation, Map input) { - Set keySet = new HashSet<>(); - keySet.addAll(input.keySet()); - for (String key : keySet) { - String newKey = MappingDocIdExporter.extractDataSourceIdByName(mappingLocation, key); - if (!newKey.contentEquals(key)) { - Object value = input.get(key); - input.remove(key); - input.put(newKey, value); - } - } - } - public static void main(String[] args) { MappingValidator mv = new MappingValidator(); if (args.length > 1) { From 2278be3d7cb24e17496738a99ae7a6315c631eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Tue, 13 Apr 2021 22:02:06 +0200 Subject: [PATCH 16/22] Refactor test-resources - refactor test-resources classes - make them POJO - use Lombok - improve setting of values in SourceMappingTestClass and TargetMappingTestClass - use BeanWrapper - add converters for unknown conversions between objects - rename AtlasmapPage, AtlasmapInit - remove CucumberGlue - use dependency injection instead --- datamapper-e2e/pom.xml | 7 +- .../atlasmap/qe/test/atlas/AtlasmapInit.java | 22 +- .../atlasmap/qe/test/atlas/AtlasmapPage.java | 16 +- .../qe/test/atlas/CucumberSpringConfig.java | 13 + .../atlasmap/qe/test/atlas/CucumberTest.java | 4 +- .../qe/test/atlas/steps/BackendSteps.java | 39 +- .../qe/test/atlas/steps/ComplexSteps.java | 23 +- .../qe/test/atlas/steps/CucumberGlue.java | 7 - .../test/atlas/steps/TransformationSteps.java | 23 +- .../atlasmap/qe/test/atlas/steps/UISteps.java | 23 +- .../qe/test/atlas/utils/CucumberSpring.java | 12 - .../utils/{Utils.java => MappingUtils.java} | 5 +- .../FieldActions/DateFieldActions.feature | 2 + mapping-validator/pom.xml | 28 +- .../java/io/atlasmap/qe/test/AtlasMapper.java | 11 +- .../io/atlasmap/qe/test/MappingValidator.java | 47 +- .../qe/test/ValidatorSpringConfig.java | 40 ++ .../CharacterToBooleanConverter.java | 14 + .../converter/NumberToBooleanConverter.java | 14 + .../test/converter/NumberToDateConverter.java | 16 + .../test/converter/StringToDateConverter.java | 22 + .../qe/test/MappingValidatorTest.java | 126 +++++- .../resources/fromDateObjectToDateObject.json | 368 +++++++++++++++ pom.xml | 2 - .../java/io/atlasmap/qe/test/BaseClass.java | 134 ------ .../java/io/atlasmap/qe/test/DatesObject.java | 142 +----- .../qe/test/MappingTestClassConverter.java | 9 - .../qe/test/NestedCollectionClass.java | 23 + .../java/io/atlasmap/qe/test/SimpleEnum.java | 1 + .../qe/test/SmallMappingTestClass.java | 97 +--- .../io/atlasmap/qe/test/SourceListsClass.java | 84 +--- .../qe/test/SourceMappingTestClass.java | 333 ++------------ .../qe/test/SourceNestedCollectionClass.java | 46 +- .../io/atlasmap/qe/test/StringObject.java | 49 +- .../io/atlasmap/qe/test/TargetListsClass.java | 2 +- .../qe/test/TargetMappingTestClass.java | 420 ++---------------- .../qe/test/TargetNestedCollectionClass.java | 45 +- 37 files changed, 899 insertions(+), 1370 deletions(-) create mode 100644 datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberSpringConfig.java delete mode 100644 datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/CucumberGlue.java delete mode 100644 datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/CucumberSpring.java rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/{Utils.java => MappingUtils.java} (98%) create mode 100644 mapping-validator/src/main/java/io/atlasmap/qe/test/ValidatorSpringConfig.java create mode 100644 mapping-validator/src/main/java/io/atlasmap/qe/test/converter/CharacterToBooleanConverter.java create mode 100644 mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToBooleanConverter.java create mode 100644 mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToDateConverter.java create mode 100644 mapping-validator/src/main/java/io/atlasmap/qe/test/converter/StringToDateConverter.java create mode 100644 mapping-validator/src/test/resources/fromDateObjectToDateObject.json delete mode 100644 test-resources/src/main/java/io/atlasmap/qe/test/BaseClass.java delete mode 100644 test-resources/src/main/java/io/atlasmap/qe/test/MappingTestClassConverter.java create mode 100644 test-resources/src/main/java/io/atlasmap/qe/test/NestedCollectionClass.java diff --git a/datamapper-e2e/pom.xml b/datamapper-e2e/pom.xml index 55c6daa..075c76b 100644 --- a/datamapper-e2e/pom.xml +++ b/datamapper-e2e/pom.xml @@ -60,6 +60,12 @@ ${cucumber.version} test + + io.cucumber + cucumber-spring + ${cucumber.version} + test + io.cucumber cucumber-junit @@ -71,7 +77,6 @@ spring-test ${spring.version} - org.springframework spring-tx diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java index d154c48..6df7224 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java @@ -12,13 +12,14 @@ import java.util.function.Consumer; import io.atlasmap.qe.test.atlas.utils.TestConfiguration; -import io.atlasmap.qe.test.atlas.utils.Utils; +import io.atlasmap.qe.test.atlas.utils.MappingUtils; 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. @@ -34,7 +35,7 @@ public class AtlasmapInit implements EventListener { /** * {@link AtlasmapPage} needed for resources loading. */ - private final AtlasmapPage atlasMapPage = new AtlasmapPage(); + private final AtlasmapPage atlasmapPage = new AtlasmapPage(); /** * {@link EventHandler} that is started before all tests. @@ -59,6 +60,7 @@ public class AtlasmapInit implements EventListener { throw new IllegalStateException("Cannot find JAR file with test classes!"); } + // TODO: obtain classes names programmatically // Source classes: page.enableSourceClass("io.atlasmap.qe.test.SourceMappingTestClass"); page.enableSourceClass("io.atlasmap.qe.test.DatesObject"); @@ -96,15 +98,18 @@ public class AtlasmapInit implements EventListener { put("First Record As Header", "true"); }}); - //TODO: find more dynamic way for initialization check - Utils.sleep(1000); + // TODO: find more dynamic way for initialization check + MappingUtils.sleep(1000); try { - Utils.backupAdmFile(); + 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 setupFast = event -> runOnPage((page) -> { page.resetAll(); @@ -113,7 +118,7 @@ public class AtlasmapInit implements EventListener { // Imports ADM file. try { page.importAdmFile(admFile.getCanonicalPath()); - Utils.backupAdmFile(); + MappingUtils.backupAdmFile(); } catch (IOException e) { throw new IllegalStateException("Error when getting canonical path of ADM file.", e); } @@ -128,11 +133,10 @@ public class AtlasmapInit implements EventListener { /** * Opens browser and executes steps defined in {@code pageConsumer}. * - * @param pageConsumer that will be executed inside web browser on {@link AtlasmapInit#atlasMapPage}. + * @param pageConsumer that will be executed inside web browser on {@link AtlasmapInit#atlasmapPage}. */ private void runOnPage(Consumer pageConsumer) { - - pageConsumer.accept(atlasMapPage); + pageConsumer.accept(atlasmapPage); } /** diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java index a1991ae..1697c2f 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java @@ -32,8 +32,9 @@ import io.atlasmap.qe.test.atlas.utils.ByUtils; import io.atlasmap.qe.test.atlas.utils.HoverAction; import io.atlasmap.qe.test.atlas.utils.TestConfiguration; -import io.atlasmap.qe.test.atlas.utils.Utils; +import io.atlasmap.qe.test.atlas.utils.MappingUtils; import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; import org.openqa.selenium.WebDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.ButtonReleaseAction; @@ -43,6 +44,7 @@ import org.openqa.selenium.interactions.MoveMouseAction; @Slf4j +@Component public class AtlasmapPage { public static final String TEST_CLASS = "SourceMappingTestClass"; @@ -173,7 +175,7 @@ public void changeSelectValue(String from, String to) { } public void setInputValueByDataTestid(String inputSelector, String inputValue) { - Utils.insertCharByChar(inputValue, $(ByUtils.dataTestId(inputSelector))); + MappingUtils.insertCharByChar(inputValue, $(ByUtils.dataTestId(inputSelector))); } /** @@ -212,7 +214,7 @@ public void clickOnValueFromPicker(String value) { } public void addToConditionalMapping(String condition) { - Utils.insertCharByChar(condition, $(By.id("expressionMarkup"))); + MappingUtils.insertCharByChar(condition, $(By.id("expressionMarkup"))); } public void selectSeparator(String action) { @@ -314,7 +316,7 @@ public void enableCsvDocument(String path, boolean isSource, String format, Map< $$(By.id("selected-paramater")).last().waitUntil(visible, 5000).selectOption(key); String keyId = key.replaceAll("\\s+", ""); keyId = keyId.substring(0, 1).toLowerCase() + keyId.substring(1); - Utils.sleep(1000); + MappingUtils.sleep(1000); SelenideElement parameterOption = $(By.name(keyId)); if (parameterOption.is(Condition.type("text"))) { @@ -395,7 +397,7 @@ public void setInputValueForFieldPreview(String field, String value) { pickerValue.clear(); pickerValue.sendKeys(value); - Utils.sleep(1000); + MappingUtils.sleep(1000); } public String getFieldPreviewValue(String field) { @@ -406,7 +408,7 @@ public String getFieldPreviewValue(String field) { int timeout = 5000; do { - Utils.sleep(200); + MappingUtils.sleep(200); timeout -= 200; } while ("".equals(pickerValue.getValue()) && timeout > 0); return pickerValue.getValue(); @@ -596,7 +598,7 @@ private void addTransformationOnField(String transformation, boolean isSource) { mappingDetailField.$(ByUtils.dataTestIdStartsWith("add-transformation-to-")).sendKeys(Keys.ENTER); mappingDetailField.$(ByUtils.dataTestIdStartsWith("user-field-action-")).waitUntil(visible, 5000).selectOption(transformation); - Utils.sleep(2000); + MappingUtils.sleep(2000); } /** diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberSpringConfig.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberSpringConfig.java new file mode 100644 index 0000000..1ba89ef --- /dev/null +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberSpringConfig.java @@ -0,0 +1,13 @@ +package io.atlasmap.qe.test.atlas; + +import io.atlasmap.qe.test.ValidatorSpringConfig; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.ContextConfiguration; + +import io.cucumber.spring.CucumberContextConfiguration; + +@CucumberContextConfiguration +@ContextConfiguration(classes = CucumberSpringConfig.class) +@ComponentScan(basePackageClasses = {ValidatorSpringConfig.class, CucumberTest.class}) +public class CucumberSpringConfig { +} diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberTest.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberTest.java index f934fe7..3ae46d7 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberTest.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberTest.java @@ -15,10 +15,10 @@ public class CucumberTest { @BeforeClass public static void setupCucumber() { //set up Selenide - Configuration.timeout = TestConfiguration.getConfigTimeout() * 1000; + Configuration.timeout = TestConfiguration.getConfigTimeout() * 1000L; //We will now use custom web driver //Configuration.browser = TestConfiguration.syndesisBrowser(); - Configuration.browser = "io.atlasmap.qe.test.atlas.CustomWebDriverProvider"; + Configuration.browser = CustomWebDriverProvider.class.getName(); Configuration.browserSize = "1920x1080"; Selenide.open(TestConfiguration.getUiIndexPath()); //Logging selectors is disabled by default, enable it in test properties if you wish diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/BackendSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/BackendSteps.java index 67aea7e..1088f82 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/BackendSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/BackendSteps.java @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +import io.atlasmap.qe.test.*; import org.junit.Assert; import org.openqa.selenium.NotFoundException; @@ -13,15 +14,7 @@ import java.util.Map; import io.atlasmap.qe.resources.ResourcesGenerator; -import io.atlasmap.qe.test.DatesObject; -import io.atlasmap.qe.test.SmallMappingTestClass; -import io.atlasmap.qe.test.SourceListsClass; -import io.atlasmap.qe.test.SourceNestedCollectionClass; -import io.atlasmap.qe.test.StringObject; -import io.atlasmap.qe.test.TargetListsClass; -import io.atlasmap.qe.test.TargetMappingTestClass; -import io.atlasmap.qe.test.TargetNestedCollectionClass; -import io.atlasmap.qe.test.atlas.utils.Utils; +import io.atlasmap.qe.test.atlas.utils.MappingUtils; import io.cucumber.datatable.DataTable; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; @@ -29,14 +22,20 @@ import io.cucumber.java.en.When; import lombok.extern.slf4j.Slf4j; +import javax.inject.Inject; + + @Slf4j -public class BackendSteps extends CucumberGlue { +public class BackendSteps { + + @Inject + private MappingValidator validator; @Given("atlasmap is clean") public void atlasmapIsClean() { try { - Utils.deleteMappingsFromFolder(); - Utils.restoreAdmFile(); + MappingUtils.deleteMappingsFromFolder(); + MappingUtils.restoreAdmFile(); } catch (IOException e) { e.printStackTrace(); } @@ -44,10 +43,10 @@ public void atlasmapIsClean() { } @Then("save mapping as {string}") - public void userSavesMappingAs(String arg1) throws Exception { - Utils.sleep(1000); - String mappingLocation = Utils.moveMapping(arg1); - validator.setMappingLocation(arg1); + public void userSavesMappingAs(String newMappingFileName) throws Exception { + MappingUtils.sleep(1000); + String mappingLocation = MappingUtils.moveMapping(newMappingFileName); + validator.setMappingLocation(newMappingFileName); } @And("verify {string}") @@ -60,6 +59,7 @@ public void setsSourceData(DataTable sourceMappingData) throws Throwable { //SourceMappingTestClass source = new SourceMappingTestClass(); for (Map source : sourceMappingData.asMaps()) { for (String field : source.keySet()) { + // TODO: should be also able to set fields of different objects than SourceMappingTestClass this.validator.setSourceValue(field, replaceEmptyString(source.get(field))); } } @@ -83,7 +83,7 @@ public void setsExpectedData(DataTable targetMappingData) throws Throwable { public void verifyIfIsNotIn(String field, String value, String path) { // // Assert.assertTrue(validator.verifyMapping()); TargetMappingTestClass processed = this.validator.processMapping(); - assertThat(processed.getValue(field)).isNotEqualTo(value); + assertThat(validator.getValueOfBeanProperty(processed, field)).isNotEqualTo(value); } @Then("save and verify mapping as {string}") @@ -131,7 +131,7 @@ private String replaceEmptyString(String value) { @And("sleep for \"{int}\"") public void sleepFor(int arg0) { // Write code here that turns the phrase above into concrete actions - Utils.sleep(arg0); + MappingUtils.sleep(arg0); } @Then("save {string} verify negative with") @@ -204,7 +204,8 @@ public void saveAndVerifyMappingFromToDatetypesAs(String source, String mapping) assertThat(sourceDate.getSqlDate().toString()).isEqualTo(d.getSqlDate().toString()); assertThat(sourceDate.getGregorianCalendar()).isEqualTo(d.getGregorianCalendar()); - assertThat(validator.verifyMultiObjectMapping()).isTrue(); + // FIXME: following method is broken (verifyMultiObjectMapping) + // assertThat(validator.verifyMultiObjectMapping()).isTrue(); } @Then("save and verify datetypes mapping as {string} and skip sql formats") diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/ComplexSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/ComplexSteps.java index be544b4..82bb830 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/ComplexSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/ComplexSteps.java @@ -1,5 +1,7 @@ package io.atlasmap.qe.test.atlas.steps; +import io.atlasmap.qe.test.MappingValidator; +import lombok.extern.slf4j.Slf4j; import org.junit.Assert; import io.atlasmap.qe.test.TargetMappingTestClass; @@ -9,12 +11,23 @@ import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -public class ComplexSteps extends CucumberGlue { +import javax.inject.Inject; - private AtlasmapPage atlasmapPage = new AtlasmapPage(); - private static TransformationSteps transformationSteps = new TransformationSteps(); - private static BackendSteps backendSteps = new BackendSteps(); +@Slf4j +public class ComplexSteps { + + @Inject + private MappingValidator validator; + + @Inject + private AtlasmapPage atlasmapPage; + + @Inject + private TransformationSteps transformationSteps; + + @Inject + private BackendSteps backendSteps; @When("verify in {string} transformation that {string} is transformed to {string}") public void verifyInTransformationThatIsTransformedTo(String transformation, String input, String output) throws Throwable { @@ -42,7 +55,7 @@ public void verifyConversionFromInPreview(String field) throws Exception { for (String targetField : targetFields) { this.atlasmapPage.hoverAndSelectOperation(targetField, HoverAction.SHOW_MAPPING_DETAILS, "target"); - String targetMapped = target.getValue(targetField).toString(); + String targetMapped = validator.getValueOfBeanProperty(target, targetField).toString(); if (!targetField.contains("String")) { targetMapped = (targetMapped.endsWith(".0") ? targetMapped.replace(".0", "") : targetMapped); } diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/CucumberGlue.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/CucumberGlue.java deleted file mode 100644 index cab5f67..0000000 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/CucumberGlue.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.atlasmap.qe.test.atlas.steps; - -import io.atlasmap.qe.test.MappingValidator; - -public abstract class CucumberGlue { - protected static MappingValidator validator = new MappingValidator(); -} diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/TransformationSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/TransformationSteps.java index c4cd618..52b9d27 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/TransformationSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/TransformationSteps.java @@ -1,15 +1,22 @@ package io.atlasmap.qe.test.atlas.steps; +import lombok.extern.slf4j.Slf4j; import org.junit.Assert; import io.atlasmap.qe.test.atlas.AtlasmapPage; -import io.atlasmap.qe.test.atlas.utils.Utils; +import io.atlasmap.qe.test.atlas.utils.MappingUtils; import io.cucumber.java.en.And; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -public class TransformationSteps extends CucumberGlue { - private AtlasmapPage atlasmapPage = new AtlasmapPage(); +import javax.inject.Inject; + + +@Slf4j +public class TransformationSteps { + + @Inject + private AtlasmapPage atlasmapPage; @When("add {string} transformation on {string}") public void addTransformationOn(String transformation, String sourceTarget) { @@ -29,7 +36,7 @@ public void addCollectionTransformationOn(String transformation) { @And("select {string} transformation") public void selectTransformation(String arg0) { this.atlasmapPage.selectTransformation(arg0, "Append"); - Utils.sleep(1000); + MappingUtils.sleep(1000); } @When("select {string} number transformation") @@ -40,19 +47,19 @@ public void selectNumberTransformation(String arg0) { @When("select {string} separator") public void selectSeparator(String separator) { this.atlasmapPage.selectSeparator(separator); - Utils.sleep(1000); + MappingUtils.sleep(1000); } @When("set index to {int}") public void setCopyToIndex(int index) { this.atlasmapPage.setCopyToIndex(index); - Utils.sleep(1000); + MappingUtils.sleep(1000); } @When("set repeat count to {int}") public void setRepeatCount(int count) { this.atlasmapPage.setRepeatCount(count); - Utils.sleep(1000); + MappingUtils.sleep(1000); } /** @@ -125,7 +132,7 @@ public void verifyPreviewOfTransformationFromWithValueIsTransformedToIn(String t this.atlasmapPage.addTransformationToTargetOrSource(transformation, true); this.atlasmapPage.setInputValueForFieldPreview(sourceField, sourceValue); this.atlasmapPage.setInputValueForFieldPreview(sourceField, sourceValue); - Utils.sleep(1000); + MappingUtils.sleep(1000); String preview = this.atlasmapPage.getFieldPreviewValue(targetField); Assert.assertEquals(targetValue, preview); } diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java index c749818..e510501 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; +import io.atlasmap.qe.test.MappingValidator; import io.atlasmap.qe.test.atlas.AtlasmapInit; import org.junit.Assert; @@ -10,7 +11,7 @@ import io.atlasmap.qe.test.atlas.AtlasmapPage; import io.atlasmap.qe.test.atlas.utils.HoverAction; -import io.atlasmap.qe.test.atlas.utils.Utils; +import io.atlasmap.qe.test.atlas.utils.MappingUtils; import io.cucumber.datatable.DataTable; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; @@ -18,15 +19,23 @@ import io.cucumber.java.en.When; import lombok.extern.slf4j.Slf4j; +import javax.inject.Inject; + + @Slf4j -public class UISteps extends CucumberGlue { +public class UISteps { + + @Inject + private MappingValidator validator; + + @Inject + private AtlasmapPage atlasmapPage; - private AtlasmapPage atlasmapPage = new AtlasmapPage(); - private static boolean internalMapping = true; + private boolean internalMapping = true; @Given("atlasmap contains TestClass") - public void atlasmapContainsTestClass() throws Exception { - String resp = Utils.requestClass(atlasmapPage.TEST_CLASS); + public void atlasMapContainsTestClass() throws Exception { + String resp = MappingUtils.requestClass(atlasmapPage.TEST_CLASS); assertThat(resp).contains(atlasmapPage.TEST_CLASS); } @@ -243,7 +252,7 @@ public void checkThatOnRowNumberIsForSourceValueSDisplayedTargetPreview(int inde atlasmapPage.clickOnRowInMappingTable(index); atlasmapPage.setPreviewValueInTable(index, "sources", source.split(";")); atlasmapPage.clickOnRowInMappingTable(index); - Utils.sleep(500); + MappingUtils.sleep(500); final String preview = atlasmapPage.getPreviewValueInTable(index, "targets"); assertThat(preview).isEqualTo(target); } diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/CucumberSpring.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/CucumberSpring.java deleted file mode 100644 index 6ac978f..0000000 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/CucumberSpring.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.atlasmap.qe.test.atlas.utils; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.ContextConfiguration; - -import io.cucumber.spring.CucumberContextConfiguration; - -@CucumberContextConfiguration -@ContextConfiguration(classes = CucumberSpring.class) -@ComponentScan(basePackages = {"io.atlasmap.qe"}) -public class CucumberSpring { -} diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MappingUtils.java similarity index 98% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MappingUtils.java index 74d5b16..a844659 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/Utils.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MappingUtils.java @@ -2,6 +2,7 @@ import static com.codeborne.selenide.Condition.visible; +import io.atlasmap.v2.Mapping; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.TrueFileFilter; import org.apache.commons.io.filefilter.WildcardFileFilter; @@ -22,7 +23,7 @@ * Created by mmelko on 16/11/2017. */ @Slf4j -public class Utils { +public class MappingUtils { private static final String LIBRARY_SERVICE = TestConfiguration.getBackendUrl() + "/v2/atlas/library/list/"; @@ -92,7 +93,7 @@ public static void restoreAdmFile() throws IOException { public static void backupAdmFile() throws IOException { File mappings = new File(TestConfiguration.getMappingsRootDirectory()); // this is necessary when using fast init - Utils.sleep(1000); + MappingUtils.sleep(1000); if (mappings.exists()) { FileUtils.listFiles(mappings, new WildcardFileFilter("*.gz"), TrueFileFilter.TRUE).forEach(f -> { File backupAdmFile = new File(f.getAbsoluteFile().getAbsolutePath() + "_backup"); diff --git a/datamapper-e2e/src/test/resources/features/FieldActions/DateFieldActions.feature b/datamapper-e2e/src/test/resources/features/FieldActions/DateFieldActions.feature index 854ed09..05e2933 100644 --- a/datamapper-e2e/src/test/resources/features/FieldActions/DateFieldActions.feature +++ b/datamapper-e2e/src/test/resources/features/FieldActions/DateFieldActions.feature @@ -13,6 +13,8 @@ Feature: Date related field actions When add mapping from "" to "targetInteger" And add "" transformation on "source" And set "" value in target's "targetInteger" + + # FIXME: "set source data" is not working properly And set source data | | | 2012-12-21-09:00 | diff --git a/mapping-validator/pom.xml b/mapping-validator/pom.xml index e6b0657..5d17dbd 100644 --- a/mapping-validator/pom.xml +++ b/mapping-validator/pom.xml @@ -44,16 +44,6 @@ - - io.cucumber - cucumber-java - ${cucumber.version} - - - io.cucumber - cucumber-spring - ${cucumber.version} - org.springframework spring-core @@ -64,7 +54,16 @@ spring-context ${spring.version} - + + org.springframework + spring-test + ${spring.version} + + + javax.inject + javax.inject + 1 + org.apache.camel camel-core @@ -125,11 +124,16 @@ log4j-core ${log4j.version} + + org.testng + testng + 7.4.0 + test + org.assertj assertj-core 3.11.1 - diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java index af3eba2..de14b59 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java @@ -9,6 +9,7 @@ import org.apache.commons.io.IOUtils; import org.json.JSONArray; import org.json.JSONObject; +import org.springframework.stereotype.Component; import java.io.IOException; import java.io.InputStream; @@ -18,6 +19,8 @@ import static org.assertj.core.api.Assertions.fail; + +@Component public class AtlasMapper { public Map processMapping(Map inputMap, String mappingFilePath) { @@ -57,7 +60,7 @@ public void configure() { return targetMap; } catch (Exception e) { e.printStackTrace(); - fail(e.getMessage()); + fail(e.getMessage()); // TODO return null; } } @@ -84,8 +87,8 @@ private String extractDataSourceIdByName(String mappingFilePath, String dataSour JSONObject atlasMappingJson = exportAtlasJson(mappingFilePath); JSONArray dataSourceList = atlasMappingJson.getJSONObject("AtlasMapping").getJSONArray("dataSource"); - for(int i = 0; i < dataSourceList.length(); i++) { - if(dataSourceList.getJSONObject(i).getString("name").contentEquals(dataSourceName)) { + for (int i = 0; i < dataSourceList.length(); i++) { + if (dataSourceList.getJSONObject(i).getString("name").contentEquals(dataSourceName)) { dataSourceId = dataSourceList.getJSONObject(i).getString("id"); break; } @@ -98,7 +101,7 @@ private JSONObject exportAtlasJson(String mappingFilePath) { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); InputStream atlasFileStream = classloader.getResourceAsStream(mappingFilePath); try { - jsonTxt = IOUtils.toString( atlasFileStream ); + jsonTxt = IOUtils.toString(atlasFileStream); } catch (IOException e) { e.printStackTrace(); } diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java index 8f28551..f43f6e3 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java @@ -7,13 +7,21 @@ import java.text.ParseException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.stream.Stream; import io.atlasmap.qe.resources.ResourcesGenerator; +import org.springframework.beans.BeanWrapper; +import org.springframework.beans.PropertyAccessorFactory; +import org.springframework.core.convert.ConversionService; +import org.springframework.stereotype.Component; + +import javax.inject.Inject; /** * Created by mmelko on 15/11/2017. */ +@Component public class MappingValidator { private static final Logger LOG = LogManager.getLogger(MappingValidator.class); public static final String SOURCE_MAP = "SOURCE_MAP"; @@ -24,7 +32,12 @@ public class MappingValidator { private TargetMappingTestClass target; private Map expectedMap; private Map sourceMap; - private final AtlasMapper atlasMapper = new AtlasMapper(); + + @Inject + private AtlasMapper atlasMapper; + + @Inject + private ConversionService conversionService; public MappingValidator() { initializeValues(); @@ -89,7 +102,7 @@ public boolean verifyMapping(SourceMappingTestClass source, TargetMappingTestCla public boolean verifyMultiObjectMapping() { this.sourceMap.put(this.source.getClass().getName(), this.source); - this.expectedMap.put(this.target.getClass().getName(), this.target); + this.expectedMap.put(this.target.getClass().getName(), this.target); // FIXME: why is this here? final boolean res = verifyMultiObjectMapping(this.sourceMap); this.clear(); this.initValidator(); @@ -111,7 +124,7 @@ public boolean verifyMappingInputExpected(Map input, Map { Object actual = getExpectedValue(processed, k); - assertThat(v).isEqualTo(actual); + assertThat(actual).isEqualTo(v); }); return true; } @@ -142,20 +155,30 @@ public void map(String source, String target) throws ParseException { setTargetValue(target, getSourceValue(source)); } - public void setTargetValue(String field, Object value) throws ParseException { - this.target.setAndConvertValue(field, value); + public void setTargetValue(String field, Object value) { + setValueOfBeanProperty(target, field, value); } - public void setSourceValue(String field, Object value) throws ParseException { - source.setAndConvertValue(field, value); + public void setSourceValue(String field, Object value) { + setValueOfBeanProperty(source, field, value); } public Object getSourceValue(String field) { - return this.source.getValue(field); + return getValueOfBeanProperty(this.source, field); } public Object getTargetValue(String field) { - return this.target.getValue(field); + return getValueOfBeanProperty(this.target, field); + } + + public void setValueOfBeanProperty(Object bean, String fieldName, Object value) { + BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(bean); + beanWrapper.setPropertyValue(fieldName, conversionService.convert(value, + Objects.requireNonNull(beanWrapper.getPropertyType(fieldName)))); + } + + public Object getValueOfBeanProperty(Object bean, String fieldName) { + return PropertyAccessorFactory.forBeanPropertyAccess(bean).getPropertyValue(fieldName); } public TargetMappingTestClass getTarget() { @@ -206,11 +229,7 @@ public void initValidator() { sourceMap.put(SourceListsClass.class.getName(), new SourceListsClass()); sourceMap.put(SmallMappingTestClass.class.getName(), new SmallMappingTestClass()); sourceMap.put(SourceNestedCollectionClass.class.getName(), new SourceNestedCollectionClass()); - try { - sourceMap.put(DatesObject.class.getName(), new DatesObject("21-12-2012")); - } catch (ParseException e) { - e.printStackTrace(); - } + sourceMap.put(DatesObject.class.getName(), new DatesObject("21-12-2012")); sourceMap.put("sourceJson.schema", ResourcesGenerator.getJsonInstance()); sourceMap.put("sourceArrays", ResourcesGenerator.getJsonArrays()); sourceMap.put("sourceXmlInstance", ResourcesGenerator.getXMLInstance()); diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/ValidatorSpringConfig.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/ValidatorSpringConfig.java new file mode 100644 index 0000000..adee6a0 --- /dev/null +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/ValidatorSpringConfig.java @@ -0,0 +1,40 @@ +package io.atlasmap.qe.test; + +import io.atlasmap.qe.test.converter.CharacterToBooleanConverter; +import io.atlasmap.qe.test.converter.NumberToBooleanConverter; +import io.atlasmap.qe.test.converter.NumberToDateConverter; +import io.atlasmap.qe.test.converter.StringToDateConverter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.ConversionServiceFactoryBean; +import org.springframework.core.convert.converter.Converter; + +import javax.inject.Inject; +import java.util.HashSet; +import java.util.Set; + +@Configuration +@ComponentScan(basePackageClasses = ValidatorSpringConfig.class) +public class ValidatorSpringConfig { + + @Inject + @Bean(name = "conversionService") + public ConversionServiceFactoryBean getConversionService(StringToDateConverter stringToDateConverter, + NumberToDateConverter numberToDateConverter, + NumberToBooleanConverter numberToBooleanConverter, + CharacterToBooleanConverter characterToBooleanConverter) { + + ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean(); + + Set converters = new HashSet<>(); + + converters.add(stringToDateConverter); + converters.add(numberToDateConverter); + converters.add(numberToBooleanConverter); + converters.add(characterToBooleanConverter); + + bean.setConverters(converters); + return bean; + } +} diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/CharacterToBooleanConverter.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/CharacterToBooleanConverter.java new file mode 100644 index 0000000..640ef8a --- /dev/null +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/CharacterToBooleanConverter.java @@ -0,0 +1,14 @@ +package io.atlasmap.qe.test.converter; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + + +@Component +public class CharacterToBooleanConverter implements Converter { + + @Override + public Boolean convert(Character value) { + return value != '\000'; + } +} diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToBooleanConverter.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToBooleanConverter.java new file mode 100644 index 0000000..b9285dd --- /dev/null +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToBooleanConverter.java @@ -0,0 +1,14 @@ +package io.atlasmap.qe.test.converter; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + + +@Component +public class NumberToBooleanConverter implements Converter { + + @Override + public Boolean convert(Number value) { + return value.doubleValue() != 0; + } +} diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToDateConverter.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToDateConverter.java new file mode 100644 index 0000000..2c6586f --- /dev/null +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToDateConverter.java @@ -0,0 +1,16 @@ +package io.atlasmap.qe.test.converter; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import java.util.Date; + + +@Component +public class NumberToDateConverter implements Converter { + + @Override + public Date convert(Number value) { + return new Date(value.longValue()); + } +} diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/StringToDateConverter.java b/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/StringToDateConverter.java new file mode 100644 index 0000000..cef762a --- /dev/null +++ b/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/StringToDateConverter.java @@ -0,0 +1,22 @@ +package io.atlasmap.qe.test.converter; + +import lombok.SneakyThrows; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + + +@Component +public class StringToDateConverter implements Converter { + + @SneakyThrows + @Override + public Date convert(String value) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh"); + format.setTimeZone(TimeZone.getTimeZone("UTC")); + return format.parse(value); + } +} diff --git a/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java b/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java index 39ebeb2..73da849 100644 --- a/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java +++ b/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java @@ -1,42 +1,52 @@ package io.atlasmap.qe.test; -import org.junit.Assert; -import org.junit.Test; - import lombok.extern.slf4j.Slf4j; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.Test; + +import javax.inject.Inject; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; import static org.assertj.core.api.Assertions.assertThat; + /** * Tests for mapping validator. * * @author Ondřej Kuhejda */ @Slf4j -public class MappingValidatorTest { +@ContextConfiguration(classes = ValidatorSpringConfig.class) +public class MappingValidatorTest extends AbstractTestNGSpringContextTests { + + @Inject + MappingValidator mv; @Test - public void javaToJavaMapping() throws Exception { - MappingValidator mv = new MappingValidator(); + public void javaToJavaMapping() { + mv.initValidator(); mv.setMappingLocation("javaToJava.json"); mv.setTargetValue("targetCombineString", "sourceString sourceAnotherString 1"); - Assert.assertTrue(mv.verifyMapping()); + assertThat(mv.verifyMapping()).isTrue(); } @Test - public void jsonToJavaMapping() throws Exception { - MappingValidator mv = new MappingValidator(); + public void jsonToJavaMapping() { + mv.initValidator(); mv.setMappingLocation("jsonToJava.json"); mv.setTargetValue("targetString", "sourceJsonString"); mv.setTargetValue("targetInteger", "10"); mv.setTargetValue("targetDouble", "-50"); mv.setTargetValue("targetFloat", "40.0"); - Assert.assertTrue(mv.verifyMapping()); + assertThat(mv.verifyMapping()).isTrue(); } @Test - public void jsonToXmlMapping() throws Exception { - MappingValidator mv = new MappingValidator(); + public void jsonToXmlMapping() { + mv.initValidator(); mv.setMappingLocation("jsonToXml.json"); String result = (String) mv.processMapping("targetXMLSchema"); assertThat(result).contains("sourceJsonString"); @@ -45,24 +55,106 @@ public void jsonToXmlMapping() throws Exception { } @Test - public void xmlSchemaToJavaMapping() throws Exception { - MappingValidator mv = new MappingValidator(); + public void xmlSchemaToJavaMapping() { + mv.initValidator(); mv.setMappingLocation("xmlSchemaToJava.json"); mv.setTargetValue("targetString", "XmlString"); mv.setTargetValue("targetInteger", "300"); mv.setTargetValue("targetDouble", "500"); mv.setTargetValue("targetFloat", "100.1"); - Assert.assertTrue(mv.verifyMapping()); + assertThat(mv.verifyMapping()).isTrue(); } @Test - public void xmlToJsonMapping() throws Exception { - MappingValidator mv = new MappingValidator(); + public void xmlToJsonMapping() { + mv.initValidator(); mv.setMappingLocation("xmlToJson.json"); String result = (String) mv.processMapping("targetJson.schema"); assertThat(result).contains("\"targetJsonInteger\":300"); assertThat(result).contains("\"targetJsonInteger\":300"); } + + @Test + public void setValuesOfBeanProperties() { + mv.initValidator(); + TargetMappingTestClass bean = new TargetMappingTestClass(); + + mv.setValueOfBeanProperty(bean, "targetString", "targetString"); + mv.setValueOfBeanProperty(bean, "targetCombineString", "targetCombineString"); + mv.setValueOfBeanProperty(bean, "targetInteger", 5); + mv.setValueOfBeanProperty(bean, "targetLong", 4L); + mv.setValueOfBeanProperty(bean, "targetFloat", 3f); + mv.setValueOfBeanProperty(bean, "targetDouble", 2d); + mv.setValueOfBeanProperty(bean, "targetDate", new Date(0)); + mv.setValueOfBeanProperty(bean, "targetAnotherString", "targetAnotherString"); + mv.setValueOfBeanProperty(bean, "targetBoolean", false); + mv.setValueOfBeanProperty(bean, "targetShort", 1); + mv.setValueOfBeanProperty(bean, "targetByte", Byte.MIN_VALUE); + mv.setValueOfBeanProperty(bean, "targetChar", 'x'); + mv.setValueOfBeanProperty(bean, "targetBigInteger", new BigInteger("0")); + mv.setValueOfBeanProperty(bean, "targetBigDecimal", new BigDecimal("0")); + mv.setValueOfBeanProperty(bean, "targetSmallMappingTestClass", new SmallMappingTestClass()); + mv.setValueOfBeanProperty(bean, "dateObjectVariable", new DatesObject("01-01-1989")); + mv.setValueOfBeanProperty(bean, "targetEnum", SimpleEnum.VALUE2); + + TargetMappingTestClass targetMappingTestClass = new TargetMappingTestClass(); + assertThat(bean).isEqualTo(targetMappingTestClass); + + mv.setValueOfBeanProperty(bean, "targetInteger", "5"); + mv.setValueOfBeanProperty(bean, "targetLong", "4"); + mv.setValueOfBeanProperty(bean, "targetFloat", "3"); + mv.setValueOfBeanProperty(bean, "targetDouble", "2"); + mv.setValueOfBeanProperty(bean, "targetDate", "1970-01-01-00"); + mv.setValueOfBeanProperty(bean, "targetBoolean", "false"); + mv.setValueOfBeanProperty(bean, "targetShort", "1"); + mv.setValueOfBeanProperty(bean, "targetByte", "-128"); + mv.setValueOfBeanProperty(bean, "targetChar", "x"); + mv.setValueOfBeanProperty(bean, "targetBigInteger", "0"); + mv.setValueOfBeanProperty(bean, "targetBigDecimal", "0"); + mv.setValueOfBeanProperty(bean, "targetEnum", "VALUE2"); + + assertThat(bean).isEqualTo(targetMappingTestClass); + + mv.setValueOfBeanProperty(bean, "targetDate", 0); + mv.setValueOfBeanProperty(bean, "targetBoolean", new BigDecimal("0")); + + assertThat(bean).isEqualTo(targetMappingTestClass); + + mv.setValueOfBeanProperty(bean, "targetInteger", '\005'); + mv.setValueOfBeanProperty(bean, "targetLong", '\004'); + mv.setValueOfBeanProperty(bean, "targetFloat", '\003'); + mv.setValueOfBeanProperty(bean, "targetDouble", '\002'); + mv.setValueOfBeanProperty(bean, "targetBoolean", '\000'); + mv.setValueOfBeanProperty(bean, "targetShort", '\001'); + mv.setValueOfBeanProperty(bean, "targetBigInteger", '\000'); + mv.setValueOfBeanProperty(bean, "targetBigDecimal", '\000'); + + assertThat(bean).isEqualTo(targetMappingTestClass); + } + + @Test + public void dateObjectsMapping() { + mv.initValidator(); + + DatesObject sourceDate = new DatesObject("22-12-2012"); + mv.addSource(sourceDate.getClass().getName(), sourceDate); + + mv.setMappingLocation("fromDateObjectToDateObject.json"); + + TargetMappingTestClass targetMappingTestClass = (TargetMappingTestClass) mv.processMapping(TargetMappingTestClass.class.getName()); + DatesObject dateObjectVariable = targetMappingTestClass.getDateObjectVariable(); + + assertThat(sourceDate.getStandardJavaDate()).isEqualTo(dateObjectVariable.getStandardJavaDate()); + assertThat(sourceDate.getCalendar().getTimeInMillis()).isEqualTo(dateObjectVariable.getCalendar().getTimeInMillis()); + assertThat(sourceDate.getLocalDate()).isEqualTo(dateObjectVariable.getLocalDate()); + assertThat(sourceDate.getLocalDateTime()).isEqualTo(dateObjectVariable.getLocalDateTime()); + assertThat(sourceDate.getLocalTime()).isEqualTo(dateObjectVariable.getLocalTime()); + assertThat(sourceDate.getTime()).isEqualTo(dateObjectVariable.getTime()); + assertThat(sourceDate.getTimestamp()).isEqualTo(dateObjectVariable.getTimestamp()); + assertThat(sourceDate.getZonedDateTime()).isEqualTo(dateObjectVariable.getZonedDateTime()); + assertThat(sourceDate.getSqlDate().toString()).isEqualTo(dateObjectVariable.getSqlDate().toString()); + assertThat(sourceDate.getGregorianCalendar()).isEqualTo(dateObjectVariable.getGregorianCalendar()); + } } diff --git a/mapping-validator/src/test/resources/fromDateObjectToDateObject.json b/mapping-validator/src/test/resources/fromDateObjectToDateObject.json new file mode 100644 index 0000000..98431e9 --- /dev/null +++ b/mapping-validator/src/test/resources/fromDateObjectToDateObject.json @@ -0,0 +1,368 @@ +{ + "AtlasMapping" : { + "jsonType" : "io.atlasmap.v2.AtlasMapping", + "dataSource" : [ { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceMappingTestClass", + "name" : "io.atlasmap.qe.test.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.DatesObject", + "name" : "io.atlasmap.qe.test.DatesObject", + "description" : "Java document class io.atlasmap.qe.test.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceListsClass", + "name" : "io.atlasmap.qe.test.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SmallMappingTestClass", + "name" : "io.atlasmap.qe.test.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceArrays-327e9f21-71ca-423c-9abd-5bf62ccb6202", + "name" : "sourceArrays", + "description" : "Source document sourceArrays type: JSON", + "uri" : "atlas:json:sourceArrays-327e9f21-71ca-423c-9abd-5bf62ccb6202", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJsonArray-b5b047f2-1cf6-48d5-be23-2c5ccfa590e5", + "name" : "sourceJsonArray", + "description" : "Source document sourceJsonArray type: JSON", + "uri" : "atlas:json:sourceJsonArray-b5b047f2-1cf6-48d5-be23-2c5ccfa590e5", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "sourceJson.schema-f2a5c14f-d24f-444c-8ce7-9daf3499209e", + "name" : "sourceJson.schema", + "description" : "Source document sourceJson.schema type: JSON", + "uri" : "atlas:json:sourceJson.schema-f2a5c14f-d24f-444c-8ce7-9daf3499209e", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXmlInstance-9c72624a-e5fe-4577-b63d-a84f51dbb509", + "name" : "sourceXmlInstance", + "description" : "Source document sourceXmlInstance type: XML", + "uri" : "atlas:xml:sourceXmlInstance-9c72624a-e5fe-4577-b63d-a84f51dbb509", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "sourceXMLSchema-564b49aa-fac2-467c-8ac7-4497e7c63e68", + "name" : "sourceXMLSchema", + "description" : "Source document sourceXMLSchema type: XSD", + "uri" : "atlas:xml:sourceXMLSchema-564b49aa-fac2-467c-8ac7-4497e7c63e68", + "dataSourceType" : "SOURCE", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "sourceCsv-abd44290-56a6-44e3-9442-8a963c0e14ed", + "name" : "sourceCsv", + "description" : "Source document sourceCsv type: CSV", + "uri" : "atlas:csv:sourceCsv-abd44290-56a6-44e3-9442-8a963c0e14ed", + "dataSourceType" : "SOURCE" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetMappingTestClass", + "name" : "io.atlasmap.qe.test.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.StringObject", + "name" : "io.atlasmap.qe.test.StringObject", + "description" : "Java document class io.atlasmap.qe.test.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetListsClass", + "name" : "io.atlasmap.qe.test.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetArrays-4ba232c5-d534-4985-a79d-1c689feea9ac", + "name" : "targetArrays", + "description" : "Target document targetArrays type: JSON", + "uri" : "atlas:json:targetArrays-4ba232c5-d534-4985-a79d-1c689feea9ac", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJsonArray-e3bef3f6-ddb0-4589-b8b3-c3fde41bf15a", + "name" : "targetJsonArray", + "description" : "Target document targetJsonArray type: JSON", + "uri" : "atlas:json:targetJsonArray-e3bef3f6-ddb0-4589-b8b3-c3fde41bf15a", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.json.v2.JsonDataSource", + "id" : "targetJson.schema-62fd3b6a-3e74-4167-a8e6-9ba6eb2aedbe", + "name" : "targetJson.schema", + "description" : "Target document targetJson.schema type: JSON", + "uri" : "atlas:json:targetJson.schema-62fd3b6a-3e74-4167-a8e6-9ba6eb2aedbe", + "dataSourceType" : "TARGET" + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLSchema-43885419-4d8b-423c-ae5c-79a6d6a1dc1a", + "name" : "targetXMLSchema", + "description" : "Target document targetXMLSchema type: XSD", + "uri" : "atlas:xml:targetXMLSchema-43885419-4d8b-423c-ae5c-79a6d6a1dc1a", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.xml.v2.XmlDataSource", + "id" : "targetXMLInstance-52583445-d1d1-492b-be8a-1bd268e7e84e", + "name" : "targetXMLInstance", + "description" : "Target document targetXMLInstance type: XML", + "uri" : "atlas:xml:targetXMLInstance-52583445-d1d1-492b-be8a-1bd268e7e84e", + "dataSourceType" : "TARGET", + "xmlNamespaces" : { + "xmlNamespace" : [ ] + } + }, { + "jsonType" : "io.atlasmap.v2.DataSource", + "id" : "targetCsv-37b83f14-4634-4bc0-8c75-8c11e9d20ae9", + "name" : "targetCsv", + "description" : "Target document targetCsv type: CSV", + "uri" : "atlas:csv:targetCsv-37b83f14-4634-4bc0-8c75-8c11e9d20ae9", + "dataSourceType" : "TARGET" + } ], + "mappings" : { + "mapping" : [ { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/standardJavaDate", + "fieldType" : "DATE_TIME", + "name" : "standardJavaDate", + "className" : "java.util.Date" + } ], + "id" : "mapping.972563" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/sqlDate", + "fieldType" : "DATE", + "name" : "sqlDate", + "className" : "java.sql.Date" + } ], + "id" : "mapping.814611" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/localDate", + "fieldType" : "DATE", + "name" : "localDate", + "className" : "java.time.LocalDate" + } ], + "id" : "mapping.176755" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/localDateTime", + "fieldType" : "DATE_TIME", + "name" : "localDateTime", + "className" : "java.time.LocalDateTime" + } ], + "id" : "mapping.250598" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/localTime", + "fieldType" : "TIME", + "name" : "localTime", + "className" : "java.time.LocalTime" + } ], + "id" : "mapping.770674" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/time", + "fieldType" : "TIME", + "name" : "time", + "className" : "java.sql.Time" + } ], + "id" : "mapping.11232" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/timestamp", + "fieldType" : "DATE_TIME", + "name" : "timestamp", + "className" : "java.sql.Timestamp" + } ], + "id" : "mapping.341133" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/zonedDateTime", + "fieldType" : "DATE_TIME_TZ", + "name" : "zonedDateTime", + "className" : "java.time.ZonedDateTime" + } ], + "id" : "mapping.440625" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "id" : "mapping.696249" + }, { + "jsonType" : "io.atlasmap.v2.Mapping", + "inputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.DatesObject", + "path" : "/calendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "calendar", + "className" : "java.util.Calendar" + } ], + "outputField" : [ { + "jsonType" : "io.atlasmap.java.v2.JavaField", + "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "path" : "/dateObjectVariable/gregorianCalendar", + "fieldType" : "DATE_TIME_TZ", + "name" : "gregorianCalendar", + "className" : "java.util.GregorianCalendar" + } ], + "id" : "mapping.555503" + } ] + }, + "lookupTables" : { + "lookupTable" : [ ] + }, + "constants" : { + "constant" : [ ] + }, + "properties" : { + "property" : [ ] + }, + "name" : "UI.0" + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 604d61c..3de43a8 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,6 @@ cucumber-spring ${cucumber.version} - @@ -160,7 +159,6 @@ io.atlasmap.qe.test.atlas.AtlasmapInit, pretty, - junit:target/cucumber/cucumber-junit.xml, json:target/cucumber/cucumber-report.json, io.atlasmap.qe.test.atlas.utils.MailFormatter:target/cucumber/cucumber-mail/ diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/BaseClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/BaseClass.java deleted file mode 100644 index 9867520..0000000 --- a/test-resources/src/main/java/io/atlasmap/qe/test/BaseClass.java +++ /dev/null @@ -1,134 +0,0 @@ -package io.atlasmap.qe.test; - -import java.util.Arrays; -import java.util.Objects; - -public abstract class BaseClass { - - public static class NestedClass { - private String nestedField; - private NestedClass[] nestedArray; - private NestedClass[] nestedRenamedArray; - - public String getNestedField() { - return nestedField; - } - - public void setNestedField(String nestedField) { - this.nestedField = nestedField; - } - - public NestedClass() { - } - - public NestedClass(String nestedField) { - this.nestedField = nestedField; - } - - public NestedClass[] getNestedArray() { - return nestedArray; - } - - public void setNestedArray(NestedClass[] nestedArray) { - this.nestedArray = nestedArray; - } - - public NestedClass[] getNestedRenamedArray() { - return nestedRenamedArray; - } - - public void setNestedRenamedArray(NestedClass[] nestedRenamedArray) { - this.nestedRenamedArray = nestedRenamedArray; - } - - @Override - public String toString() { - return "NestedClass{" + - "nestedField='" + nestedField + '\'' + - ", nestedArray=" + Arrays.toString(nestedArray) + - ", nestedRenamedArray=" + Arrays.toString(nestedRenamedArray) + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NestedClass that = (NestedClass) o; - return Objects.equals(nestedField, that.nestedField) && - Arrays.equals(nestedArray, that.nestedArray) && - Arrays.equals(nestedRenamedArray, that.nestedRenamedArray); - } - - @Override - public int hashCode() { - int result = Objects.hash(nestedField); - result = 31 * result + Arrays.hashCode(nestedArray); - result = 31 * result + Arrays.hashCode(nestedRenamedArray); - return result; - } - } - - private String rootField; - private NestedClass[] rootArray; - private NestedClass[] rootRenamedArray; - - public String getRootField() { - return rootField; - } - - public void setRootField(String rootField) { - this.rootField = rootField; - } - - public NestedClass[] getRootArray() { - return rootArray; - } - - public void setRootArray(NestedClass[] rootArray) { - this.rootArray = rootArray; - } - - public NestedClass[] getRootRenamedArray() { - return rootRenamedArray; - } - - public void setRootRenamedArray(NestedClass[] rootRenamedArray) { - this.rootRenamedArray = rootRenamedArray; - } - - @Override - public String toString() { - return "BaseClass{" + - "rootField='" + rootField + '\'' + - ", rootArray=" + Arrays.toString(rootArray) + - ", rootRenamedArray=" + Arrays.toString(rootRenamedArray) + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BaseClass baseClass = (BaseClass) o; - return Objects.equals(rootField, baseClass.rootField) && - Arrays.equals(rootArray, baseClass.rootArray) && - Arrays.equals(rootRenamedArray, baseClass.rootRenamedArray); - } - - @Override - public int hashCode() { - int result = Objects.hash(rootField); - result = 31 * result + Arrays.hashCode(rootArray); - result = 31 * result + Arrays.hashCode(rootRenamedArray); - return result; - } -} \ No newline at end of file diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/DatesObject.java b/test-resources/src/main/java/io/atlasmap/qe/test/DatesObject.java index 9c588b7..f01f3eb 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/DatesObject.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/DatesObject.java @@ -1,12 +1,13 @@ package io.atlasmap.qe.test; +import lombok.Data; + import java.sql.Time; import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; - import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; @@ -14,13 +15,13 @@ import java.time.ZoneId; import java.time.ZonedDateTime; - import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; -import java.util.Objects; import java.util.TimeZone; + +@Data public class DatesObject { private Date standardJavaDate; @@ -34,27 +35,23 @@ public class DatesObject { private GregorianCalendar gregorianCalendar; private Calendar calendar; - public Calendar getCalendar() { - return calendar; - } - - public void setCalendar(Calendar calendar) { - this.calendar = calendar; - } - - public DatesObject() throws ParseException { + public DatesObject() { final String date = "05-05-1989"; init(date); } - public DatesObject(String date) throws ParseException { + public DatesObject(String date) { init(date); } - private void init(String date) throws ParseException { + private void init(String date) { SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); - this.standardJavaDate = formatter.parse(date); + try { + this.standardJavaDate = formatter.parse(date); + } catch (ParseException e) { + throw new IllegalArgumentException("Wrong date format: " + date); + } Instant i = this.standardJavaDate.toInstant(); this.sqlDate = new java.sql.Date(i.toEpochMilli()); @@ -67,119 +64,4 @@ private void init(String date) throws ParseException { this.gregorianCalendar = GregorianCalendar.from(this.zonedDateTime); this.calendar = gregorianCalendar; } - - public Date getStandardJavaDate() { - return standardJavaDate; - } - - public void setStandardJavaDate(Date standardJavaDate) { - this.standardJavaDate = standardJavaDate; - } - - public java.sql.Date getSqlDate() { - return sqlDate; - } - - public void setSqlDate(java.sql.Date sqlDate) { - this.sqlDate = sqlDate; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = timestamp; - } - - public ZonedDateTime getZonedDateTime() { - return zonedDateTime; - } - - public void setZonedDateTime(ZonedDateTime zonedDateTime) { - this.zonedDateTime = zonedDateTime; - } - - public LocalDateTime getLocalDateTime() { - return localDateTime; - } - - public void setLocalDateTime(LocalDateTime localDateTime) { - this.localDateTime = localDateTime; - } - - public LocalDate getLocalDate() { - return localDate; - } - - public void setLocalDate(LocalDate localDate) { - this.localDate = localDate; - } - - public LocalTime getLocalTime() { - return localTime; - } - - public void setLocalTime(LocalTime localTime) { - this.localTime = localTime; - } - - public Time getTime() { - return time; - } - - public void setTime(Time time) { - this.time = time; - } - - public GregorianCalendar getGregorianCalendar() { - return gregorianCalendar; - } - - public void setGregorianCalendar(GregorianCalendar gregorianCalendar) { - this.gregorianCalendar = gregorianCalendar; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - DatesObject that = (DatesObject) o; - return Objects.equals(standardJavaDate, that.standardJavaDate) && - Objects.equals(sqlDate, that.sqlDate) && - Objects.equals(timestamp, that.timestamp) && - Objects.equals(zonedDateTime, that.zonedDateTime) && - Objects.equals(localDateTime, that.localDateTime) && - Objects.equals(localDate, that.localDate) && - Objects.equals(localTime, that.localTime) && - Objects.equals(time, that.time) && - Objects.equals(gregorianCalendar, that.gregorianCalendar); - } - - @Override - public int hashCode() { - - return Objects.hash(standardJavaDate, sqlDate, timestamp, zonedDateTime, localDateTime, localDate, localTime, time, gregorianCalendar); - } - - @Override - public String toString() { - return "DatesObject{" + - "standardJavaDate=" + standardJavaDate + - ", sqlDate=" + sqlDate + - ", timestamp=" + timestamp + - ", zonedDateTime=" + zonedDateTime + - ", localDateTime=" + localDateTime + - ", localDate=" + localDate + - ", localTime=" + localTime + - ", time=" + time + - ", gregorianCalendar=" + gregorianCalendar + - ", calendar=" + calendar + - '}'; - } } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/MappingTestClassConverter.java b/test-resources/src/main/java/io/atlasmap/qe/test/MappingTestClassConverter.java deleted file mode 100644 index 316b904..0000000 --- a/test-resources/src/main/java/io/atlasmap/qe/test/MappingTestClassConverter.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.atlasmap.qe.test; - -import java.text.ParseException; - -public interface MappingTestClassConverter { - public void setAndConvertValue(String field, Object value) throws ParseException; - - public Object getValue(String field); -} diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/NestedCollectionClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/NestedCollectionClass.java new file mode 100644 index 0000000..82b771f --- /dev/null +++ b/test-resources/src/main/java/io/atlasmap/qe/test/NestedCollectionClass.java @@ -0,0 +1,23 @@ +package io.atlasmap.qe.test; + +import lombok.Data; + + +@Data +public abstract class NestedCollectionClass { + + @Data + public static class NestedClass { + private String nestedField; + private NestedClass[] nestedArray; + private NestedClass[] nestedRenamedArray; + + public NestedClass(String nestedField) { + this.nestedField = nestedField; + } + } + + private String rootField; + private NestedClass[] rootArray; + private NestedClass[] rootRenamedArray; +} diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SimpleEnum.java b/test-resources/src/main/java/io/atlasmap/qe/test/SimpleEnum.java index 8e27759..4b30b95 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SimpleEnum.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/SimpleEnum.java @@ -1,5 +1,6 @@ package io.atlasmap.qe.test; + public enum SimpleEnum { VALUE1, VALUE2, VALUE3 } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SmallMappingTestClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/SmallMappingTestClass.java index 72110ae..9e69ad9 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SmallMappingTestClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/SmallMappingTestClass.java @@ -1,64 +1,25 @@ package io.atlasmap.qe.test; +import lombok.Data; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import java.util.Objects; + /** * Created by mmelko on 27/10/2017. */ +@Data public class SmallMappingTestClass implements Serializable { private String objectField1; - private String objectField2; - private Long objectLong; - private List listOfStrings; - private List listOfIntegers; - private List listOfDoubles; - @Override - public String toString() { - return "SmallMappingTestClass{" + - "objectField1='" + objectField1 + '\'' + - ", objectField2='" + objectField2 + '\'' + - ", objectLong=" + objectLong + - ", listOfStrings=" + listOfStrings + - ", listOfIntegers=" + listOfIntegers + - ", listOfDoubles=" + listOfDoubles + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - SmallMappingTestClass that = (SmallMappingTestClass) o; - return Objects.equals(objectField1, that.objectField1) && - Objects.equals(objectField2, that.objectField2) && - Objects.equals(objectLong, that.objectLong) && - Objects.equals(listOfStrings, that.listOfStrings) && - Objects.equals(listOfIntegers, that.listOfIntegers) && - Objects.equals(listOfDoubles, that.listOfDoubles); - } - - @Override - public int hashCode() { - - return Objects.hash(objectField1, objectField2, objectLong, listOfStrings, listOfIntegers, listOfDoubles); - } - public SmallMappingTestClass() { initObjectVariable(1); } @@ -83,55 +44,5 @@ public void initObjectVariable(int offset) { this.listOfDoubles.add((double) i * offset); } } - - public String getObjectField1() { - return objectField1; - } - - public void setObjectField1(String objectField1) { - this.objectField1 = objectField1; - } - - public String getObjectField2() { - return objectField2; - } - - public void setObjectField2(String objectField2) { - this.objectField2 = objectField2; - } - - public void setObjectLong(Long objectLong1) { - this.objectLong = objectLong1; - } - - public List getListOfStrings() { - - return listOfStrings; - } - - public void setListOfStrings(List listOfStrings) { - this.listOfStrings = listOfStrings; - } - - public List getListOfIntegers() { - return listOfIntegers; - } - - public void setListOfIntegers(List listOfIntegers) { - this.listOfIntegers = listOfIntegers; - } - - public List getListOfDoubles() { - return listOfDoubles; - } - - public void setListOfDoubles(List listOfDoubles) { - this.listOfDoubles = listOfDoubles; - } - - - public void doSomething() { - System.out.println("Useless method"); - } } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SourceListsClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/SourceListsClass.java index 34c88a3..c456086 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SourceListsClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/SourceListsClass.java @@ -1,15 +1,19 @@ package io.atlasmap.qe.test; +import lombok.Data; + import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; + +@Data public class SourceListsClass { + private List strings; private List integers; private List doubles; @@ -40,82 +44,4 @@ public SourceListsClass() { this.set.add("setStr"+i); } } - - public List getStrings() { - return strings; - } - - public void setStrings(List strings) { - this.strings = strings; - } - - public List getIntegers() { - return integers; - } - - public void setIntegers(List integers) { - this.integers = integers; - } - - public List getDoubles() { - return doubles; - } - - public void setDoubles(List doubles) { - this.doubles = doubles; - } - - public List getFloats() { - return floats; - } - - public void setFloats(List floats) { - this.floats = floats; - } - - public List getObjects() { - return objects; - } - - public void setObjects(List objects) { - this.objects = objects; - } - - public Map getMap() { - return map; - } - - public void setMap(Map map) { - this.map = map; - } - - public Set getSet() { - return set; - } - - public void setSet(Set set) { - this.set = set; - } - - public String[] getArray() { - return array; - } - - public void setArray(String[] array) { - this.array = array; - } - - @Override - public String toString() { - return "SourceListsClass{" + - "strings=" + strings + - ", integers=" + integers + - ", doubles=" + doubles + - ", floats=" + floats + - ", objects=" + objects + - ", map=" + map + - ", set=" + set + - ", array=" + Arrays.toString(array) + - '}'; - } } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SourceMappingTestClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/SourceMappingTestClass.java index 8df0557..ba07aad 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SourceMappingTestClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/SourceMappingTestClass.java @@ -1,319 +1,36 @@ package io.atlasmap.qe.test; +import lombok.Data; + import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; -import java.text.NumberFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.Date; -import java.util.TimeZone; + /** - * Created by mmelko on 26/10/2017. + * Simple class that is used to verify mappings from Java objects. + * + * @author Ondřej Kuhejda */ -public class SourceMappingTestClass implements Serializable, MappingTestClassConverter { - - private String sourceString; - private String sourceCombineString; - private int sourceInteger; - private long sourceLong; - private float sourceFloat; - private double sourceDouble; - private BigDecimal sourceBigDecimal; - private Date sourceDate; - private String sourceAnotherString; - private boolean sourceBoolean; - private short sourceShort; - private byte sourceByte; - private char sourceChar; - private BigInteger sourceBigInteger; +@Data +public class SourceMappingTestClass implements Serializable { + private String sourceString = "sourceString"; + private String sourceCombineString = "sourceCombine"; + private int sourceInteger = 1; + private long sourceLong = 2L; + private float sourceFloat = 3f; + private double sourceDouble = 4d; + private BigDecimal sourceBigDecimal = new BigDecimal("12345"); + private Date sourceDate = Date.from(ZonedDateTime.of(1970, 1, 1, 0, 0, 0, 0, ZoneId.of("UTC")).toInstant()); + private String sourceAnotherString = "sourceAnotherString"; + private boolean sourceBoolean = true; + private short sourceShort = 5; + private byte sourceByte = Byte.MAX_VALUE; + private char sourceChar = 'A'; + private BigInteger sourceBigInteger = new BigInteger("12345"); private SmallMappingTestClass smallMappingTestClass; - private SimpleEnum sourceEnum; - - - public BigDecimal getSourceBigDecimal() { - return sourceBigDecimal; - } - - public void setSourceBigDecimal(BigDecimal sourceBigDecimal) { - this.sourceBigDecimal = sourceBigDecimal; - } - - public SourceMappingTestClass() { - this.sourceString = "sourceString"; - this.sourceCombineString = "sourceCombine"; - this.sourceInteger = 1; - this.sourceLong = 2L; - this.sourceFloat = 3f; - this.sourceDouble = 4d; - this.sourceShort = 5; - this.sourceByte = Byte.MAX_VALUE; - this.sourceChar = 'A'; - this.sourceBigInteger=new BigInteger("12345"); - this.sourceBigDecimal=new BigDecimal("12345"); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); - sdf.setTimeZone(TimeZone.getTimeZone("UTC")); - try { - this.sourceDate = sdf.parse("1970-01-01-00:00:00"); - } catch (ParseException e) { - e.printStackTrace(); - } - this.sourceAnotherString = "sourceAnotherString"; - this.sourceBoolean = true; - this.sourceEnum = SimpleEnum.VALUE1; - } - - @Override - public String toString() { - return "SourceMappingTestClass{" + - "sourceString='" + sourceString + '\'' + - " | sourceCombineString='" + sourceCombineString + '\'' + - " | sourceInteger=" + sourceInteger + - " | sourceLong=" + sourceLong + - " | sourceFloat=" + sourceFloat + - " | sourceDouble=" + sourceDouble + - " | sourceDate=" + sourceDate + - " | sourceAnotherString='" + sourceAnotherString + '\'' + - " | sourceBoolean=" + sourceBoolean + - " | sourceShort=" + sourceShort + - " | sourceByte=" + sourceByte + - " | sourceChar=" + sourceChar + - " | sourceEnum=" + sourceEnum + - '}'; - } - - public String getSourceString() { - return sourceString; - } - - public void setSourceString(String sourceString) { - this.sourceString = sourceString; - } - - public String getSourceCombineString() { - return sourceCombineString; - } - - public void setSourceCombineString(String sourceCombineString) { - this.sourceCombineString = sourceCombineString; - } - - public int getSourceInteger() { - return sourceInteger; - } - - public void setSourceInteger(int sourceInteger) { - this.sourceInteger = sourceInteger; - } - - public long getSourceLong() { - return sourceLong; - } - - public void setSourceLong(long sourceLong) { - this.sourceLong = sourceLong; - } - - public float getSourceFloat() { - return sourceFloat; - } - - public void setSourceFloat(float sourceFloat) { - this.sourceFloat = sourceFloat; - } - - public double getSourceDouble() { - return sourceDouble; - } - - public void setSourceDouble(double sourceDouble) { - this.sourceDouble = sourceDouble; - } - - public Date getSourceDate() { - return sourceDate; - } - - public void setSourceDate(Date sourceDate) { - this.sourceDate = sourceDate; - } - - public String getSourceAnotherString() { - return sourceAnotherString; - } - - public void setSourceAnotherString(String sourceAnotherString) { - this.sourceAnotherString = sourceAnotherString; - } - - public boolean isSourceBoolean() { - return sourceBoolean; - } - - public void setSourceBoolean(boolean sourceBoolean) { - this.sourceBoolean = sourceBoolean; - } - - public short getSourceShort() { - return sourceShort; - } - - public void setSourceShort(short sourceShort) { - this.sourceShort = sourceShort; - } - - public byte getSourceByte() { - return sourceByte; - } - - public void setSourceByte(byte sourceByte) { - this.sourceByte = sourceByte; - } - - public char getSourceChar() { - return sourceChar; - } - - public void setSourceChar(char sourceChar) { - this.sourceChar = sourceChar; - } - - public SmallMappingTestClass getSmallMappingTestClass() { - return smallMappingTestClass; - } - - public void setSmallMappingTestClass(SmallMappingTestClass o) { - this.smallMappingTestClass = o; - } - - public BigInteger getSourceBigInteger() { - return sourceBigInteger; - } - - public void setSourceBigInteger(BigInteger sourceBigInteger) { - this.sourceBigInteger = sourceBigInteger; - } - - public SimpleEnum getSourceEnum() { - return sourceEnum; - } - - public void setSourceEnum(SimpleEnum sourceEnum) { - this.sourceEnum = sourceEnum; - } - - @Override - public void setAndConvertValue(String field, Object value) throws ParseException { - - switch (field) { - - case "sourceCombineString": { - this.setSourceCombineString(value.toString()); - break; - } - case "sourceString": { - this.setSourceString(value.toString()); - break; - } - case "sourceInteger": { - this.setSourceInteger(NumberFormat.getInstance().parse(value.toString()).intValue()); - break; - } - case "sourceLong": { - this.setSourceLong((NumberFormat.getInstance().parse(value.toString())).longValue()); - break; - } - case "sourceFloat": { - this.setSourceFloat((NumberFormat.getInstance().parse(value.toString())).floatValue()); - break; - } - case "sourceDouble": { - this.setSourceDouble((NumberFormat.getInstance().parse(value.toString())).doubleValue()); - break; - } - case "sourceShort": { - this.setSourceShort((NumberFormat.getInstance().parse(value.toString())).shortValue()); - break; - } - case "sourceByte": { - this.setSourceByte(Byte.parseByte(value.toString())); - break; - } - case "sourceBigInteger": { - this.setSourceBigInteger(new BigInteger(value.toString())); - break; - } - case "sourceBigDecimal": { - this.setSourceBigDecimal(new BigDecimal(value.toString())); - break; - } - case "sourceChar": { - this.setSourceChar(value.toString().toCharArray()[0]); - break; - } - - case "sourceBoolean": { - this.setSourceBoolean(Boolean.parseBoolean(value.toString())); - break; - } - case "sourceDate": { - if (value instanceof Date) { - this.setSourceDate((Date) value); - } else if (value instanceof Number) { - this.setSourceDate(new Date(((Number) value).longValue())); - } else { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh"); - format.setTimeZone(TimeZone.getTimeZone("UTC")); - this.setSourceDate(format.parse(value.toString())); - } - break; - } - case "sourceAnotherString": { - this.setSourceAnotherString(value.toString()); - break; - } - case "sourceEnum": { - this.setSourceEnum(SimpleEnum.valueOf(value.toString())); - break; - } - } - } - - @Override - public Object getValue(String field) { - switch (field) { - case "sourceCombineString": - return getSourceCombineString(); - case "sourceString": - return getSourceString(); - case "sourceInteger": - return getSourceInteger(); - case "sourceBigInteger": - return getSourceBigInteger(); - case "sourceBigDecimal": - return getSourceBigDecimal(); - case "sourceLong": - return getSourceLong(); - case "sourceFloat": - return getSourceFloat(); - case "sourceDouble": - return getSourceDouble(); - case "sourceShort": - return getSourceShort(); - case "sourceByte": - return getSourceByte(); - case "sourceChar": - return getSourceChar(); - case "sourceDate": - return getSourceDate(); - case "sourceBoolean": - return isSourceBoolean(); - case "sourceAnotherString": - return getSourceAnotherString(); - case "sourceEnum": - return getSourceEnum(); - } - return null; - } + private SimpleEnum sourceEnum = SimpleEnum.VALUE1; } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SourceNestedCollectionClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/SourceNestedCollectionClass.java index 9d64ea6..58b5239 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SourceNestedCollectionClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/SourceNestedCollectionClass.java @@ -1,38 +1,36 @@ package io.atlasmap.qe.test; -public class SourceNestedCollectionClass extends BaseClass { +import lombok.ToString; - public SourceNestedCollectionClass() { - NestedClass array0 = new BaseClass.NestedClass("javaFirstArrayValue0"); - NestedClass array1 = new BaseClass.NestedClass("javaFirstArrayValue1"); +@ToString(callSuper=true) +public class SourceNestedCollectionClass extends NestedCollectionClass { + + public SourceNestedCollectionClass() { + NestedClass array0 = new NestedCollectionClass.NestedClass("javaFirstArrayValue0"); + NestedClass array1 = new NestedCollectionClass.NestedClass("javaFirstArrayValue1"); - BaseClass.NestedClass[] someArray = new BaseClass.NestedClass[] { + NestedCollectionClass.NestedClass[] someArray = new NestedCollectionClass.NestedClass[] { array0, array1 }; setRootArray(someArray); - BaseClass.NestedClass array00 = new BaseClass.NestedClass("javaSecondArrayValue0-0"); - BaseClass.NestedClass array01 = new BaseClass.NestedClass("javaSecondArrayValue0-1"); + NestedCollectionClass.NestedClass array00 = new NestedCollectionClass.NestedClass("javaSecondArrayValue0-0"); + NestedCollectionClass.NestedClass array01 = new NestedCollectionClass.NestedClass("javaSecondArrayValue0-1"); - array00.setNestedArray(new BaseClass.NestedClass[] { new BaseClass.NestedClass("javaThirdArrayValue0-0-0"), - new BaseClass.NestedClass("javaThirdArrayValue0-0-1")}); - array01.setNestedArray(new BaseClass.NestedClass[] { new BaseClass.NestedClass("javaThirdArrayValue0-1-0"), - new BaseClass.NestedClass("javaThirdArrayValue0-1-1"), new BaseClass.NestedClass("javaThirdArrayValue0-1-2")}); + array00.setNestedArray(new NestedCollectionClass.NestedClass[] { new NestedCollectionClass.NestedClass("javaThirdArrayValue0-0-0"), + new NestedCollectionClass.NestedClass("javaThirdArrayValue0-0-1")}); + array01.setNestedArray(new NestedCollectionClass.NestedClass[] { new NestedCollectionClass.NestedClass("javaThirdArrayValue0-1-0"), + new NestedCollectionClass.NestedClass("javaThirdArrayValue0-1-1"), new NestedCollectionClass.NestedClass("javaThirdArrayValue0-1-2")}); - array0.setNestedArray(new BaseClass.NestedClass[] {array00, array01}); - - BaseClass.NestedClass array10 = new BaseClass.NestedClass("javaSecondArrayValue1-0"); - BaseClass.NestedClass array11 = new BaseClass.NestedClass("javaSecondArrayValue1-1"); - array10.setNestedArray(new BaseClass.NestedClass[] { new BaseClass.NestedClass("javaThirdArrayValue1-0-0"), - new BaseClass.NestedClass("javaThirdArrayValue1-0-1"), new BaseClass.NestedClass("javaThirdArrayValue1-0-2")}); - array11.setNestedArray(new BaseClass.NestedClass[] { new BaseClass.NestedClass("javaThirdArrayValue1-1-0"), - new BaseClass.NestedClass("javaThirdArrayValue1-1-1")}); - array1.setNestedArray(new BaseClass.NestedClass[] { array10, array11 }); - } + array0.setNestedArray(new NestedCollectionClass.NestedClass[] {array00, array01}); - @Override - public String toString() { - return "SourceNestedCollectionClass{} " + super.toString(); + NestedCollectionClass.NestedClass array10 = new NestedCollectionClass.NestedClass("javaSecondArrayValue1-0"); + NestedCollectionClass.NestedClass array11 = new NestedCollectionClass.NestedClass("javaSecondArrayValue1-1"); + array10.setNestedArray(new NestedCollectionClass.NestedClass[] { new NestedCollectionClass.NestedClass("javaThirdArrayValue1-0-0"), + new NestedCollectionClass.NestedClass("javaThirdArrayValue1-0-1"), new NestedCollectionClass.NestedClass("javaThirdArrayValue1-0-2")}); + array11.setNestedArray(new NestedCollectionClass.NestedClass[] { new NestedCollectionClass.NestedClass("javaThirdArrayValue1-1-0"), + new NestedCollectionClass.NestedClass("javaThirdArrayValue1-1-1")}); + array1.setNestedArray(new NestedCollectionClass.NestedClass[] { array10, array11 }); } } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/StringObject.java b/test-resources/src/main/java/io/atlasmap/qe/test/StringObject.java index d09bd4a..b227aee 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/StringObject.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/StringObject.java @@ -1,9 +1,10 @@ package io.atlasmap.qe.test; -import java.util.Objects; +import lombok.Data; -public class StringObject { +@Data +public class StringObject { private String lastName; private String firstName; @@ -21,48 +22,4 @@ public StringObject (String first,String last) { this.firstName = first; this.lastName = last; } - @Override - public String toString() { - return "StringObject{" + - "lastName='" + lastName + '\'' + - ", firstName='" + firstName + '\'' + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - StringObject that = (StringObject) o; - return Objects.equals(lastName, that.lastName) && - Objects.equals(firstName, that.firstName); - } - - @Override - public int hashCode() { - - return Objects.hash(lastName, firstName); - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastname) { - this.lastName = lastname; - } - } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/TargetListsClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/TargetListsClass.java index 04bdc54..83aa2fa 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/TargetListsClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/TargetListsClass.java @@ -1,5 +1,6 @@ package io.atlasmap.qe.test; + public class TargetListsClass extends SourceListsClass { public TargetListsClass() { this.getStrings().clear(); @@ -7,5 +8,4 @@ public TargetListsClass() { this.getIntegers().clear(); this.getFloats().clear(); } - } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/TargetMappingTestClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/TargetMappingTestClass.java index 9ab53c2..fc311b0 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/TargetMappingTestClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/TargetMappingTestClass.java @@ -1,405 +1,35 @@ package io.atlasmap.qe.test; +import lombok.Data; + import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; -import java.text.NumberFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.Date; -import java.util.Objects; -import java.util.TimeZone; + /** - * Created by mmelko on 26/10/2017. + * Simple class that is used to verify mappings to Java objects. + * + * @author Ondřej Kuhejda **/ -public class TargetMappingTestClass implements MappingTestClassConverter, Serializable { - - private String targetString; - private String targetCombineString; - private int targetInteger; - private long targetLong; - private float targetFloat; - private double targetDouble; - private Date targetDate; - private String targetAnotherString; - private boolean targetBoolean; - private short targetShort; - private byte targetByte; - private char targetChar; - private BigInteger targetBigInteger; - private BigDecimal targetBigDecimal; - private SmallMappingTestClass targetSmallMappingTestClass; - private DatesObject dateObjectVariable; - private SimpleEnum targetEnum; - - public DatesObject getDateObjectVariable() { - return dateObjectVariable; - } - - public void setDateObjectVariable(DatesObject dateObjectVariable) { - this.dateObjectVariable = dateObjectVariable; - } - - public TargetMappingTestClass() { - this.targetString = "targetString"; - this.targetCombineString = "targetCombineString"; - this.targetInteger = 5; - this.targetLong = 4L; - this.targetFloat = 3f; - this.targetDouble = 2d; - this.targetDate = new Date(0); - this.targetAnotherString = "targetAnotherString"; - this.targetBoolean = false; - this.targetShort = 1; - this.targetByte = Byte.MIN_VALUE; - this.targetChar = 'x'; - this.targetEnum = SimpleEnum.VALUE2; - try { - this.dateObjectVariable = new DatesObject("01-01-1989"); - } catch (ParseException e) { - e.printStackTrace(); - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); - sdf.setTimeZone(TimeZone.getTimeZone("UTC")); - TargetMappingTestClass that = (TargetMappingTestClass) o; - return targetInteger == that.targetInteger && - targetLong == that.targetLong && - Float.compare(that.targetFloat, targetFloat) == 0 && - Double.compare(that.targetDouble, targetDouble) == 0 && - targetBoolean == that.targetBoolean && - targetShort == that.targetShort && - targetByte == that.targetByte && - targetChar == that.targetChar && - Objects.equals(targetString, that.targetString) && - Objects.equals(targetCombineString, that.targetCombineString) && - Objects.equals(sdf.format(targetDate), sdf.format(that.targetDate)) && - Objects.equals(targetAnotherString, that.targetAnotherString) && - Objects.equals(targetEnum, that.targetEnum) && - Objects.equals(targetSmallMappingTestClass, that.targetSmallMappingTestClass); - } - - @Override - public String toString() { - return "TargetMappingTestClass{" + - "targetString='" + targetString + '\'' + - "| targetCombineString='" + targetCombineString + '\'' + - "| targetInteger=" + targetInteger + - "| targetLong=" + targetLong + - "| targetFloat=" + targetFloat + - "| targetDouble=" + targetDouble + - "| targetDate=" + targetDate + - "| targetAnotherString='" + targetAnotherString + '\'' + - "| targetBoolean=" + targetBoolean + - "| targetShort=" + targetShort + - "| targetByte=" + targetByte + - "| targetChar=" + targetChar + - "| targetEnum=" + targetEnum + - "| targetMappingTestClass=" + targetSmallMappingTestClass + - '}'; - } - - @Override - public int hashCode() { - - return Objects.hash(targetString, targetCombineString, targetInteger, targetLong, targetFloat, targetDouble, targetDate, targetAnotherString, targetBoolean, targetShort, targetByte, targetChar); - } - - @Override - public void setAndConvertValue(String field, Object value) throws ParseException { - - switch (field) { - case "targetCombineString": { - this.setTargetCombineString(value.toString()); - break; - } - case "targetString": { - this.setTargetString(value.toString()); - break; - } - case "targetInteger": { - if (value instanceof Character) { - this.setTargetInteger(Integer.valueOf((Character) value)); - } else { - this.setTargetInteger(NumberFormat.getInstance().parse(value.toString()).intValue()); - } - break; - } - - case "targetBigDecimal": { - if (value instanceof Character) { - this.setTargetBigDecimal(BigDecimal.valueOf((Character) value)); - } else { - this.setTargetBigDecimal(new BigDecimal(value.toString())); - } - break; - } - case "targetLong": { - if (value instanceof Character) { - this.setTargetLong(Long.valueOf((Character) value)); - } else { - this.setTargetLong((NumberFormat.getInstance().parse(value.toString())).longValue()); - } - break; - } - case "targetFloat": { - if (value instanceof Character) { - this.setTargetFloat(Float.valueOf((Character) value)); - } else { - this.setTargetFloat((NumberFormat.getInstance().parse(value.toString())).floatValue()); - } - break; - } - case "targetDouble": { - if (value instanceof Character) { - this.setTargetDouble(Double.valueOf((Character) value)); - } else { - this.setTargetDouble((NumberFormat.getInstance().parse(value.toString())).doubleValue()); - } - break; - } - case "targetShort": { - if (value instanceof Character) { - this.setTargetShort((short) ((Character) value).charValue()); - } else { - this.setTargetShort((NumberFormat.getInstance().parse(value.toString())).shortValue()); - } - break; - } - case "targetByte": { - try { - this.setTargetByte((NumberFormat.getInstance().parse(value.toString()).byteValue())); - } catch (Exception e) { - this.setTargetChar(value.toString().toCharArray()[0]); - } - - break; - } - - case "targetChar": { - if (value instanceof Character) { - setTargetChar((Character) value); - } else { - try { - this.setTargetChar(Character.valueOf((char) NumberFormat.getInstance().parse(value.toString()).intValue())); - } catch (Exception e) { - this.setTargetChar(value.toString().toCharArray()[0]); - } - } - - break; - } - - case "targetBoolean": { - if (value instanceof Number) { - final int temp = ((Number) value).intValue(); - if (temp == 0) { - this.setTargetBoolean(false); - } else { - this.setTargetBoolean(true); - } - } else if (value instanceof Character) { - this.setTargetDouble(Double.valueOf((Character) value)); - } else { - this.setTargetBoolean(Boolean.parseBoolean(value.toString())); - } - break; - } - case "targetDate": { - if (value instanceof Date) { - this.setTargetDate((Date) value); - } else if (value instanceof Number) { - this.setTargetDate(new Date(((Number) value).longValue())); - } else { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh"); - format.setTimeZone(TimeZone.getTimeZone("UTC")); - this.setTargetDate(format.parse(value.toString())); - } - break; - } - case "targetAnotherString": { - this.setTargetAnotherString(value.toString()); - break; - } - case "targetEnum": { - this.setTargetEnum(SimpleEnum.valueOf(value.toString())); - break; - } - } - } - - @Override - public Object getValue(String field) { - switch (field) { - case "targetCombineString": - return getTargetCombineString(); - case "targetString": - return getTargetString(); - case "targetInteger": - return getTargetInteger(); - case "targetBigInteger": - return getTargetBigInteger(); - case "tagetBigDecimal": - return getTargetBigDecimal(); - case "targetLong": - return getTargetLong(); - case "targetFloat": - return getTargetFloat(); - case "targetDouble": - return getTargetDouble(); - case "targetDate": - return getTargetDate(); - case "targetShort": - return getTargetShort(); - case "targetByte": - return getTargetByte(); - case "targetChar": - return getTargetChar(); - case "targetBoolean": - return isTargetBoolean(); - case "targetAnotherString": - return getTargetAnotherString(); - case "targetEnum": - return getTargetEnum(); - } - return null; - } - - public String getTargetString() { - return targetString; - } - - public void setTargetString(String targetString) { - this.targetString = targetString; - } - - public String getTargetCombineString() { - return targetCombineString; - } - - public void setTargetCombineString(String targetCombineString) { - this.targetCombineString = targetCombineString; - } - - public int getTargetInteger() { - return targetInteger; - } - - public BigInteger getTargetBigInteger() { - return targetBigInteger; - } - - public void setTargetBigInteger(BigInteger targetBigInteger) { - this.targetBigInteger = targetBigInteger; - } - - public BigDecimal getTargetBigDecimal() { - return targetBigDecimal; - } - - public void setTargetBigDecimal(BigDecimal targetBigDecimal) { - this.targetBigDecimal = targetBigDecimal; - } - - public void setTargetInteger(int targetInteger) { - this.targetInteger = targetInteger; - } - - public long getTargetLong() { - return targetLong; - } - - public void setTargetLong(long targetLong) { - this.targetLong = targetLong; - } - - public float getTargetFloat() { - return targetFloat; - } - - public void setTargetFloat(float targetFloat) { - this.targetFloat = targetFloat; - } - - public double getTargetDouble() { - return targetDouble; - } - - public void setTargetDouble(double targetDouble) { - this.targetDouble = targetDouble; - } - - public Date getTargetDate() { - return targetDate; - } - - public void setTargetDate(Date targetDate) { - this.targetDate = targetDate; - } - - public String getTargetAnotherString() { - return targetAnotherString; - } - - public void setTargetAnotherString(String targetAnotherString) { - this.targetAnotherString = targetAnotherString; - } - - public boolean isTargetBoolean() { - return targetBoolean; - } - - public void setTargetBoolean(boolean targetBoolean) { - this.targetBoolean = targetBoolean; - } - - public short getTargetShort() { - return targetShort; - } - - public void setTargetShort(short targetShort) { - this.targetShort = targetShort; - } - - public byte getTargetByte() { - return targetByte; - } - - public void setTargetByte(byte targetByte) { - this.targetByte = targetByte; - } - - public char getTargetChar() { - return targetChar; - } - - public void setTargetChar(char targetChar) { - this.targetChar = targetChar; - } - - public SmallMappingTestClass getTargetSmallMappingTestClass() { - return targetSmallMappingTestClass; - } - - public void setTargetSmallMappingTestClass(SmallMappingTestClass targetSmallMappingTestClass) { - this.targetSmallMappingTestClass = targetSmallMappingTestClass; - } - - public SimpleEnum getTargetEnum() { - return targetEnum; - } - - public void setTargetEnum(SimpleEnum targetEnum) { - this.targetEnum = targetEnum; - } +@Data +public class TargetMappingTestClass implements Serializable { + private String targetString = "targetString";; + private String targetCombineString = "targetCombineString"; + private int targetInteger = 5; + private long targetLong = 4L; + private float targetFloat = 3f; + private double targetDouble = 2d; + private Date targetDate = new Date(0); + private String targetAnotherString = "targetAnotherString"; + private boolean targetBoolean = false; + private short targetShort = 1; + private byte targetByte = Byte.MIN_VALUE; + private char targetChar = 'x'; + private BigInteger targetBigInteger = new BigInteger("0"); + private BigDecimal targetBigDecimal = new BigDecimal("0"); + private SmallMappingTestClass targetSmallMappingTestClass = new SmallMappingTestClass(); + private DatesObject dateObjectVariable = new DatesObject("01-01-1989"); + private SimpleEnum targetEnum = SimpleEnum.VALUE2; } diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/TargetNestedCollectionClass.java b/test-resources/src/main/java/io/atlasmap/qe/test/TargetNestedCollectionClass.java index 8fc2678..dee1804 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/TargetNestedCollectionClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/test/TargetNestedCollectionClass.java @@ -1,40 +1,39 @@ package io.atlasmap.qe.test; -public class TargetNestedCollectionClass extends BaseClass { +import lombok.ToString; + + +@ToString(callSuper=true) +public class TargetNestedCollectionClass extends NestedCollectionClass { public TargetNestedCollectionClass(String sourceType) { - NestedClass array0 = new BaseClass.NestedClass(sourceType + "FirstArrayValue0"); - NestedClass array1 = new BaseClass.NestedClass(sourceType + "FirstArrayValue1"); + NestedClass array0 = new NestedCollectionClass.NestedClass(sourceType + "FirstArrayValue0"); + NestedClass array1 = new NestedCollectionClass.NestedClass(sourceType + "FirstArrayValue1"); - BaseClass.NestedClass[] someArray = new BaseClass.NestedClass[] { + NestedCollectionClass.NestedClass[] someArray = new NestedCollectionClass.NestedClass[] { array0, array1 }; setRootArray(someArray); - BaseClass.NestedClass array00 = new BaseClass.NestedClass(sourceType + "SecondArrayValue0-0"); - BaseClass.NestedClass array01 = new BaseClass.NestedClass(sourceType + "SecondArrayValue0-1"); + NestedCollectionClass.NestedClass array00 = new NestedCollectionClass.NestedClass(sourceType + "SecondArrayValue0-0"); + NestedCollectionClass.NestedClass array01 = new NestedCollectionClass.NestedClass(sourceType + "SecondArrayValue0-1"); - array00.setNestedArray(new BaseClass.NestedClass[] {new BaseClass.NestedClass(sourceType + "ThirdArrayValue0-0-0"), - new BaseClass.NestedClass(sourceType + "ThirdArrayValue0-0-1")}); - array01.setNestedArray(new BaseClass.NestedClass[] {new BaseClass.NestedClass(sourceType + "ThirdArrayValue0-1-0"), - new BaseClass.NestedClass(sourceType + "ThirdArrayValue0-1-1"), new BaseClass.NestedClass(sourceType + "ThirdArrayValue0-1-2")}); + array00.setNestedArray(new NestedCollectionClass.NestedClass[] {new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue0-0-0"), + new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue0-0-1")}); + array01.setNestedArray(new NestedCollectionClass.NestedClass[] {new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue0-1-0"), + new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue0-1-1"), new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue0-1-2")}); - array0.setNestedArray(new BaseClass.NestedClass[] {array00, array01}); + array0.setNestedArray(new NestedCollectionClass.NestedClass[] {array00, array01}); - BaseClass.NestedClass array10 = new BaseClass.NestedClass(sourceType + "SecondArrayValue1-0"); - BaseClass.NestedClass array11 = new BaseClass.NestedClass(sourceType + "SecondArrayValue1-1"); - array10.setNestedArray(new BaseClass.NestedClass[] {new BaseClass.NestedClass(sourceType + "ThirdArrayValue1-0-0"), - new BaseClass.NestedClass(sourceType + "ThirdArrayValue1-0-1"), new BaseClass.NestedClass(sourceType + "ThirdArrayValue1-0-2")}); - array11.setNestedArray(new BaseClass.NestedClass[] {new BaseClass.NestedClass(sourceType + "ThirdArrayValue1-1-0"), - new BaseClass.NestedClass(sourceType + "ThirdArrayValue1-1-1")}); - array1.setNestedArray(new BaseClass.NestedClass[] {array10, array11}); + NestedCollectionClass.NestedClass array10 = new NestedCollectionClass.NestedClass(sourceType + "SecondArrayValue1-0"); + NestedCollectionClass.NestedClass array11 = new NestedCollectionClass.NestedClass(sourceType + "SecondArrayValue1-1"); + array10.setNestedArray(new NestedCollectionClass.NestedClass[] {new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue1-0-0"), + new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue1-0-1"), new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue1-0-2")}); + array11.setNestedArray(new NestedCollectionClass.NestedClass[] {new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue1-1-0"), + new NestedCollectionClass.NestedClass(sourceType + "ThirdArrayValue1-1-1")}); + array1.setNestedArray(new NestedCollectionClass.NestedClass[] {array10, array11}); } public TargetNestedCollectionClass() { } - - @Override - public String toString() { - return "TargetNestedCollectionClass{} " + super.toString(); - } } From 93504e7e3e2665c02d5bb2b796767071ab1b7f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Tue, 13 Apr 2021 23:31:16 +0200 Subject: [PATCH 17/22] Rename packages and enable test classes programmatically --- .gitignore | 3 +- .../qe/test/{atlas => }/AtlasmapInit.java | 6 +- .../qe/test/{atlas => }/AtlasmapPage.java | 10 +- .../{atlas => }/CucumberSpringConfig.java | 4 +- .../qe/test/{atlas => }/CucumberTest.java | 4 +- .../{atlas => }/CustomWebDriverProvider.java | 4 +- .../test/{atlas => }/hooks/UITestHooks.java | 4 +- .../test/{atlas => }/steps/BackendSteps.java | 14 ++- .../test/{atlas => }/steps/ComplexSteps.java | 10 +- .../steps/TransformationSteps.java | 6 +- .../qe/test/{atlas => }/steps/UISteps.java | 12 +- .../qe/test/{atlas => }/utils/ByUtils.java | 2 +- .../test/{atlas => }/utils/HoverAction.java | 2 +- .../test/{atlas => }/utils/MailFormatter.java | 2 +- .../test/{atlas => }/utils/MappingUtils.java | 2 +- .../{atlas => }/utils/TestConfiguration.java | 2 +- mapping-validator/pom.xml | 2 +- .../qe/{test => mapper}/AtlasMapper.java | 2 +- .../qe/{test => mapper}/MappingValidator.java | 10 +- .../ValidatorSpringConfig.java | 10 +- .../CharacterToBooleanConverter.java | 2 +- .../converter/NumberToBooleanConverter.java | 2 +- .../converter/NumberToDateConverter.java | 2 +- .../converter/StringToDateConverter.java | 2 +- .../src/main/resources/combine.xml | 12 +- .../MappingValidatorTest.java | 6 +- .../resources/fromDateObjectToDateObject.json | 114 +++++++++--------- .../src/test/resources/javaToJava.json | 82 ++++++------- .../src/test/resources/jsonToJava.json | 82 ++++++------- .../src/test/resources/jsonToXml.json | 74 ++++++------ .../src/test/resources/xmlSchemaToJava.json | 82 ++++++------- .../src/test/resources/xmlToJson.json | 74 ++++++------ pom.xml | 4 +- .../qe/{test => data}/DatesObject.java | 2 +- .../{test => data}/NestedCollectionClass.java | 2 +- .../ResourcesGenerator.java | 4 +- .../qe/{test => data}/SimpleEnum.java | 2 +- .../{test => data}/SmallMappingTestClass.java | 2 +- .../qe/{test => data}/StringObject.java | 2 +- .../source}/SourceListsClass.java | 3 +- .../source}/SourceMappingTestClass.java | 4 +- .../source}/SourceNestedCollectionClass.java | 3 +- .../target}/TargetListsClass.java | 4 +- .../target}/TargetMappingTestClass.java | 5 +- .../target}/TargetNestedCollectionClass.java | 3 +- 45 files changed, 356 insertions(+), 329 deletions(-) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/AtlasmapInit.java (97%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/AtlasmapPage.java (99%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/CucumberSpringConfig.java (82%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/CucumberTest.java (89%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/CustomWebDriverProvider.java (98%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/hooks/UITestHooks.java (92%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/steps/BackendSteps.java (98%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/steps/ComplexSteps.java (93%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/steps/TransformationSteps.java (97%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/steps/UISteps.java (98%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/utils/ByUtils.java (90%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/utils/HoverAction.java (93%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/utils/MailFormatter.java (99%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/utils/MappingUtils.java (99%) rename datamapper-e2e/src/test/java/io/atlasmap/qe/test/{atlas => }/utils/TestConfiguration.java (99%) rename mapping-validator/src/main/java/io/atlasmap/qe/{test => mapper}/AtlasMapper.java (99%) rename mapping-validator/src/main/java/io/atlasmap/qe/{test => mapper}/MappingValidator.java (96%) rename mapping-validator/src/main/java/io/atlasmap/qe/{test => mapper}/ValidatorSpringConfig.java (82%) rename mapping-validator/src/main/java/io/atlasmap/qe/{test => mapper}/converter/CharacterToBooleanConverter.java (88%) rename mapping-validator/src/main/java/io/atlasmap/qe/{test => mapper}/converter/NumberToBooleanConverter.java (88%) rename mapping-validator/src/main/java/io/atlasmap/qe/{test => mapper}/converter/NumberToDateConverter.java (88%) rename mapping-validator/src/main/java/io/atlasmap/qe/{test => mapper}/converter/StringToDateConverter.java (93%) rename mapping-validator/src/test/java/io/atlasmap/qe/{test => mapper}/MappingValidatorTest.java (97%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data}/DatesObject.java (98%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data}/NestedCollectionClass.java (94%) rename test-resources/src/main/java/io/atlasmap/qe/{resources => data}/ResourcesGenerator.java (99%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data}/SimpleEnum.java (66%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data}/SmallMappingTestClass.java (97%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data}/StringObject.java (94%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data/source}/SourceListsClass.java (94%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data/source}/SourceMappingTestClass.java (90%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data/source}/SourceNestedCollectionClass.java (96%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data/target}/TargetListsClass.java (72%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data/target}/TargetMappingTestClass.java (87%) rename test-resources/src/main/java/io/atlasmap/qe/{test => data/target}/TargetNestedCollectionClass.java (96%) diff --git a/.gitignore b/.gitignore index 378e33d..daa3b25 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ **/build/ -**/target/ +/target/ +/*/target/ **/node **/*.DS_Store **/*.iml diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java similarity index 97% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java index 6df7224..4d0466b 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapInit.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.atlas; +package io.atlasmap.qe.test; import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.TrueFileFilter; @@ -11,8 +11,8 @@ import java.util.Optional; import java.util.function.Consumer; -import io.atlasmap.qe.test.atlas.utils.TestConfiguration; -import io.atlasmap.qe.test.atlas.utils.MappingUtils; +import io.atlasmap.qe.test.utils.TestConfiguration; +import io.atlasmap.qe.test.utils.MappingUtils; import io.cucumber.plugin.EventListener; import io.cucumber.plugin.event.EventHandler; import io.cucumber.plugin.event.EventPublisher; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java similarity index 99% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java index 1697c2f..3f1f2e8 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.atlas; +package io.atlasmap.qe.test; import static com.codeborne.selenide.Selenide.sleep; import static org.assertj.core.api.Assertions.assertThat; @@ -29,10 +29,10 @@ import java.util.WeakHashMap; import java.util.stream.Collectors; -import io.atlasmap.qe.test.atlas.utils.ByUtils; -import io.atlasmap.qe.test.atlas.utils.HoverAction; -import io.atlasmap.qe.test.atlas.utils.TestConfiguration; -import io.atlasmap.qe.test.atlas.utils.MappingUtils; +import io.atlasmap.qe.test.utils.ByUtils; +import io.atlasmap.qe.test.utils.HoverAction; +import io.atlasmap.qe.test.utils.TestConfiguration; +import io.atlasmap.qe.test.utils.MappingUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.openqa.selenium.WebDriver; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberSpringConfig.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/CucumberSpringConfig.java similarity index 82% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberSpringConfig.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/CucumberSpringConfig.java index 1ba89ef..42699e6 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberSpringConfig.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/CucumberSpringConfig.java @@ -1,6 +1,6 @@ -package io.atlasmap.qe.test.atlas; +package io.atlasmap.qe.test; -import io.atlasmap.qe.test.ValidatorSpringConfig; +import io.atlasmap.qe.mapper.ValidatorSpringConfig; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.ContextConfiguration; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberTest.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/CucumberTest.java similarity index 89% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberTest.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/CucumberTest.java index 3ae46d7..aa3e0f1 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CucumberTest.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/CucumberTest.java @@ -1,12 +1,12 @@ -package io.atlasmap.qe.test.atlas; +package io.atlasmap.qe.test; +import io.atlasmap.qe.test.utils.TestConfiguration; import org.junit.BeforeClass; import org.junit.runner.RunWith; import com.codeborne.selenide.Configuration; import com.codeborne.selenide.Selenide; -import io.atlasmap.qe.test.atlas.utils.TestConfiguration; import io.cucumber.junit.Cucumber; @RunWith(Cucumber.class) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CustomWebDriverProvider.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/CustomWebDriverProvider.java similarity index 98% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CustomWebDriverProvider.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/CustomWebDriverProvider.java index c4854e0..ad7cbcc 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/CustomWebDriverProvider.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/CustomWebDriverProvider.java @@ -1,5 +1,6 @@ -package io.atlasmap.qe.test.atlas; +package io.atlasmap.qe.test; +import io.atlasmap.qe.test.utils.TestConfiguration; import org.apache.commons.io.FileUtils; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; @@ -16,7 +17,6 @@ import java.util.Hashtable; import java.util.Map; -import io.atlasmap.qe.test.atlas.utils.TestConfiguration; import io.github.bonigarcia.wdm.WebDriverManager; import lombok.extern.slf4j.Slf4j; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/hooks/UITestHooks.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/hooks/UITestHooks.java similarity index 92% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/hooks/UITestHooks.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/hooks/UITestHooks.java index 2fcaf50..abe4b2e 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/hooks/UITestHooks.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/hooks/UITestHooks.java @@ -1,5 +1,6 @@ -package io.atlasmap.qe.test.atlas.hooks; +package io.atlasmap.qe.test.hooks; +import io.atlasmap.qe.test.utils.TestConfiguration; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.logging.LogEntry; @@ -9,7 +10,6 @@ import java.util.stream.Collectors; -import io.atlasmap.qe.test.atlas.utils.TestConfiguration; import io.cucumber.java.AfterStep; import io.cucumber.java.Scenario; import lombok.extern.slf4j.Slf4j; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/BackendSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java similarity index 98% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/BackendSteps.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java index 1088f82..3c8a522 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/BackendSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java @@ -1,9 +1,17 @@ -package io.atlasmap.qe.test.atlas.steps; +package io.atlasmap.qe.test.steps; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import io.atlasmap.qe.test.*; +import io.atlasmap.qe.data.*; +import io.atlasmap.qe.data.source.SourceListsClass; +import io.atlasmap.qe.data.source.SourceNestedCollectionClass; +import io.atlasmap.qe.data.target.TargetListsClass; +import io.atlasmap.qe.data.target.TargetMappingTestClass; +import io.atlasmap.qe.data.target.TargetNestedCollectionClass; +import io.atlasmap.qe.mapper.MappingValidator; +import io.atlasmap.qe.data.ResourcesGenerator; +import io.atlasmap.qe.test.utils.MappingUtils; import org.junit.Assert; import org.openqa.selenium.NotFoundException; @@ -13,8 +21,6 @@ import java.util.List; import java.util.Map; -import io.atlasmap.qe.resources.ResourcesGenerator; -import io.atlasmap.qe.test.atlas.utils.MappingUtils; import io.cucumber.datatable.DataTable; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/ComplexSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/ComplexSteps.java similarity index 93% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/ComplexSteps.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/ComplexSteps.java index 82bb830..3e59bcd 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/ComplexSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/ComplexSteps.java @@ -1,12 +1,12 @@ -package io.atlasmap.qe.test.atlas.steps; +package io.atlasmap.qe.test.steps; -import io.atlasmap.qe.test.MappingValidator; +import io.atlasmap.qe.mapper.MappingValidator; +import io.atlasmap.qe.data.target.TargetMappingTestClass; +import io.atlasmap.qe.test.utils.HoverAction; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; -import io.atlasmap.qe.test.TargetMappingTestClass; -import io.atlasmap.qe.test.atlas.AtlasmapPage; -import io.atlasmap.qe.test.atlas.utils.HoverAction; +import io.atlasmap.qe.test.AtlasmapPage; import io.cucumber.java.en.And; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/TransformationSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/TransformationSteps.java similarity index 97% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/TransformationSteps.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/TransformationSteps.java index 52b9d27..7ef9af8 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/TransformationSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/TransformationSteps.java @@ -1,10 +1,10 @@ -package io.atlasmap.qe.test.atlas.steps; +package io.atlasmap.qe.test.steps; +import io.atlasmap.qe.test.utils.MappingUtils; import lombok.extern.slf4j.Slf4j; import org.junit.Assert; -import io.atlasmap.qe.test.atlas.AtlasmapPage; -import io.atlasmap.qe.test.atlas.utils.MappingUtils; +import io.atlasmap.qe.test.AtlasmapPage; import io.cucumber.java.en.And; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java similarity index 98% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java index e510501..000fb4a 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/steps/UISteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java @@ -1,17 +1,17 @@ -package io.atlasmap.qe.test.atlas.steps; +package io.atlasmap.qe.test.steps; import static org.assertj.core.api.Assertions.assertThat; -import io.atlasmap.qe.test.MappingValidator; -import io.atlasmap.qe.test.atlas.AtlasmapInit; +import io.atlasmap.qe.mapper.MappingValidator; +import io.atlasmap.qe.test.AtlasmapInit; +import io.atlasmap.qe.test.utils.HoverAction; +import io.atlasmap.qe.test.utils.MappingUtils; import org.junit.Assert; import java.util.*; import java.util.function.Consumer; -import io.atlasmap.qe.test.atlas.AtlasmapPage; -import io.atlasmap.qe.test.atlas.utils.HoverAction; -import io.atlasmap.qe.test.atlas.utils.MappingUtils; +import io.atlasmap.qe.test.AtlasmapPage; import io.cucumber.datatable.DataTable; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/ByUtils.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/ByUtils.java similarity index 90% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/ByUtils.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/ByUtils.java index c9e402b..beabd3e 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/ByUtils.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/ByUtils.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.atlas.utils; +package io.atlasmap.qe.test.utils; import org.openqa.selenium.By; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/HoverAction.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/HoverAction.java similarity index 93% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/HoverAction.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/HoverAction.java index 4a08f04..cac52fa 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/HoverAction.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/HoverAction.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.atlas.utils; +package io.atlasmap.qe.test.utils; public enum HoverAction { diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MailFormatter.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MailFormatter.java similarity index 99% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MailFormatter.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MailFormatter.java index 8f19597..a59ab11 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MailFormatter.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MailFormatter.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.atlas.utils; +package io.atlasmap.qe.test.utils; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MappingUtils.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MappingUtils.java similarity index 99% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MappingUtils.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MappingUtils.java index a844659..7392b38 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/MappingUtils.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MappingUtils.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.atlas.utils; +package io.atlasmap.qe.test.utils; import static com.codeborne.selenide.Condition.visible; diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/TestConfiguration.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/TestConfiguration.java similarity index 99% rename from datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/TestConfiguration.java rename to datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/TestConfiguration.java index 49b40bd..5e0abce 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/atlas/utils/TestConfiguration.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/TestConfiguration.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.atlas.utils; +package io.atlasmap.qe.test.utils; import java.io.IOException; import java.io.InputStream; diff --git a/mapping-validator/pom.xml b/mapping-validator/pom.xml index 5d17dbd..ca7db08 100644 --- a/mapping-validator/pom.xml +++ b/mapping-validator/pom.xml @@ -33,7 +33,7 @@ - io.atlasmap.qe.test.MappingValidator + io.atlasmap.qe.mapper.MappingValidator diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/AtlasMapper.java similarity index 99% rename from mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java rename to mapping-validator/src/main/java/io/atlasmap/qe/mapper/AtlasMapper.java index de14b59..ee7c85a 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/AtlasMapper.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/AtlasMapper.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.mapper; import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java similarity index 96% rename from mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java rename to mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java index f43f6e3..760cd10 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/MappingValidator.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java @@ -1,6 +1,13 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.mapper; import static org.assertj.core.api.Assertions.assertThat; + +import io.atlasmap.qe.data.*; +import io.atlasmap.qe.data.source.SourceListsClass; +import io.atlasmap.qe.data.source.SourceMappingTestClass; +import io.atlasmap.qe.data.source.SourceNestedCollectionClass; +import io.atlasmap.qe.data.target.TargetMappingTestClass; +import io.atlasmap.qe.data.ResourcesGenerator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -10,7 +17,6 @@ import java.util.Objects; import java.util.stream.Stream; -import io.atlasmap.qe.resources.ResourcesGenerator; import org.springframework.beans.BeanWrapper; import org.springframework.beans.PropertyAccessorFactory; import org.springframework.core.convert.ConversionService; diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/ValidatorSpringConfig.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/ValidatorSpringConfig.java similarity index 82% rename from mapping-validator/src/main/java/io/atlasmap/qe/test/ValidatorSpringConfig.java rename to mapping-validator/src/main/java/io/atlasmap/qe/mapper/ValidatorSpringConfig.java index adee6a0..913b484 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/ValidatorSpringConfig.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/ValidatorSpringConfig.java @@ -1,9 +1,9 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.mapper; -import io.atlasmap.qe.test.converter.CharacterToBooleanConverter; -import io.atlasmap.qe.test.converter.NumberToBooleanConverter; -import io.atlasmap.qe.test.converter.NumberToDateConverter; -import io.atlasmap.qe.test.converter.StringToDateConverter; +import io.atlasmap.qe.mapper.converter.NumberToBooleanConverter; +import io.atlasmap.qe.mapper.converter.CharacterToBooleanConverter; +import io.atlasmap.qe.mapper.converter.NumberToDateConverter; +import io.atlasmap.qe.mapper.converter.StringToDateConverter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/CharacterToBooleanConverter.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/CharacterToBooleanConverter.java similarity index 88% rename from mapping-validator/src/main/java/io/atlasmap/qe/test/converter/CharacterToBooleanConverter.java rename to mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/CharacterToBooleanConverter.java index 640ef8a..e3d403d 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/CharacterToBooleanConverter.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/CharacterToBooleanConverter.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.converter; +package io.atlasmap.qe.mapper.converter; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Component; diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToBooleanConverter.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/NumberToBooleanConverter.java similarity index 88% rename from mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToBooleanConverter.java rename to mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/NumberToBooleanConverter.java index b9285dd..17b723e 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToBooleanConverter.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/NumberToBooleanConverter.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.converter; +package io.atlasmap.qe.mapper.converter; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Component; diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToDateConverter.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/NumberToDateConverter.java similarity index 88% rename from mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToDateConverter.java rename to mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/NumberToDateConverter.java index 2c6586f..e963126 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/NumberToDateConverter.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/NumberToDateConverter.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.converter; +package io.atlasmap.qe.mapper.converter; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Component; diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/StringToDateConverter.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/StringToDateConverter.java similarity index 93% rename from mapping-validator/src/main/java/io/atlasmap/qe/test/converter/StringToDateConverter.java rename to mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/StringToDateConverter.java index cef762a..e79a475 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/test/converter/StringToDateConverter.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/converter/StringToDateConverter.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test.converter; +package io.atlasmap.qe.mapper.converter; import lombok.SneakyThrows; import org.springframework.core.convert.converter.Converter; diff --git a/mapping-validator/src/main/resources/combine.xml b/mapping-validator/src/main/resources/combine.xml index 7849b62..b411f7a 100644 --- a/mapping-validator/src/main/resources/combine.xml +++ b/mapping-validator/src/main/resources/combine.xml @@ -1,13 +1,13 @@ - - + + - - - - + + + + diff --git a/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java b/mapping-validator/src/test/java/io/atlasmap/qe/mapper/MappingValidatorTest.java similarity index 97% rename from mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java rename to mapping-validator/src/test/java/io/atlasmap/qe/mapper/MappingValidatorTest.java index 73da849..b01a722 100644 --- a/mapping-validator/src/test/java/io/atlasmap/qe/test/MappingValidatorTest.java +++ b/mapping-validator/src/test/java/io/atlasmap/qe/mapper/MappingValidatorTest.java @@ -1,5 +1,9 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.mapper; +import io.atlasmap.qe.data.DatesObject; +import io.atlasmap.qe.data.SimpleEnum; +import io.atlasmap.qe.data.SmallMappingTestClass; +import io.atlasmap.qe.data.target.TargetMappingTestClass; import lombok.extern.slf4j.Slf4j; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; diff --git a/mapping-validator/src/test/resources/fromDateObjectToDateObject.json b/mapping-validator/src/test/resources/fromDateObjectToDateObject.json index 98431e9..0b39936 100644 --- a/mapping-validator/src/test/resources/fromDateObjectToDateObject.json +++ b/mapping-validator/src/test/resources/fromDateObjectToDateObject.json @@ -3,38 +3,38 @@ "jsonType" : "io.atlasmap.v2.AtlasMapping", "dataSource" : [ { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceMappingTestClass", - "name" : "io.atlasmap.qe.test.SourceMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "id" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "name" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceMappingTestClass?className=io.atlasmap.qe.data.source.SourceMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.DatesObject", - "name" : "io.atlasmap.qe.test.DatesObject", - "description" : "Java document class io.atlasmap.qe.test.DatesObject", - "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "id" : "io.atlasmap.qe.data.DatesObject", + "name" : "io.atlasmap.qe.data.DatesObject", + "description" : "Java document class io.atlasmap.qe.data.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.data.DatesObject?className=io.atlasmap.qe.data.DatesObject", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceListsClass", - "name" : "io.atlasmap.qe.test.SourceListsClass", - "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "id" : "io.atlasmap.qe.data.source.SourceListsClass", + "name" : "io.atlasmap.qe.data.source.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceListsClass?className=io.atlasmap.qe.data.source.SourceListsClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SmallMappingTestClass", - "name" : "io.atlasmap.qe.test.SmallMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "id" : "io.atlasmap.qe.data.SmallMappingTestClass", + "name" : "io.atlasmap.qe.data.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.SmallMappingTestClass?className=io.atlasmap.qe.data.SmallMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "id" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceNestedCollectionClass?className=io.atlasmap.qe.data.source.SourceNestedCollectionClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -86,31 +86,31 @@ "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetMappingTestClass", - "name" : "io.atlasmap.qe.test.TargetMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "id" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "name" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetMappingTestClass?className=io.atlasmap.qe.data.target.TargetMappingTestClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.StringObject", - "name" : "io.atlasmap.qe.test.StringObject", - "description" : "Java document class io.atlasmap.qe.test.StringObject", - "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "id" : "io.atlasmap.qe.data.StringObject", + "name" : "io.atlasmap.qe.data.StringObject", + "description" : "Java document class io.atlasmap.qe.data.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.data.StringObject?className=io.atlasmap.qe.data.StringObject", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetListsClass", - "name" : "io.atlasmap.qe.test.TargetListsClass", - "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "id" : "io.atlasmap.qe.data.target.TargetListsClass", + "name" : "io.atlasmap.qe.data.target.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetListsClass?className=io.atlasmap.qe.data.target.TargetListsClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "id" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetNestedCollectionClass?className=io.atlasmap.qe.data.target.TargetNestedCollectionClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -166,7 +166,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -174,7 +174,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/standardJavaDate", "fieldType" : "DATE_TIME", "name" : "standardJavaDate", @@ -185,7 +185,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -193,7 +193,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/sqlDate", "fieldType" : "DATE", "name" : "sqlDate", @@ -204,7 +204,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -212,7 +212,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/localDate", "fieldType" : "DATE", "name" : "localDate", @@ -223,7 +223,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -231,7 +231,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/localDateTime", "fieldType" : "DATE_TIME", "name" : "localDateTime", @@ -242,7 +242,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -250,7 +250,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/localTime", "fieldType" : "TIME", "name" : "localTime", @@ -261,7 +261,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -269,7 +269,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/time", "fieldType" : "TIME", "name" : "time", @@ -280,7 +280,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -288,7 +288,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/timestamp", "fieldType" : "DATE_TIME", "name" : "timestamp", @@ -299,7 +299,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -307,7 +307,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/zonedDateTime", "fieldType" : "DATE_TIME_TZ", "name" : "zonedDateTime", @@ -318,7 +318,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -326,7 +326,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -337,7 +337,7 @@ "jsonType" : "io.atlasmap.v2.Mapping", "inputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.DatesObject", + "docId" : "io.atlasmap.qe.data.DatesObject", "path" : "/calendar", "fieldType" : "DATE_TIME_TZ", "name" : "calendar", @@ -345,7 +345,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/dateObjectVariable/gregorianCalendar", "fieldType" : "DATE_TIME_TZ", "name" : "gregorianCalendar", @@ -365,4 +365,4 @@ }, "name" : "UI.0" } -} \ No newline at end of file +} diff --git a/mapping-validator/src/test/resources/javaToJava.json b/mapping-validator/src/test/resources/javaToJava.json index 33aff01..f98eaf5 100644 --- a/mapping-validator/src/test/resources/javaToJava.json +++ b/mapping-validator/src/test/resources/javaToJava.json @@ -3,38 +3,38 @@ "jsonType" : "io.atlasmap.v2.AtlasMapping", "dataSource" : [ { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceMappingTestClass", - "name" : "io.atlasmap.qe.test.SourceMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "id" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "name" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceMappingTestClass?className=io.atlasmap.qe.data.source.SourceMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.DatesObject", - "name" : "io.atlasmap.qe.test.DatesObject", - "description" : "Java document class io.atlasmap.qe.test.DatesObject", - "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "id" : "io.atlasmap.qe.data.DatesObject", + "name" : "io.atlasmap.qe.data.DatesObject", + "description" : "Java document class io.atlasmap.qe.data.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.data.DatesObject?className=io.atlasmap.qe.data.DatesObject", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceListsClass", - "name" : "io.atlasmap.qe.test.SourceListsClass", - "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "id" : "io.atlasmap.qe.data.source.SourceListsClass", + "name" : "io.atlasmap.qe.data.source.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceListsClass?className=io.atlasmap.qe.data.source.SourceListsClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SmallMappingTestClass", - "name" : "io.atlasmap.qe.test.SmallMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "id" : "io.atlasmap.qe.data.SmallMappingTestClass", + "name" : "io.atlasmap.qe.data.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.SmallMappingTestClass?className=io.atlasmap.qe.data.SmallMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "id" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceNestedCollectionClass?className=io.atlasmap.qe.data.source.SourceNestedCollectionClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -86,31 +86,31 @@ "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetMappingTestClass", - "name" : "io.atlasmap.qe.test.TargetMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "id" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "name" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetMappingTestClass?className=io.atlasmap.qe.data.target.TargetMappingTestClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.StringObject", - "name" : "io.atlasmap.qe.test.StringObject", - "description" : "Java document class io.atlasmap.qe.test.StringObject", - "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "id" : "io.atlasmap.qe.data.StringObject", + "name" : "io.atlasmap.qe.data.StringObject", + "description" : "Java document class io.atlasmap.qe.data.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.data.StringObject?className=io.atlasmap.qe.data.StringObject", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetListsClass", - "name" : "io.atlasmap.qe.test.TargetListsClass", - "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "id" : "io.atlasmap.qe.data.target.TargetListsClass", + "name" : "io.atlasmap.qe.data.target.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetListsClass?className=io.atlasmap.qe.data.target.TargetListsClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "id" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetNestedCollectionClass?className=io.atlasmap.qe.data.target.TargetNestedCollectionClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -172,21 +172,21 @@ } ], "field" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.SourceMappingTestClass", + "docId" : "io.atlasmap.qe.data.source.SourceMappingTestClass", "index" : 0, "path" : "/sourceString", "fieldType" : "STRING", "name" : "sourceString" }, { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.SourceMappingTestClass", + "docId" : "io.atlasmap.qe.data.source.SourceMappingTestClass", "index" : 1, "path" : "/sourceAnotherString", "fieldType" : "STRING", "name" : "sourceAnotherString" }, { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.SourceMappingTestClass", + "docId" : "io.atlasmap.qe.data.source.SourceMappingTestClass", "index" : 2, "path" : "/sourceInteger", "fieldType" : "INTEGER", @@ -196,7 +196,7 @@ "inputField" : [ ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetCombineString", "fieldType" : "STRING", "name" : "targetCombineString" @@ -215,4 +215,4 @@ }, "name" : "UI.0" } -} \ No newline at end of file +} diff --git a/mapping-validator/src/test/resources/jsonToJava.json b/mapping-validator/src/test/resources/jsonToJava.json index 5fb9e85..849b435 100644 --- a/mapping-validator/src/test/resources/jsonToJava.json +++ b/mapping-validator/src/test/resources/jsonToJava.json @@ -3,38 +3,38 @@ "jsonType" : "io.atlasmap.v2.AtlasMapping", "dataSource" : [ { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceMappingTestClass", - "name" : "io.atlasmap.qe.test.SourceMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "id" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "name" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceMappingTestClass?className=io.atlasmap.qe.data.source.SourceMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.DatesObject", - "name" : "io.atlasmap.qe.test.DatesObject", - "description" : "Java document class io.atlasmap.qe.test.DatesObject", - "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "id" : "io.atlasmap.qe.data.DatesObject", + "name" : "io.atlasmap.qe.data.DatesObject", + "description" : "Java document class io.atlasmap.qe.data.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.data.DatesObject?className=io.atlasmap.qe.data.DatesObject", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceListsClass", - "name" : "io.atlasmap.qe.test.SourceListsClass", - "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "id" : "io.atlasmap.qe.data.source.SourceListsClass", + "name" : "io.atlasmap.qe.data.source.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceListsClass?className=io.atlasmap.qe.data.source.SourceListsClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SmallMappingTestClass", - "name" : "io.atlasmap.qe.test.SmallMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "id" : "io.atlasmap.qe.data.SmallMappingTestClass", + "name" : "io.atlasmap.qe.data.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.SmallMappingTestClass?className=io.atlasmap.qe.data.SmallMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "id" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceNestedCollectionClass?className=io.atlasmap.qe.data.source.SourceNestedCollectionClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -86,31 +86,31 @@ "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetMappingTestClass", - "name" : "io.atlasmap.qe.test.TargetMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "id" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "name" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetMappingTestClass?className=io.atlasmap.qe.data.target.TargetMappingTestClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.StringObject", - "name" : "io.atlasmap.qe.test.StringObject", - "description" : "Java document class io.atlasmap.qe.test.StringObject", - "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "id" : "io.atlasmap.qe.data.StringObject", + "name" : "io.atlasmap.qe.data.StringObject", + "description" : "Java document class io.atlasmap.qe.data.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.data.StringObject?className=io.atlasmap.qe.data.StringObject", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetListsClass", - "name" : "io.atlasmap.qe.test.TargetListsClass", - "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "id" : "io.atlasmap.qe.data.target.TargetListsClass", + "name" : "io.atlasmap.qe.data.target.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetListsClass?className=io.atlasmap.qe.data.target.TargetListsClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "id" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetNestedCollectionClass?className=io.atlasmap.qe.data.target.TargetNestedCollectionClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -174,7 +174,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetInteger", "fieldType" : "INTEGER", "name" : "targetInteger" @@ -192,7 +192,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetString", "fieldType" : "STRING", "name" : "targetString" @@ -210,7 +210,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetDouble", "fieldType" : "DOUBLE", "name" : "targetDouble" @@ -228,7 +228,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetFloat", "fieldType" : "FLOAT", "name" : "targetFloat" @@ -247,4 +247,4 @@ }, "name" : "UI.0" } -} \ No newline at end of file +} diff --git a/mapping-validator/src/test/resources/jsonToXml.json b/mapping-validator/src/test/resources/jsonToXml.json index 2e468a7..9f42b6f 100644 --- a/mapping-validator/src/test/resources/jsonToXml.json +++ b/mapping-validator/src/test/resources/jsonToXml.json @@ -3,38 +3,38 @@ "jsonType" : "io.atlasmap.v2.AtlasMapping", "dataSource" : [ { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceMappingTestClass", - "name" : "io.atlasmap.qe.test.SourceMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "id" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "name" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceMappingTestClass?className=io.atlasmap.qe.data.source.SourceMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.DatesObject", - "name" : "io.atlasmap.qe.test.DatesObject", - "description" : "Java document class io.atlasmap.qe.test.DatesObject", - "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "id" : "io.atlasmap.qe.data.DatesObject", + "name" : "io.atlasmap.qe.data.DatesObject", + "description" : "Java document class io.atlasmap.qe.data.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.data.DatesObject?className=io.atlasmap.qe.data.DatesObject", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceListsClass", - "name" : "io.atlasmap.qe.test.SourceListsClass", - "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "id" : "io.atlasmap.qe.data.source.SourceListsClass", + "name" : "io.atlasmap.qe.data.source.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceListsClass?className=io.atlasmap.qe.data.source.SourceListsClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SmallMappingTestClass", - "name" : "io.atlasmap.qe.test.SmallMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "id" : "io.atlasmap.qe.data.SmallMappingTestClass", + "name" : "io.atlasmap.qe.data.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.SmallMappingTestClass?className=io.atlasmap.qe.data.SmallMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "id" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceNestedCollectionClass?className=io.atlasmap.qe.data.source.SourceNestedCollectionClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -86,31 +86,31 @@ "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetMappingTestClass", - "name" : "io.atlasmap.qe.test.TargetMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "id" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "name" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetMappingTestClass?className=io.atlasmap.qe.data.target.TargetMappingTestClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.StringObject", - "name" : "io.atlasmap.qe.test.StringObject", - "description" : "Java document class io.atlasmap.qe.test.StringObject", - "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "id" : "io.atlasmap.qe.data.StringObject", + "name" : "io.atlasmap.qe.data.StringObject", + "description" : "Java document class io.atlasmap.qe.data.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.data.StringObject?className=io.atlasmap.qe.data.StringObject", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetListsClass", - "name" : "io.atlasmap.qe.test.TargetListsClass", - "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "id" : "io.atlasmap.qe.data.target.TargetListsClass", + "name" : "io.atlasmap.qe.data.target.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetListsClass?className=io.atlasmap.qe.data.target.TargetListsClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "id" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetNestedCollectionClass?className=io.atlasmap.qe.data.target.TargetNestedCollectionClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -251,4 +251,4 @@ }, "name" : "UI.0" } -} \ No newline at end of file +} diff --git a/mapping-validator/src/test/resources/xmlSchemaToJava.json b/mapping-validator/src/test/resources/xmlSchemaToJava.json index 1c51e88..1833210 100644 --- a/mapping-validator/src/test/resources/xmlSchemaToJava.json +++ b/mapping-validator/src/test/resources/xmlSchemaToJava.json @@ -3,38 +3,38 @@ "jsonType" : "io.atlasmap.v2.AtlasMapping", "dataSource" : [ { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceMappingTestClass", - "name" : "io.atlasmap.qe.test.SourceMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "id" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "name" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceMappingTestClass?className=io.atlasmap.qe.data.source.SourceMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.DatesObject", - "name" : "io.atlasmap.qe.test.DatesObject", - "description" : "Java document class io.atlasmap.qe.test.DatesObject", - "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "id" : "io.atlasmap.qe.data.DatesObject", + "name" : "io.atlasmap.qe.data.DatesObject", + "description" : "Java document class io.atlasmap.qe.data.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.data.DatesObject?className=io.atlasmap.qe.data.DatesObject", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceListsClass", - "name" : "io.atlasmap.qe.test.SourceListsClass", - "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "id" : "io.atlasmap.qe.data.source.SourceListsClass", + "name" : "io.atlasmap.qe.data.source.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceListsClass?className=io.atlasmap.qe.data.source.SourceListsClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SmallMappingTestClass", - "name" : "io.atlasmap.qe.test.SmallMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "id" : "io.atlasmap.qe.data.SmallMappingTestClass", + "name" : "io.atlasmap.qe.data.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.SmallMappingTestClass?className=io.atlasmap.qe.data.SmallMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "id" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceNestedCollectionClass?className=io.atlasmap.qe.data.source.SourceNestedCollectionClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -86,31 +86,31 @@ "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetMappingTestClass", - "name" : "io.atlasmap.qe.test.TargetMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "id" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "name" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetMappingTestClass?className=io.atlasmap.qe.data.target.TargetMappingTestClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.StringObject", - "name" : "io.atlasmap.qe.test.StringObject", - "description" : "Java document class io.atlasmap.qe.test.StringObject", - "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "id" : "io.atlasmap.qe.data.StringObject", + "name" : "io.atlasmap.qe.data.StringObject", + "description" : "Java document class io.atlasmap.qe.data.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.data.StringObject?className=io.atlasmap.qe.data.StringObject", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetListsClass", - "name" : "io.atlasmap.qe.test.TargetListsClass", - "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "id" : "io.atlasmap.qe.data.target.TargetListsClass", + "name" : "io.atlasmap.qe.data.target.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetListsClass?className=io.atlasmap.qe.data.target.TargetListsClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "id" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetNestedCollectionClass?className=io.atlasmap.qe.data.target.TargetNestedCollectionClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -174,7 +174,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetInteger", "fieldType" : "INTEGER", "name" : "targetInteger" @@ -192,7 +192,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetString", "fieldType" : "STRING", "name" : "targetString" @@ -210,7 +210,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetDouble", "fieldType" : "DOUBLE", "name" : "targetDouble" @@ -228,7 +228,7 @@ } ], "outputField" : [ { "jsonType" : "io.atlasmap.java.v2.JavaField", - "docId" : "io.atlasmap.qe.test.TargetMappingTestClass", + "docId" : "io.atlasmap.qe.data.target.TargetMappingTestClass", "path" : "/targetFloat", "fieldType" : "FLOAT", "name" : "targetFloat" @@ -247,4 +247,4 @@ }, "name" : "UI.0" } -} \ No newline at end of file +} diff --git a/mapping-validator/src/test/resources/xmlToJson.json b/mapping-validator/src/test/resources/xmlToJson.json index b6707ba..0307d2b 100644 --- a/mapping-validator/src/test/resources/xmlToJson.json +++ b/mapping-validator/src/test/resources/xmlToJson.json @@ -3,38 +3,38 @@ "jsonType" : "io.atlasmap.v2.AtlasMapping", "dataSource" : [ { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceMappingTestClass", - "name" : "io.atlasmap.qe.test.SourceMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SourceMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceMappingTestClass?className=io.atlasmap.qe.test.SourceMappingTestClass", + "id" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "name" : "io.atlasmap.qe.data.source.SourceMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceMappingTestClass?className=io.atlasmap.qe.data.source.SourceMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.DatesObject", - "name" : "io.atlasmap.qe.test.DatesObject", - "description" : "Java document class io.atlasmap.qe.test.DatesObject", - "uri" : "atlas:java:io.atlasmap.qe.test.DatesObject?className=io.atlasmap.qe.test.DatesObject", + "id" : "io.atlasmap.qe.data.DatesObject", + "name" : "io.atlasmap.qe.data.DatesObject", + "description" : "Java document class io.atlasmap.qe.data.DatesObject", + "uri" : "atlas:java:io.atlasmap.qe.data.DatesObject?className=io.atlasmap.qe.data.DatesObject", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceListsClass", - "name" : "io.atlasmap.qe.test.SourceListsClass", - "description" : "Java document class io.atlasmap.qe.test.SourceListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceListsClass?className=io.atlasmap.qe.test.SourceListsClass", + "id" : "io.atlasmap.qe.data.source.SourceListsClass", + "name" : "io.atlasmap.qe.data.source.SourceListsClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceListsClass?className=io.atlasmap.qe.data.source.SourceListsClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SmallMappingTestClass", - "name" : "io.atlasmap.qe.test.SmallMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.SmallMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SmallMappingTestClass?className=io.atlasmap.qe.test.SmallMappingTestClass", + "id" : "io.atlasmap.qe.data.SmallMappingTestClass", + "name" : "io.atlasmap.qe.data.SmallMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.SmallMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.SmallMappingTestClass?className=io.atlasmap.qe.data.SmallMappingTestClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "name" : "io.atlasmap.qe.test.SourceNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.SourceNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.SourceNestedCollectionClass?className=io.atlasmap.qe.test.SourceNestedCollectionClass", + "id" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "name" : "io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.source.SourceNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.source.SourceNestedCollectionClass?className=io.atlasmap.qe.data.source.SourceNestedCollectionClass", "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -86,31 +86,31 @@ "dataSourceType" : "SOURCE" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetMappingTestClass", - "name" : "io.atlasmap.qe.test.TargetMappingTestClass", - "description" : "Java document class io.atlasmap.qe.test.TargetMappingTestClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetMappingTestClass?className=io.atlasmap.qe.test.TargetMappingTestClass", + "id" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "name" : "io.atlasmap.qe.data.target.TargetMappingTestClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetMappingTestClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetMappingTestClass?className=io.atlasmap.qe.data.target.TargetMappingTestClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.StringObject", - "name" : "io.atlasmap.qe.test.StringObject", - "description" : "Java document class io.atlasmap.qe.test.StringObject", - "uri" : "atlas:java:io.atlasmap.qe.test.StringObject?className=io.atlasmap.qe.test.StringObject", + "id" : "io.atlasmap.qe.data.StringObject", + "name" : "io.atlasmap.qe.data.StringObject", + "description" : "Java document class io.atlasmap.qe.data.StringObject", + "uri" : "atlas:java:io.atlasmap.qe.data.StringObject?className=io.atlasmap.qe.data.StringObject", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetListsClass", - "name" : "io.atlasmap.qe.test.TargetListsClass", - "description" : "Java document class io.atlasmap.qe.test.TargetListsClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetListsClass?className=io.atlasmap.qe.test.TargetListsClass", + "id" : "io.atlasmap.qe.data.target.TargetListsClass", + "name" : "io.atlasmap.qe.data.target.TargetListsClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetListsClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetListsClass?className=io.atlasmap.qe.data.target.TargetListsClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.v2.DataSource", - "id" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "name" : "io.atlasmap.qe.test.TargetNestedCollectionClass", - "description" : "Java document class io.atlasmap.qe.test.TargetNestedCollectionClass", - "uri" : "atlas:java:io.atlasmap.qe.test.TargetNestedCollectionClass?className=io.atlasmap.qe.test.TargetNestedCollectionClass", + "id" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "name" : "io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "description" : "Java document class io.atlasmap.qe.data.target.TargetNestedCollectionClass", + "uri" : "atlas:java:io.atlasmap.qe.data.target.TargetNestedCollectionClass?className=io.atlasmap.qe.data.target.TargetNestedCollectionClass", "dataSourceType" : "TARGET" }, { "jsonType" : "io.atlasmap.json.v2.JsonDataSource", @@ -251,4 +251,4 @@ }, "name" : "UI.0" } -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index 3de43a8..bfc54cd 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ - io.atlasmap.qe.test.atlas.CucumberTest + io.atlasmap.qe.test.CucumberTest classpath:features ${tags} @@ -161,7 +161,7 @@ pretty, junit:target/cucumber/cucumber-junit.xml, json:target/cucumber/cucumber-report.json, - io.atlasmap.qe.test.atlas.utils.MailFormatter:target/cucumber/cucumber-mail/ + io.atlasmap.qe.test.utils.MailFormatter:target/cucumber/cucumber-mail/ diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/DatesObject.java b/test-resources/src/main/java/io/atlasmap/qe/data/DatesObject.java similarity index 98% rename from test-resources/src/main/java/io/atlasmap/qe/test/DatesObject.java rename to test-resources/src/main/java/io/atlasmap/qe/data/DatesObject.java index f01f3eb..01d450e 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/DatesObject.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/DatesObject.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data; import lombok.Data; diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/NestedCollectionClass.java b/test-resources/src/main/java/io/atlasmap/qe/data/NestedCollectionClass.java similarity index 94% rename from test-resources/src/main/java/io/atlasmap/qe/test/NestedCollectionClass.java rename to test-resources/src/main/java/io/atlasmap/qe/data/NestedCollectionClass.java index 82b771f..f03a176 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/NestedCollectionClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/NestedCollectionClass.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data; import lombok.Data; diff --git a/test-resources/src/main/java/io/atlasmap/qe/resources/ResourcesGenerator.java b/test-resources/src/main/java/io/atlasmap/qe/data/ResourcesGenerator.java similarity index 99% rename from test-resources/src/main/java/io/atlasmap/qe/resources/ResourcesGenerator.java rename to test-resources/src/main/java/io/atlasmap/qe/data/ResourcesGenerator.java index e3316f2..d3015d9 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/resources/ResourcesGenerator.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/ResourcesGenerator.java @@ -1,11 +1,11 @@ -package io.atlasmap.qe.resources; +package io.atlasmap.qe.data; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import io.atlasmap.qe.test.StringObject; +// TODO: remove this class public class ResourcesGenerator { public static String getJsonInstance() { diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SimpleEnum.java b/test-resources/src/main/java/io/atlasmap/qe/data/SimpleEnum.java similarity index 66% rename from test-resources/src/main/java/io/atlasmap/qe/test/SimpleEnum.java rename to test-resources/src/main/java/io/atlasmap/qe/data/SimpleEnum.java index 4b30b95..0491de9 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SimpleEnum.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/SimpleEnum.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data; public enum SimpleEnum { diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SmallMappingTestClass.java b/test-resources/src/main/java/io/atlasmap/qe/data/SmallMappingTestClass.java similarity index 97% rename from test-resources/src/main/java/io/atlasmap/qe/test/SmallMappingTestClass.java rename to test-resources/src/main/java/io/atlasmap/qe/data/SmallMappingTestClass.java index 9e69ad9..78080d1 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SmallMappingTestClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/SmallMappingTestClass.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data; import lombok.Data; diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/StringObject.java b/test-resources/src/main/java/io/atlasmap/qe/data/StringObject.java similarity index 94% rename from test-resources/src/main/java/io/atlasmap/qe/test/StringObject.java rename to test-resources/src/main/java/io/atlasmap/qe/data/StringObject.java index b227aee..a0366a5 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/StringObject.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/StringObject.java @@ -1,4 +1,4 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data; import lombok.Data; diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SourceListsClass.java b/test-resources/src/main/java/io/atlasmap/qe/data/source/SourceListsClass.java similarity index 94% rename from test-resources/src/main/java/io/atlasmap/qe/test/SourceListsClass.java rename to test-resources/src/main/java/io/atlasmap/qe/data/source/SourceListsClass.java index c456086..41f7beb 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SourceListsClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/source/SourceListsClass.java @@ -1,6 +1,7 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data.source; +import io.atlasmap.qe.data.StringObject; import lombok.Data; import java.util.ArrayList; diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SourceMappingTestClass.java b/test-resources/src/main/java/io/atlasmap/qe/data/source/SourceMappingTestClass.java similarity index 90% rename from test-resources/src/main/java/io/atlasmap/qe/test/SourceMappingTestClass.java rename to test-resources/src/main/java/io/atlasmap/qe/data/source/SourceMappingTestClass.java index ba07aad..9ec9657 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SourceMappingTestClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/source/SourceMappingTestClass.java @@ -1,5 +1,7 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data.source; +import io.atlasmap.qe.data.SimpleEnum; +import io.atlasmap.qe.data.SmallMappingTestClass; import lombok.Data; import java.io.Serializable; diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/SourceNestedCollectionClass.java b/test-resources/src/main/java/io/atlasmap/qe/data/source/SourceNestedCollectionClass.java similarity index 96% rename from test-resources/src/main/java/io/atlasmap/qe/test/SourceNestedCollectionClass.java rename to test-resources/src/main/java/io/atlasmap/qe/data/source/SourceNestedCollectionClass.java index 58b5239..dd8c0ff 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/SourceNestedCollectionClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/source/SourceNestedCollectionClass.java @@ -1,5 +1,6 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data.source; +import io.atlasmap.qe.data.NestedCollectionClass; import lombok.ToString; diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/TargetListsClass.java b/test-resources/src/main/java/io/atlasmap/qe/data/target/TargetListsClass.java similarity index 72% rename from test-resources/src/main/java/io/atlasmap/qe/test/TargetListsClass.java rename to test-resources/src/main/java/io/atlasmap/qe/data/target/TargetListsClass.java index 83aa2fa..97da3d5 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/TargetListsClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/target/TargetListsClass.java @@ -1,6 +1,8 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data.target; +import io.atlasmap.qe.data.source.SourceListsClass; + public class TargetListsClass extends SourceListsClass { public TargetListsClass() { this.getStrings().clear(); diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/TargetMappingTestClass.java b/test-resources/src/main/java/io/atlasmap/qe/data/target/TargetMappingTestClass.java similarity index 87% rename from test-resources/src/main/java/io/atlasmap/qe/test/TargetMappingTestClass.java rename to test-resources/src/main/java/io/atlasmap/qe/data/target/TargetMappingTestClass.java index fc311b0..e9a85d5 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/TargetMappingTestClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/target/TargetMappingTestClass.java @@ -1,5 +1,8 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data.target; +import io.atlasmap.qe.data.DatesObject; +import io.atlasmap.qe.data.SimpleEnum; +import io.atlasmap.qe.data.SmallMappingTestClass; import lombok.Data; import java.io.Serializable; diff --git a/test-resources/src/main/java/io/atlasmap/qe/test/TargetNestedCollectionClass.java b/test-resources/src/main/java/io/atlasmap/qe/data/target/TargetNestedCollectionClass.java similarity index 96% rename from test-resources/src/main/java/io/atlasmap/qe/test/TargetNestedCollectionClass.java rename to test-resources/src/main/java/io/atlasmap/qe/data/target/TargetNestedCollectionClass.java index dee1804..bab0156 100644 --- a/test-resources/src/main/java/io/atlasmap/qe/test/TargetNestedCollectionClass.java +++ b/test-resources/src/main/java/io/atlasmap/qe/data/target/TargetNestedCollectionClass.java @@ -1,5 +1,6 @@ -package io.atlasmap.qe.test; +package io.atlasmap.qe.data.target; +import io.atlasmap.qe.data.NestedCollectionClass; import lombok.ToString; From 29a61940ebf4fc9476d71afdec87bd3669d236f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Tue, 27 Apr 2021 18:53:33 +0200 Subject: [PATCH 18/22] Refactor ResourceGenerator - move ResourceGenerator to datamapper-e2e module - load documents from files (instead of harcoded strings) - use dependency injection - move documents used for mapping to test-resources module - add JAR_RESOURCE_FOLDER and DOCUMENTS_RESOURCE_FOLDER to TestConfiguration - rewrite MappingValidatorTest --- .../io/atlasmap/qe/test/AtlasmapInit.java | 79 ++--- .../atlasmap/qe/test/steps/BackendSteps.java | 54 ++-- .../io/atlasmap/qe/test/steps/UISteps.java | 12 +- .../qe/test/utils/ResourcesGenerator.java | 138 +++++++++ .../qe/test/utils/TestConfiguration.java | 18 ++ .../io/atlasmap/qe/mapper/AtlasMapper.java | 3 +- .../atlasmap/qe/mapper/MappingValidator.java | 47 +-- .../qe/mapper/MappingValidatorTest.java | 166 ++++++----- .../atlasmap/qe/data/ResourcesGenerator.java | 280 ------------------ .../documents/csv/sourceCsvCommentMarker.csv | 0 .../csv/sourceCsvCustomDelimiter.csv | 0 .../csv/sourceCsvCustomEscapeCharacter.csv | 0 .../csv/sourceCsvCustomQuoteCharacter.csv | 0 .../documents/csv/sourceCsvHeaders.csv | 0 .../csv/sourceCsvIgnoreEmptyLines.csv | 0 .../csv/sourceCsvIgnoreHeaderCase.csv | 0 .../csv/sourceCsvIgnoreSurroundingSpaces.csv | 0 .../csv/sourceCsvMissingColumnNames.csv | 0 .../documents/csv/sourceCsvTdfFormat.csv | 0 .../resources/documents/sourceArrays.json | 0 .../main}/resources/documents/sourceCsv.csv | 0 .../documents/sourceJson.schema.json | 0 .../resources/documents/sourceJsonArray.json | 0 .../documents/sourceJsonSchemaInstance.json | 33 +++ .../resources/documents/sourceXMLInstance.xml | 0 .../resources/documents/sourceXMLSchema.xsd | 0 .../documents/sourceXMLSchemaInstance.xml | 13 + .../resources/documents/targetArrays.json | 0 .../main}/resources/documents/targetCsv.csv | 0 .../documents/targetJson.schema.json | 0 .../resources/documents/targetJsonArray.json | 0 .../resources/documents/targetXMLInstance.xml | 0 .../resources/documents/targetXMLSchema.xsd | 0 33 files changed, 393 insertions(+), 450 deletions(-) create mode 100644 datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/ResourcesGenerator.java delete mode 100644 test-resources/src/main/java/io/atlasmap/qe/data/ResourcesGenerator.java rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvCommentMarker.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvCustomDelimiter.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvCustomEscapeCharacter.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvCustomQuoteCharacter.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvHeaders.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvIgnoreEmptyLines.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvIgnoreHeaderCase.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvIgnoreSurroundingSpaces.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvMissingColumnNames.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/csv/sourceCsvTdfFormat.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/sourceArrays.json (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/sourceCsv.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/sourceJson.schema.json (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/sourceJsonArray.json (100%) create mode 100644 test-resources/src/main/resources/documents/sourceJsonSchemaInstance.json rename datamapper-e2e/src/test/resources/documents/sourceXmlInstance.xml => test-resources/src/main/resources/documents/sourceXMLInstance.xml (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/sourceXMLSchema.xsd (100%) create mode 100644 test-resources/src/main/resources/documents/sourceXMLSchemaInstance.xml rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/targetArrays.json (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/targetCsv.csv (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/targetJson.schema.json (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/targetJsonArray.json (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/targetXMLInstance.xml (100%) rename {datamapper-e2e/src/test => test-resources/src/main}/resources/documents/targetXMLSchema.xsd (100%) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java index 4d0466b..0936615 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java @@ -1,5 +1,16 @@ package io.atlasmap.qe.test; +import io.atlasmap.qe.data.DatesObject; +import io.atlasmap.qe.data.SmallMappingTestClass; +import io.atlasmap.qe.data.StringObject; +import io.atlasmap.qe.data.source.SourceListsClass; +import io.atlasmap.qe.data.source.SourceMappingTestClass; +import io.atlasmap.qe.data.source.SourceNestedCollectionClass; +import io.atlasmap.qe.data.target.TargetListsClass; +import io.atlasmap.qe.data.target.TargetMappingTestClass; +import io.atlasmap.qe.data.target.TargetNestedCollectionClass; +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; @@ -11,8 +22,6 @@ import java.util.Optional; import java.util.function.Consumer; -import io.atlasmap.qe.test.utils.TestConfiguration; -import io.atlasmap.qe.test.utils.MappingUtils; import io.cucumber.plugin.EventListener; import io.cucumber.plugin.event.EventHandler; import io.cucumber.plugin.event.EventPublisher; @@ -28,10 +37,6 @@ */ public class AtlasmapInit implements EventListener { - // directory with test-resources JAR - private static final String TARGET_FOLDER = System.getProperty("user.dir") + "/../test-resources/target/"; - public static final String DOCUMENTS_FOLDER = System.getProperty("user.dir") + "/src/test/resources/documents/"; - /** * {@link AtlasmapPage} needed for resources loading. */ @@ -46,7 +51,8 @@ public class AtlasmapInit implements EventListener { page.resetAll(); // Finds file from target folder that was last modified and that ends with ".jar". - Optional jarFile = FileUtils.listFiles(new File(TARGET_FOLDER), new WildcardFileFilter("*.jar"), TrueFileFilter.TRUE) + Optional jarFile = FileUtils.listFiles(new File(TestConfiguration.getJarFolderPath()), + new WildcardFileFilter("*.jar"), TrueFileFilter.TRUE) .stream().max(Comparator.comparingLong(File::lastModified)); // Imports JAR file. @@ -60,43 +66,42 @@ public class AtlasmapInit implements EventListener { throw new IllegalStateException("Cannot find JAR file with test classes!"); } - // TODO: obtain classes names programmatically // Source classes: - page.enableSourceClass("io.atlasmap.qe.test.SourceMappingTestClass"); - page.enableSourceClass("io.atlasmap.qe.test.DatesObject"); - page.enableSourceClass("io.atlasmap.qe.test.SourceListsClass"); - page.enableSourceClass("io.atlasmap.qe.test.SmallMappingTestClass"); - page.enableSourceClass("io.atlasmap.qe.test.SourceNestedCollectionClass"); + page.enableSourceClass(SourceMappingTestClass.class.getName()); + page.enableSourceClass(DatesObject.class.getName()); + page.enableSourceClass(SourceListsClass.class.getName()); + page.enableSourceClass(SmallMappingTestClass.class.getName()); + page.enableSourceClass(SourceNestedCollectionClass.class.getName()); // Target classes: - page.enableTargetClass("io.atlasmap.qe.test.TargetMappingTestClass"); - page.enableTargetClass("io.atlasmap.qe.test.StringObject"); - page.enableTargetClass("io.atlasmap.qe.test.TargetListsClass"); - page.enableTargetClass("io.atlasmap.qe.test.TargetNestedCollectionClass"); + page.enableTargetClass(TargetMappingTestClass.class.getName()); + page.enableTargetClass(StringObject.class.getName()); + page.enableTargetClass(TargetListsClass.class.getName()); + page.enableTargetClass(TargetNestedCollectionClass.class.getName()); // Source documents: - page.enableSourceDocumentInstance(DOCUMENTS_FOLDER + "sourceArrays.json"); - page.enableSourceDocumentInstance(DOCUMENTS_FOLDER + "sourceJsonArray.json"); - page.enableSourceDocumentInstance(DOCUMENTS_FOLDER + "sourceXmlInstance.xml"); - - page.enableSourceDocumentSchema(DOCUMENTS_FOLDER + "sourceJson.schema.json"); - page.enableSourceDocumentSchema(DOCUMENTS_FOLDER + "sourceXMLSchema.xsd"); - - page.enableCsvSourceDocument(DOCUMENTS_FOLDER + "sourceCsv.csv", "Default", new HashMap() {{ - put("First Record As Header", "true"); - }}); + page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceArrays.json"); + page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceJsonArray.json"); + page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceJson.schema.json"); + page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceXMLInstance.xml"); + page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceXMLSchema.xsd"); + page.enableCsvSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceCsv.csv", "Default", + new HashMap() {{ + put("First Record As Header", "true"); + }} + ); // Target documents: - page.enableTargetDocumentInstance(DOCUMENTS_FOLDER + "targetArrays.json"); - page.enableTargetDocumentInstance(DOCUMENTS_FOLDER + "targetJsonArray.json"); - page.enableTargetDocumentInstance(DOCUMENTS_FOLDER + "targetXMLInstance.xml"); - - page.enableTargetDocumentSchema(DOCUMENTS_FOLDER + "targetJson.schema.json"); - page.enableTargetDocumentSchema(DOCUMENTS_FOLDER + "targetXMLSchema.xsd"); - - page.enableCsvTargetDocument(DOCUMENTS_FOLDER + "targetCsv.csv", "Default", new HashMap() {{ - put("First Record As Header", "true"); - }}); + page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetArrays.json"); + page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetJsonArray.json"); + page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetJson.schema.json"); + page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetXMLSchema.xsd"); + page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetXMLInstance.xml"); + page.enableCsvTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetCsv.csv", "Default", + new HashMap() {{ + put("First Record As Header", "true"); + }} + ); // TODO: find more dynamic way for initialization check MappingUtils.sleep(1000); diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java index 3c8a522..51a6b1e 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java @@ -10,7 +10,7 @@ import io.atlasmap.qe.data.target.TargetMappingTestClass; import io.atlasmap.qe.data.target.TargetNestedCollectionClass; import io.atlasmap.qe.mapper.MappingValidator; -import io.atlasmap.qe.data.ResourcesGenerator; +import io.atlasmap.qe.test.utils.ResourcesGenerator; import io.atlasmap.qe.test.utils.MappingUtils; import org.junit.Assert; @@ -34,8 +34,16 @@ @Slf4j public class BackendSteps { + private final MappingValidator validator; + + private final ResourcesGenerator resourcesGenerator; + @Inject - private MappingValidator validator; + public BackendSteps(MappingValidator validator, ResourcesGenerator resourcesGenerator) { + this.validator = validator; + this.resourcesGenerator = resourcesGenerator; + validator.initializeValues(resourcesGenerator.generateResourceMap()); + } @Given("atlasmap is clean") public void atlasmapIsClean() { @@ -45,7 +53,7 @@ public void atlasmapIsClean() { } catch (IOException e) { e.printStackTrace(); } - validator.initializeValues(); + validator.initializeValues(resourcesGenerator.generateResourceMap()); } @Then("save mapping as {string}") @@ -158,6 +166,8 @@ public void addStringObjectToExpedtedMapWithAndValues(String arg0, String arg1) public void saveAndVerifyMappingWithMultipleObjectsAs(String arg0) throws Throwable { userSavesMappingAs(arg0); assertThat(validator.verifyMultiObjectMapping()).isTrue(); + validator.clear(); + validator.initValidator(resourcesGenerator.generateResourceMap()); } @And("Init smallMappingTestClass and add to source map") @@ -231,6 +241,8 @@ public void saveAndVerifyDatetypesMappingAsAndSkipSqlFormats(String mapping) thr assertThat(sourceDate.getZonedDateTime()).isEqualTo(d.getZonedDateTime()); assertThat(sourceDate.getGregorianCalendar()).isEqualTo(d.getGregorianCalendar()); assertThat(validator.verifyMultiObjectMapping()).isTrue(); + validator.clear(); + validator.initValidator(resourcesGenerator.generateResourceMap()); } @Then("^save and verify combine mapping with \"([^\"]*)\" separator as \"([^\"]*)\"$") @@ -290,18 +302,18 @@ public void saveAndVerifyThatContainsAs(String array, String var, String path) t .containsAll(Arrays.asList((new SourceListsClass()).getArray())); } else if (var.contains("csvStrings")) { strings.forEach(i -> { - ResourcesGenerator.getCsvArrays("csvStrings").contains(i); + resourcesGenerator.getCsvArrays("csvStrings").contains(i); }); } } else if ("listOfIntegers".equals(array)) { final List integers = target.getTargetSmallMappingTestClass().getListOfIntegers(); if ("listOfIntegers".equals(var)) { integers.forEach(i -> { - ResourcesGenerator.getJsonArrays("jsonIntegers").contains(i); + resourcesGenerator.getJsonArrays("jsonIntegers").contains(i); }); } else if (var.contains("csvIntegers")) { integers.forEach(i -> { - ResourcesGenerator.getCsvArrays("csvIntegers").contains(i); + resourcesGenerator.getCsvArrays("csvIntegers").contains(i); }); } else { assertThat(integers).contains(Integer.valueOf(var)); @@ -310,7 +322,7 @@ public void saveAndVerifyThatContainsAs(String array, String var, String path) t final List doubles = target.getTargetSmallMappingTestClass().getListOfDoubles(); if ("csvIntegers".equals(var)) { doubles.forEach(i -> { - ResourcesGenerator.getCsvArrays("csvDoubles").contains(i); + resourcesGenerator.getCsvArrays("csvDoubles").contains(i); }); } } else { @@ -366,9 +378,9 @@ public void saveAndVerifyRepeatingMappingOfJsonCollectionsToObjectAs(String mapp userSavesMappingAs(mapping); TargetListsClass tlc = (TargetListsClass) validator - .processSingleObjectMapping(ResourcesGenerator.getJsonArrays(), "sourceArrays", TargetListsClass.class.getName()); - final List integers = ResourcesGenerator.getJsonArrays("jsonIntegers"); - final List strings = ResourcesGenerator.getJsonArrays("jsonStrings"); + .processSingleObjectMapping(resourcesGenerator.getJsonArrays(), "sourceArrays", TargetListsClass.class.getName()); + final List integers = resourcesGenerator.getJsonArrays("jsonIntegers"); + final List strings = resourcesGenerator.getJsonArrays("jsonStrings"); assertThat(integers.size()).isGreaterThan(0); assertThat(strings.size()).isGreaterThan(0); @@ -384,8 +396,8 @@ public void saveAndVerifyRepeatingMappingOfJsonCollectionsToObjectAs(String mapp public void saveAndVerifyRepeatingMappingOfJsonObjectToObjectAs(String mapping) throws Throwable { userSavesMappingAs(mapping); final List targetObjects = ((TargetListsClass) validator - .processSingleObjectMapping(ResourcesGenerator.getJsonArrays(), "sourceArrays", TargetListsClass.class.getName())).getObjects(); - final List jsonObjects = ResourcesGenerator.getJsonArrays("jsonObjects"); + .processSingleObjectMapping(resourcesGenerator.getJsonArrays(), "sourceArrays", TargetListsClass.class.getName())).getObjects(); + final List jsonObjects = resourcesGenerator.getJsonArrays("jsonObjects"); for (int i = 0; i < targetObjects.size(); i++) { assertThat(targetObjects.get(i).getFirstName()).isEqualTo(((StringObject) jsonObjects.get(i)).getFirstName()); @@ -396,7 +408,7 @@ public void saveAndVerifyRepeatingMappingOfJsonObjectToObjectAs(String mapping) @Then("save and verify repeating mapping of csv object to object as {string}") public void saveAndVerifyRepeatingMappingOfCsvToJsonObjectAs(String mapping) throws Throwable { userSavesMappingAs(mapping); - String output = (String) validator.processSingleObjectMapping(ResourcesGenerator.getCsvInstance(), "sourceCsv", "targetJsonArray"); + String output = (String) validator.processSingleObjectMapping(resourcesGenerator.getCsvInstance(), "sourceCsv", "targetJsonArray"); System.out.println("++++>" + output); assertThat(output).contains( "{\"arrayString\":\"csv0\"},{\"arrayString\":\"csv1\"},{\"arrayString\":\"csv2\"},{\"arrayString\":\"csv3\"},{\"arrayString\":\"csv4\"}"); @@ -405,7 +417,7 @@ public void saveAndVerifyRepeatingMappingOfCsvToJsonObjectAs(String mapping) thr @Then("save and verify rootArrayMappings mapping as {string}") public void saveAndVerifyRootArrayMappingsMappingAs(String mapping) throws Throwable { userSavesMappingAs(mapping); - String output = (String) validator.processSingleObjectMapping(ResourcesGenerator.getRootJsonArray(), "sourceJsonArray", "targetJsonArray"); + String output = (String) validator.processSingleObjectMapping(resourcesGenerator.getRootJsonArray(), "sourceJsonArray", "targetJsonArray"); System.out.println("++++>" + output); assertThat(output).contains( "{\"arrayAnotherString\":\"1\",\"arrayString\":\"another-string\"},{\"arrayAnotherString\":\"2\",\"arrayString\":\"another-string\"}," + @@ -415,7 +427,7 @@ public void saveAndVerifyRootArrayMappingsMappingAs(String mapping) throws Throw @Then("save and verify CSV mapping as {string}") public void saveAndVerifyCSVMappingAs(String mapping) throws Throwable { userSavesMappingAs(mapping); - String output = (String) validator.processSingleObjectMapping(ResourcesGenerator.getCsvInstance(), "sourceCsv", "targetCsv"); + String output = (String) validator.processSingleObjectMapping(resourcesGenerator.getCsvInstance(), "sourceCsv", "targetCsv"); System.out.println("++++>" + output); assertThat(output).contains( "csv0,0,0.0,1989-05-05,true", @@ -468,15 +480,15 @@ private String getTargetType(String sourceType, String targetDocId) { switch (sourceType) { case "json": source = "sourceArrays"; - output = (String) validator.processSingleObjectMapping(ResourcesGenerator.getJsonArrays(), source, targetDocId); + output = (String) validator.processSingleObjectMapping(resourcesGenerator.getJsonArrays(), source, targetDocId); break; case "java": source = SourceNestedCollectionClass.class.getName(); output = (String) validator.processSingleObjectMapping(new SourceNestedCollectionClass(), source, targetDocId); break; case "xml": - source = "sourceXmlInstance"; - output = (String) validator.processSingleObjectMapping(ResourcesGenerator.getXMLInstance(), source, targetDocId); + source = "sourceXMLInstance"; + output = (String) validator.processSingleObjectMapping(resourcesGenerator.getXmlInstance(), source, targetDocId); break; default: fail("unknown source type: " + sourceType); @@ -509,15 +521,15 @@ public void saveAndVerifyMappingsBetweenNestedCollections(String sourceType, Str switch (sourceType) { case "json": source = "sourceArrays"; - output = validator.processSingleObjectMapping(ResourcesGenerator.getJsonArrays(), source, target); + output = validator.processSingleObjectMapping(resourcesGenerator.getJsonArrays(), source, target); break; case "java": source = SourceNestedCollectionClass.class.getName(); output = validator.processSingleObjectMapping(new SourceNestedCollectionClass(), source, target); break; case "xml": - source = "sourceXmlInstance"; - output = validator.processSingleObjectMapping(ResourcesGenerator.getXMLInstance(), source, target); + source = "sourceXMLInstance"; + output = validator.processSingleObjectMapping(resourcesGenerator.getXmlInstance(), source, target); break; default: fail("unknown source type: " + sourceType); diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java index 000fb4a..0b829ee 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java @@ -3,9 +3,9 @@ import static org.assertj.core.api.Assertions.assertThat; import io.atlasmap.qe.mapper.MappingValidator; -import io.atlasmap.qe.test.AtlasmapInit; import io.atlasmap.qe.test.utils.HoverAction; import io.atlasmap.qe.test.utils.MappingUtils; +import io.atlasmap.qe.test.utils.TestConfiguration; import org.junit.Assert; import java.util.*; @@ -35,8 +35,8 @@ public class UISteps { @Given("atlasmap contains TestClass") public void atlasMapContainsTestClass() throws Exception { - String resp = MappingUtils.requestClass(atlasmapPage.TEST_CLASS); - assertThat(resp).contains(atlasmapPage.TEST_CLASS); + String resp = MappingUtils.requestClass(AtlasmapPage.TEST_CLASS); + assertThat(resp).contains(AtlasmapPage.TEST_CLASS); } @Then("browser is opened") @@ -222,7 +222,7 @@ public void setConstantWithValue(String type, String value) { @When("set {string} property of type {string}, name {string}, scope {string}") public void setProperty(String sourceTarget, String type, String name, String scope) { - atlasmapPage.addProperty(sourceTarget.equals("source") ? true : false, type, name, scope); + atlasmapPage.addProperty(sourceTarget.equals("source"), type, name, scope); } @And("switch to mapping table view") @@ -362,14 +362,14 @@ public void clickShowSourceMapping(String mappingField) { @And("import CSV file {string} formatted as {string} with parameters") public void importCSVFileWithParameters(String fileName, String format, DataTable parameters) { System.out.println(fileName + format); - atlasmapPage.enableCsvSourceDocument(AtlasmapInit.DOCUMENTS_FOLDER + fileName, format, + atlasmapPage.enableCsvSourceDocument(TestConfiguration.getDocumentsFolderPath() + fileName, format, parameters.asMap(String.class, String.class)); } @And("import CSV file {string} formatted as {string}") public void importCSVFile(String fileName, String format) { System.out.println(fileName + format); - atlasmapPage.enableCsvSourceDocument(AtlasmapInit.DOCUMENTS_FOLDER + fileName, format, new HashMap<>()); + atlasmapPage.enableCsvSourceDocument(TestConfiguration.getDocumentsFolderPath() + fileName, format, new HashMap<>()); } @And("remove {string} document called {string}") diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/ResourcesGenerator.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/ResourcesGenerator.java new file mode 100644 index 0000000..8e618df --- /dev/null +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/ResourcesGenerator.java @@ -0,0 +1,138 @@ +package io.atlasmap.qe.test.utils; + +import io.atlasmap.qe.data.DatesObject; +import io.atlasmap.qe.data.SmallMappingTestClass; +import io.atlasmap.qe.data.StringObject; +import io.atlasmap.qe.data.source.SourceListsClass; +import io.atlasmap.qe.data.source.SourceNestedCollectionClass; +import lombok.SneakyThrows; +import org.springframework.stereotype.Component; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Stream; + + +/* + * TODO rewrite this class + * - read all strings from files + * - create connection between this class and AtlasMapInit (same resources should be loaded in both cases) + * - extract file paths into final static variables + */ +@Component +public class ResourcesGenerator { + + private final String jsonInstance; + private final String csvInstance; + private final String xmlInstance; + private final String xmlSchemaInstance; + private final String jsonArrays; + private final String rootJsonArray; + + @SneakyThrows + public ResourcesGenerator() { + String documentsFolderPath = TestConfiguration.getDocumentsFolderPath(); + + jsonInstance = new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceJsonSchemaInstance.json"))); + csvInstance = new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceCsv.csv"))); + xmlInstance = new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceXMLInstance.xml"))); + xmlSchemaInstance = new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceXMLSchemaInstance.xml"))); + jsonArrays = new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceArrays.json"))); + rootJsonArray = new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceJsonArray.json"))); + } + + public String getJsonInstance() { + return jsonInstance; + } + + public String getCsvInstance() { + return csvInstance; + } + + public String getXmlInstance() { + return xmlInstance; + } + + public String getXmlSchemaInstance() { + return xmlSchemaInstance; + } + + public String getJsonArrays() { + return jsonArrays; + } + + public String getRootJsonArray() { + return rootJsonArray; + } + + public List getJsonArrays(String field) { + switch (field) { + case "jsonIntegers": { + return new ArrayList(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); + } + case "jsonStrings": { + return new ArrayList(Arrays.asList("json0", "json1", "json2", "json3", "json4", "json5", "json6", "json7", "json8", "json9")); + } + + case "jsonObjects": { + return new ArrayList(Arrays.asList( + new StringObject("0", "v0"), + new StringObject("1", "v1"), + new StringObject("2", "v2"), + new StringObject("3", "v3"), + new StringObject("4", "v4"), + new StringObject("5", "v5"), + new StringObject("6", "v6"), + new StringObject("7", "v7"), + new StringObject("8", "v8"), + new StringObject("9", "v9") + )); + } + default: { + return null; + } + } + } + + public List getCsvArrays(String field) { + switch (field) { + case "csvIntegers": { + return new ArrayList(Arrays.asList(0, 1, 2, 3, 4)); + } + case "csvDoubles": { + return new ArrayList(Arrays.asList(0.0, 10.0, 20.0, 30.0, 40.0)); + } + case "csvStrings": { + return new ArrayList(Arrays.asList("csv0", "csv1", "csv2", "csv3", "csv4")); + } + default: { + return null; + } + } + } + + public HashMap generateResourceMap() { + HashMap resourceMap = new HashMap<>(); + + resourceMap.put(SourceListsClass.class.getName(), new SourceListsClass()); + resourceMap.put(SmallMappingTestClass.class.getName(), new SmallMappingTestClass()); + resourceMap.put(SourceNestedCollectionClass.class.getName(), new SourceNestedCollectionClass()); + resourceMap.put(DatesObject.class.getName(), new DatesObject("22-12-2012")); + resourceMap.put("sourceJson.schema", getJsonInstance()); + resourceMap.put("sourceArrays", getJsonArrays()); + resourceMap.put("sourceXMLInstance", getXmlInstance()); + resourceMap.put("sourceXMLSchema", getXmlSchemaInstance()); + resourceMap.put("sourceJsonArray", getRootJsonArray()); + + // FIXME do not use same CSV instance for every CSV resource type + Stream.of("sourceCsv", "sourceCsvCustomDelimiter", "sourceCsvMissingColumnNames", "sourceCsvCommentMarker", + "sourceCsvCustomEscapeCharacter", "sourceCsvHeaders", "sourceCsvIgnoreEmptyLines", + "sourceCsvIgnoreHeaderCase", "sourceCsvIgnoreSurroundingSpaces", "sourceCsvCustomQuoteCharacter", + "sourceCsvTdfFormat").forEach(csvDocumentName -> + resourceMap.put(csvDocumentName, getCsvInstance()) + ); + + return resourceMap; + } +} diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/TestConfiguration.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/TestConfiguration.java index 5e0abce..bf59c1d 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/TestConfiguration.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/TestConfiguration.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.io.InputStream; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -9,6 +10,8 @@ import lombok.extern.slf4j.Slf4j; + +// TODO @Component @Slf4j public class TestConfiguration { @@ -33,6 +36,10 @@ public class TestConfiguration { public static final String SELENIDE_HEADLESS = "selenide.headless"; + private static final String JAR_RESOURCE_FOLDER = "atlasmap.resource.jar"; + + public static final String DOCUMENTS_RESOURCE_FOLDER = "atlasmap.resource.documents"; + private static final TestConfiguration INSTANCE = new TestConfiguration(); private final Properties properties = new Properties(); @@ -109,6 +116,17 @@ public static String syndesisBrowser() { return get().readValue(ATLASMAP_UI_BROWSER); } + public static String getJarFolderPath() { + return get().readValue(JAR_RESOURCE_FOLDER, FileSystems.getDefault() + .getPath(System.getProperty("user.dir") + "/../test-resources/target/").normalize().toString() + "/"); + } + + public static String getDocumentsFolderPath() { + return get().readValue(DOCUMENTS_RESOURCE_FOLDER, FileSystems.getDefault() + .getPath(System.getProperty("user.dir") + "/../test-resources/src/main/resources/documents/") + .normalize().toString() + "/"); + } + private void copyValues(final Properties source) { copyValues(source, false); } diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/mapper/AtlasMapper.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/AtlasMapper.java index ee7c85a..6fc34ec 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/mapper/AtlasMapper.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/AtlasMapper.java @@ -105,8 +105,7 @@ private JSONObject exportAtlasJson(String mappingFilePath) { } catch (IOException e) { e.printStackTrace(); } - JSONObject atlasJson = new JSONObject(jsonTxt); - return atlasJson; + return new JSONObject(jsonTxt); } } diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java index 760cd10..b87391e 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java @@ -2,12 +2,9 @@ import static org.assertj.core.api.Assertions.assertThat; -import io.atlasmap.qe.data.*; -import io.atlasmap.qe.data.source.SourceListsClass; import io.atlasmap.qe.data.source.SourceMappingTestClass; -import io.atlasmap.qe.data.source.SourceNestedCollectionClass; import io.atlasmap.qe.data.target.TargetMappingTestClass; -import io.atlasmap.qe.data.ResourcesGenerator; +import lombok.extern.slf4j.Slf4j; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,7 +12,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import java.util.stream.Stream; import org.springframework.beans.BeanWrapper; import org.springframework.beans.PropertyAccessorFactory; @@ -24,14 +20,14 @@ import javax.inject.Inject; + /** * Created by mmelko on 15/11/2017. */ +@Slf4j @Component public class MappingValidator { private static final Logger LOG = LogManager.getLogger(MappingValidator.class); - public static final String SOURCE_MAP = "SOURCE_MAP"; - public static final String TARGET_MAP = "TARGET_MAP"; private String mappingLocation; private SourceMappingTestClass source; @@ -45,23 +41,19 @@ public class MappingValidator { @Inject private ConversionService conversionService; - public MappingValidator() { - initializeValues(); - } - - public void initializeValues() { + public void initializeValues(Map resourceMap) { source = new SourceMappingTestClass(); target = new TargetMappingTestClass(); expectedMap = new HashMap<>(); sourceMap = new HashMap<>(); - initValidator(); + initValidator(resourceMap); } public TargetMappingTestClass processMapping(SourceMappingTestClass input) { sourceMap = new HashMap<>(); sourceMap.put(input.getClass().getName(), input); Map targetMap = processMappingInputMap(sourceMap); - return (TargetMappingTestClass) targetMap.get("io.atlasmap.qe.test.TargetMappingTestClass"); + return (TargetMappingTestClass) targetMap.get(TargetMappingTestClass.class.getName()); } public TargetMappingTestClass processMapping() { @@ -109,13 +101,11 @@ public boolean verifyMapping(SourceMappingTestClass source, TargetMappingTestCla public boolean verifyMultiObjectMapping() { this.sourceMap.put(this.source.getClass().getName(), this.source); this.expectedMap.put(this.target.getClass().getName(), this.target); // FIXME: why is this here? - final boolean res = verifyMultiObjectMapping(this.sourceMap); - this.clear(); - this.initValidator(); + final boolean res = verifyMultiObjectMappingWithMap(this.sourceMap); return res; } - public boolean verifyMultiObjectMapping(Map input) { + public boolean verifyMultiObjectMappingWithMap(Map input) { final Boolean res = verifyMappingInputExpected(input, this.expectedMap); clear(); return res; @@ -223,30 +213,17 @@ public void addSource(String name, Object s) { this.sourceMap.put(name, s); } - private void clear() { + public void clear() { this.sourceMap.clear(); this.expectedMap.clear(); this.source = new SourceMappingTestClass(); this.target = new TargetMappingTestClass(); } - public void initValidator() { + public void initValidator(Map resourceMap) { + sourceMap = resourceMap; + sourceMap.put(source.getClass().getName(), source); - sourceMap.put(SourceListsClass.class.getName(), new SourceListsClass()); - sourceMap.put(SmallMappingTestClass.class.getName(), new SmallMappingTestClass()); - sourceMap.put(SourceNestedCollectionClass.class.getName(), new SourceNestedCollectionClass()); - sourceMap.put(DatesObject.class.getName(), new DatesObject("21-12-2012")); - sourceMap.put("sourceJson.schema", ResourcesGenerator.getJsonInstance()); - sourceMap.put("sourceArrays", ResourcesGenerator.getJsonArrays()); - sourceMap.put("sourceXmlInstance", ResourcesGenerator.getXMLInstance()); - sourceMap.put("sourceXMLSchema", ResourcesGenerator.getXmlSchemaInstance(null)); - sourceMap.put("sourceJsonArray", ResourcesGenerator.getRootJsonArray()); - Stream.of("sourceCsv", "sourceCsvCustomDelimiter", "sourceCsvMissingColumnNames", "sourceCsvCommentMarker", - "sourceCsvCustomEscapeCharacter", "sourceCsvHeaders", "sourceCsvIgnoreEmptyLines", - "sourceCsvIgnoreHeaderCase", "sourceCsvIgnoreSurroundingSpaces", "sourceCsvCustomQuoteCharacter", - "sourceCsvTdfFormat").forEach(csvDocumentName -> - sourceMap.put(csvDocumentName, ResourcesGenerator.getCsvInstance()) - ); } public static void main(String[] args) { diff --git a/mapping-validator/src/test/java/io/atlasmap/qe/mapper/MappingValidatorTest.java b/mapping-validator/src/test/java/io/atlasmap/qe/mapper/MappingValidatorTest.java index b01a722..3ef29a6 100644 --- a/mapping-validator/src/test/java/io/atlasmap/qe/mapper/MappingValidatorTest.java +++ b/mapping-validator/src/test/java/io/atlasmap/qe/mapper/MappingValidatorTest.java @@ -3,6 +3,8 @@ import io.atlasmap.qe.data.DatesObject; import io.atlasmap.qe.data.SimpleEnum; import io.atlasmap.qe.data.SmallMappingTestClass; +import io.atlasmap.qe.data.source.SourceListsClass; +import io.atlasmap.qe.data.source.SourceNestedCollectionClass; import io.atlasmap.qe.data.target.TargetMappingTestClass; import lombok.extern.slf4j.Slf4j; import org.springframework.test.context.ContextConfiguration; @@ -10,9 +12,13 @@ import org.testng.annotations.Test; import javax.inject.Inject; +import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Date; +import java.util.HashMap; import static org.assertj.core.api.Assertions.assertThat; @@ -26,33 +32,55 @@ @ContextConfiguration(classes = ValidatorSpringConfig.class) public class MappingValidatorTest extends AbstractTestNGSpringContextTests { + private MappingValidator mappingValidator; + private HashMap resourceMap; + @Inject - MappingValidator mv; + public void initializeResources(MappingValidator mappingValidator) throws IOException { + this.mappingValidator = mappingValidator; + + resourceMap = new HashMap<>(); + + resourceMap.put(SourceListsClass.class.getName(), new SourceListsClass()); + resourceMap.put(SmallMappingTestClass.class.getName(), new SmallMappingTestClass()); + resourceMap.put(SourceNestedCollectionClass.class.getName(), new SourceNestedCollectionClass()); + resourceMap.put(DatesObject.class.getName(), new DatesObject("22-12-2012")); + + String documentsFolderPath = System.getProperty("user.dir") + "/../test-resources/src/main/resources/documents/"; + + resourceMap.put("sourceJson.schema", new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceJsonSchemaInstance.json")))); + resourceMap.put("sourceArrays", new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceArrays.json")))); + resourceMap.put("sourceXMLSchema", new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceXMLSchemaInstance.xml")))); + resourceMap.put("sourceJsonArray", new String(Files.readAllBytes(Paths.get(documentsFolderPath + "sourceJsonArray.json")))); + + mappingValidator.initializeValues(new HashMap<>(resourceMap)); + } @Test public void javaToJavaMapping() { - mv.initValidator(); - mv.setMappingLocation("javaToJava.json"); - mv.setTargetValue("targetCombineString", "sourceString sourceAnotherString 1"); - assertThat(mv.verifyMapping()).isTrue(); + System.out.println(resourceMap.get("sourceXMLSchema")); + mappingValidator.initValidator(new HashMap<>(resourceMap)); + mappingValidator.setMappingLocation("javaToJava.json"); + mappingValidator.setTargetValue("targetCombineString", "sourceString sourceAnotherString 1"); + assertThat(mappingValidator.verifyMapping()).isTrue(); } @Test public void jsonToJavaMapping() { - mv.initValidator(); - mv.setMappingLocation("jsonToJava.json"); - mv.setTargetValue("targetString", "sourceJsonString"); - mv.setTargetValue("targetInteger", "10"); - mv.setTargetValue("targetDouble", "-50"); - mv.setTargetValue("targetFloat", "40.0"); - assertThat(mv.verifyMapping()).isTrue(); + mappingValidator.initValidator(new HashMap<>(resourceMap)); + mappingValidator.setMappingLocation("jsonToJava.json"); + mappingValidator.setTargetValue("targetString", "sourceJsonString"); + mappingValidator.setTargetValue("targetInteger", "10"); + mappingValidator.setTargetValue("targetDouble", "-50"); + mappingValidator.setTargetValue("targetFloat", "40.0"); + assertThat(mappingValidator.verifyMapping()).isTrue(); } @Test public void jsonToXmlMapping() { - mv.initValidator(); - mv.setMappingLocation("jsonToXml.json"); - String result = (String) mv.processMapping("targetXMLSchema"); + mappingValidator.initValidator(new HashMap<>(resourceMap)); + mappingValidator.setMappingLocation("jsonToXml.json"); + String result = (String) mappingValidator.processMapping("targetXMLSchema"); assertThat(result).contains("sourceJsonString"); assertThat(result).contains("10"); assertThat(result).contains("-50.0"); @@ -60,92 +88,92 @@ public void jsonToXmlMapping() { @Test public void xmlSchemaToJavaMapping() { - mv.initValidator(); - mv.setMappingLocation("xmlSchemaToJava.json"); - mv.setTargetValue("targetString", "XmlString"); - mv.setTargetValue("targetInteger", "300"); - mv.setTargetValue("targetDouble", "500"); - mv.setTargetValue("targetFloat", "100.1"); - assertThat(mv.verifyMapping()).isTrue(); + mappingValidator.initValidator(new HashMap<>(resourceMap)); + mappingValidator.setMappingLocation("xmlSchemaToJava.json"); + mappingValidator.setTargetValue("targetString", "XmlString"); + mappingValidator.setTargetValue("targetInteger", "300"); + mappingValidator.setTargetValue("targetDouble", "500"); + mappingValidator.setTargetValue("targetFloat", "100.1"); + assertThat(mappingValidator.verifyMapping()).isTrue(); } @Test public void xmlToJsonMapping() { - mv.initValidator(); - mv.setMappingLocation("xmlToJson.json"); - String result = (String) mv.processMapping("targetJson.schema"); + mappingValidator.initValidator(new HashMap<>(resourceMap)); + mappingValidator.setMappingLocation("xmlToJson.json"); + String result = (String) mappingValidator.processMapping("targetJson.schema"); assertThat(result).contains("\"targetJsonInteger\":300"); assertThat(result).contains("\"targetJsonInteger\":300"); } @Test public void setValuesOfBeanProperties() { - mv.initValidator(); + mappingValidator.initValidator(new HashMap<>(resourceMap)); TargetMappingTestClass bean = new TargetMappingTestClass(); - mv.setValueOfBeanProperty(bean, "targetString", "targetString"); - mv.setValueOfBeanProperty(bean, "targetCombineString", "targetCombineString"); - mv.setValueOfBeanProperty(bean, "targetInteger", 5); - mv.setValueOfBeanProperty(bean, "targetLong", 4L); - mv.setValueOfBeanProperty(bean, "targetFloat", 3f); - mv.setValueOfBeanProperty(bean, "targetDouble", 2d); - mv.setValueOfBeanProperty(bean, "targetDate", new Date(0)); - mv.setValueOfBeanProperty(bean, "targetAnotherString", "targetAnotherString"); - mv.setValueOfBeanProperty(bean, "targetBoolean", false); - mv.setValueOfBeanProperty(bean, "targetShort", 1); - mv.setValueOfBeanProperty(bean, "targetByte", Byte.MIN_VALUE); - mv.setValueOfBeanProperty(bean, "targetChar", 'x'); - mv.setValueOfBeanProperty(bean, "targetBigInteger", new BigInteger("0")); - mv.setValueOfBeanProperty(bean, "targetBigDecimal", new BigDecimal("0")); - mv.setValueOfBeanProperty(bean, "targetSmallMappingTestClass", new SmallMappingTestClass()); - mv.setValueOfBeanProperty(bean, "dateObjectVariable", new DatesObject("01-01-1989")); - mv.setValueOfBeanProperty(bean, "targetEnum", SimpleEnum.VALUE2); + mappingValidator.setValueOfBeanProperty(bean, "targetString", "targetString"); + mappingValidator.setValueOfBeanProperty(bean, "targetCombineString", "targetCombineString"); + mappingValidator.setValueOfBeanProperty(bean, "targetInteger", 5); + mappingValidator.setValueOfBeanProperty(bean, "targetLong", 4L); + mappingValidator.setValueOfBeanProperty(bean, "targetFloat", 3f); + mappingValidator.setValueOfBeanProperty(bean, "targetDouble", 2d); + mappingValidator.setValueOfBeanProperty(bean, "targetDate", new Date(0)); + mappingValidator.setValueOfBeanProperty(bean, "targetAnotherString", "targetAnotherString"); + mappingValidator.setValueOfBeanProperty(bean, "targetBoolean", false); + mappingValidator.setValueOfBeanProperty(bean, "targetShort", 1); + mappingValidator.setValueOfBeanProperty(bean, "targetByte", Byte.MIN_VALUE); + mappingValidator.setValueOfBeanProperty(bean, "targetChar", 'x'); + mappingValidator.setValueOfBeanProperty(bean, "targetBigInteger", new BigInteger("0")); + mappingValidator.setValueOfBeanProperty(bean, "targetBigDecimal", new BigDecimal("0")); + mappingValidator.setValueOfBeanProperty(bean, "targetSmallMappingTestClass", new SmallMappingTestClass()); + mappingValidator.setValueOfBeanProperty(bean, "dateObjectVariable", new DatesObject("01-01-1989")); + mappingValidator.setValueOfBeanProperty(bean, "targetEnum", SimpleEnum.VALUE2); TargetMappingTestClass targetMappingTestClass = new TargetMappingTestClass(); assertThat(bean).isEqualTo(targetMappingTestClass); - mv.setValueOfBeanProperty(bean, "targetInteger", "5"); - mv.setValueOfBeanProperty(bean, "targetLong", "4"); - mv.setValueOfBeanProperty(bean, "targetFloat", "3"); - mv.setValueOfBeanProperty(bean, "targetDouble", "2"); - mv.setValueOfBeanProperty(bean, "targetDate", "1970-01-01-00"); - mv.setValueOfBeanProperty(bean, "targetBoolean", "false"); - mv.setValueOfBeanProperty(bean, "targetShort", "1"); - mv.setValueOfBeanProperty(bean, "targetByte", "-128"); - mv.setValueOfBeanProperty(bean, "targetChar", "x"); - mv.setValueOfBeanProperty(bean, "targetBigInteger", "0"); - mv.setValueOfBeanProperty(bean, "targetBigDecimal", "0"); - mv.setValueOfBeanProperty(bean, "targetEnum", "VALUE2"); + mappingValidator.setValueOfBeanProperty(bean, "targetInteger", "5"); + mappingValidator.setValueOfBeanProperty(bean, "targetLong", "4"); + mappingValidator.setValueOfBeanProperty(bean, "targetFloat", "3"); + mappingValidator.setValueOfBeanProperty(bean, "targetDouble", "2"); + mappingValidator.setValueOfBeanProperty(bean, "targetDate", "1970-01-01-00"); + mappingValidator.setValueOfBeanProperty(bean, "targetBoolean", "false"); + mappingValidator.setValueOfBeanProperty(bean, "targetShort", "1"); + mappingValidator.setValueOfBeanProperty(bean, "targetByte", "-128"); + mappingValidator.setValueOfBeanProperty(bean, "targetChar", "x"); + mappingValidator.setValueOfBeanProperty(bean, "targetBigInteger", "0"); + mappingValidator.setValueOfBeanProperty(bean, "targetBigDecimal", "0"); + mappingValidator.setValueOfBeanProperty(bean, "targetEnum", "VALUE2"); assertThat(bean).isEqualTo(targetMappingTestClass); - mv.setValueOfBeanProperty(bean, "targetDate", 0); - mv.setValueOfBeanProperty(bean, "targetBoolean", new BigDecimal("0")); + mappingValidator.setValueOfBeanProperty(bean, "targetDate", 0); + mappingValidator.setValueOfBeanProperty(bean, "targetBoolean", new BigDecimal("0")); assertThat(bean).isEqualTo(targetMappingTestClass); - mv.setValueOfBeanProperty(bean, "targetInteger", '\005'); - mv.setValueOfBeanProperty(bean, "targetLong", '\004'); - mv.setValueOfBeanProperty(bean, "targetFloat", '\003'); - mv.setValueOfBeanProperty(bean, "targetDouble", '\002'); - mv.setValueOfBeanProperty(bean, "targetBoolean", '\000'); - mv.setValueOfBeanProperty(bean, "targetShort", '\001'); - mv.setValueOfBeanProperty(bean, "targetBigInteger", '\000'); - mv.setValueOfBeanProperty(bean, "targetBigDecimal", '\000'); + mappingValidator.setValueOfBeanProperty(bean, "targetInteger", '\005'); + mappingValidator.setValueOfBeanProperty(bean, "targetLong", '\004'); + mappingValidator.setValueOfBeanProperty(bean, "targetFloat", '\003'); + mappingValidator.setValueOfBeanProperty(bean, "targetDouble", '\002'); + mappingValidator.setValueOfBeanProperty(bean, "targetBoolean", '\000'); + mappingValidator.setValueOfBeanProperty(bean, "targetShort", '\001'); + mappingValidator.setValueOfBeanProperty(bean, "targetBigInteger", '\000'); + mappingValidator.setValueOfBeanProperty(bean, "targetBigDecimal", '\000'); assertThat(bean).isEqualTo(targetMappingTestClass); } @Test public void dateObjectsMapping() { - mv.initValidator(); + mappingValidator.initValidator(new HashMap<>(resourceMap)); DatesObject sourceDate = new DatesObject("22-12-2012"); - mv.addSource(sourceDate.getClass().getName(), sourceDate); + mappingValidator.addSource(sourceDate.getClass().getName(), sourceDate); - mv.setMappingLocation("fromDateObjectToDateObject.json"); + mappingValidator.setMappingLocation("fromDateObjectToDateObject.json"); - TargetMappingTestClass targetMappingTestClass = (TargetMappingTestClass) mv.processMapping(TargetMappingTestClass.class.getName()); + TargetMappingTestClass targetMappingTestClass = (TargetMappingTestClass) mappingValidator.processMapping(TargetMappingTestClass.class.getName()); DatesObject dateObjectVariable = targetMappingTestClass.getDateObjectVariable(); assertThat(sourceDate.getStandardJavaDate()).isEqualTo(dateObjectVariable.getStandardJavaDate()); diff --git a/test-resources/src/main/java/io/atlasmap/qe/data/ResourcesGenerator.java b/test-resources/src/main/java/io/atlasmap/qe/data/ResourcesGenerator.java deleted file mode 100644 index d3015d9..0000000 --- a/test-resources/src/main/java/io/atlasmap/qe/data/ResourcesGenerator.java +++ /dev/null @@ -1,280 +0,0 @@ -package io.atlasmap.qe.data; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - - -// TODO: remove this class -public class ResourcesGenerator { - - public static String getJsonInstance() { - return "{" + - "\"sourceJsonString\": \"sourceJsonString\"," + - "\"sourceJsonInteger\": 10," + - "\"sourceJsonLong\": 20.0," + - "\"sourceJsonFloat\": 30.4," + - "\"sourceJsonDouble\": 40.0," + - "\"sourceJsonDate\": \"1989-05-05\"," + - "\"sourceJsonBoolean\": true," + - "\"sourceJsonShort\": -50," + - "\"sourceJsonByte\": 127," + - "\"sourceJsonChar\": 3," + - "\"smallMappingTestClass\": {" + - " \"objectField1\": \"object1\"," + - " \"objectField2\": \"object2\"," + - " \"listOfStrings\": [" + - " \"sdf\"," + - " \"sdf\"" + - " ]," + - " \"listOfIntegers\": [" + - " 10," + - " 20," + - " 30," + - " 40," + - " 50" + - " ]," + - " \"listOfDoubles\": [" + - " 10.1," + - " 10.2," + - " 10.3," + - " 10.4" + - " ]" + - " }" + - "}"; - } - - public static String getCsvInstance() { - return - "csv0,0,0.0,1989-05-05,true\n" + - "csv1,10,10.0,1989-05-05,true\n" + - "csv2,20,20.0,1989-05-05,true\n" + - "csv3,30,30.0,1989-05-05,false\n" + - "csv4,40,40.0,1989-05-05,false\n"; - } - - public static String getXMLInstance() { - return "\n" + - "\n" + - " true\n" + - " A\n" + - " A\n" + - " \n" + - " 100.100\n" + - " 200.200\n" + - " 300\n" + - " 400\n" + - " 500\n" + - " XmlString\n" + - " \n" + - " xmlFirstArrayValue0\n" + - " \n" + - " xmlSecondArrayValue0-0\n" + - " \n" + - " xmlThirdArrayValue0-0-0\n" + - " \n" + - " \n" + - " xmlThirdArrayValue0-0-1\n" + - " \n" + - " \n" + - " \n" + - " xmlSecondArrayValue0-1\n" + - " \n" + - " xmlThirdArrayValue0-1-0\n" + - " \n" + - " \n" + - " xmlThirdArrayValue0-1-1\n" + - " \n" + - " \n" + - " xmlThirdArrayValue0-1-2\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " xmlFirstArrayValue1\n" + - " \n" + - " xmlSecondArrayValue1-0\n" + - " \n" + - " xmlThirdArrayValue1-0-0\n" + - " \n" + - " \n" + - " xmlThirdArrayValue1-0-1\n" + - " \n" + - " \n" + - " xmlThirdArrayValue1-0-2\n" + - " \n" + - " \n" + - " \n" + - " xmlSecondArrayValue1-1\n" + - " \n" + - " xmlThirdArrayValue1-1-0\n" + - " \n" + - " \n" + - " xmlThirdArrayValue1-1-1\n" + - " \n" + - " \n" + - " \n" + - "\n"; - } - - public static String getXmlSchemaInstance(Class c) { - return - "\n" + - " true\n" + - " A\n" + - " A\n" + - " \n" + - " 100.100\n" + - " 200.200\n" + - " 300\n" + - " 400\n" + - " 500\n" + - " XmlString\n" + - ""; - } - - public static String getJsonArrays() { - return " {\n" + - " \"jsonIntegers\": [0,1,2,3,4,5,6,7,8,9],\n" + - " \"jsonStrings\": [\"json0\",\"json1\",\"json2\",\"json3\",\"json4\",\"json5\",\"json6\",\"json7\",\"json8\",\"json9\"],\n" + - " \"jsonObjects\": [\n" + - " {\"key\":0,\"value\":\"v0\"},\n" + - " {\"key\":1,\"value\":\"v1\"},\n" + - " {\"key\":2,\"value\":\"v2\"},\n" + - " {\"key\":3,\"value\":\"v3\"},\n" + - " {\"key\":4,\"value\":\"v4\"},\n" + - " {\"key\":5,\"value\":\"v5\"},\n" + - " {\"key\":6,\"value\":\"v6\"},\n" + - " {\"key\":7,\"value\":\"v7\"},\n" + - " {\"key\":8,\"value\":\"v8\"},\n" + - " {\"key\":9,\"value\":\"v9\"}\n" + - " ],\n" + - " \"sourceJsonNestedArray\": [\n" + - " {\n" + - " \"value\": \"jsonFirstArrayValue0\",\n" + - " \"secondArray\": [\n" + - " {\n" + - " \"value\": \"jsonSecondArrayValue0-0\",\n" + - " \"thirdArray\": [\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue0-0-0\"\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue0-0-1\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonSecondArrayValue0-1\",\n" + - " \"thirdArray\": [\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue0-1-0\"\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue0-1-1\"\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue0-1-2\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonFirstArrayValue1\",\n" + - " \"secondArray\": [\n" + - " {\n" + - " \"value\": \"jsonSecondArrayValue1-0\",\n" + - " \"thirdArray\": [\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue1-0-0\"\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue1-0-1\"\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue1-0-2\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonSecondArrayValue1-1\",\n" + - " \"thirdArray\": [\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue1-1-0\"\n" + - " },\n" + - " {\n" + - " \"value\": \"jsonThirdArrayValue1-1-1\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - "}"; - } - - public static String getRootJsonArray() { - return " [{\n" + - " \"arrayNumber\": 1,\n" + - " \"arrayString\": \"1\",\n" + - " \"arrayAnotherString\": \"another-string\"\n" + - " },\n" + - " {\n" + - " \"arrayNumber\": 2,\n" + - " \"arrayString\": \"2\",\n" + - " \"arrayAnotherString\": \"another-string\"\n" + - " },\n" + - " {\n" + - " \"arrayNumber\": 3,\n" + - " \"arrayString\": \"3\",\n" + - " \"arrayAnotherString\": \"another-string\"\n" + - "}]"; - } - - public static List getJsonArrays(String field) { - switch (field) { - case "jsonIntegers": { - return new ArrayList(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); - } - case "jsonStrings": { - return new ArrayList(Arrays.asList("json0", "json1", "json2", "json3", "json4", "json5", "json6", "json7", "json8", "json9")); - } - - case "jsonObjects": { - return new ArrayList(Arrays.asList( - new StringObject("0", "v0"), - new StringObject("1", "v1"), - new StringObject("2", "v2"), - new StringObject("3", "v3"), - new StringObject("4", "v4"), - new StringObject("5", "v5"), - new StringObject("6", "v6"), - new StringObject("7", "v7"), - new StringObject("8", "v8"), - new StringObject("9", "v9") - )); - } - default: { - return null; - } - } - } - - public static List getCsvArrays(String field) { - switch (field) { - case "csvIntegers": { - return new ArrayList(Arrays.asList(0, 1, 2, 3, 4)); - } - case "csvDoubles": { - return new ArrayList(Arrays.asList(0.0, 10.0, 20.0, 30.0, 40.0)); - } - case "csvStrings": { - return new ArrayList(Arrays.asList("csv0", "csv1", "csv2", "csv3", "csv4")); - } - default: { - return null; - } - } - } -} diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvCommentMarker.csv b/test-resources/src/main/resources/documents/csv/sourceCsvCommentMarker.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvCommentMarker.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvCommentMarker.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvCustomDelimiter.csv b/test-resources/src/main/resources/documents/csv/sourceCsvCustomDelimiter.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvCustomDelimiter.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvCustomDelimiter.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvCustomEscapeCharacter.csv b/test-resources/src/main/resources/documents/csv/sourceCsvCustomEscapeCharacter.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvCustomEscapeCharacter.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvCustomEscapeCharacter.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvCustomQuoteCharacter.csv b/test-resources/src/main/resources/documents/csv/sourceCsvCustomQuoteCharacter.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvCustomQuoteCharacter.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvCustomQuoteCharacter.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvHeaders.csv b/test-resources/src/main/resources/documents/csv/sourceCsvHeaders.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvHeaders.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvHeaders.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvIgnoreEmptyLines.csv b/test-resources/src/main/resources/documents/csv/sourceCsvIgnoreEmptyLines.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvIgnoreEmptyLines.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvIgnoreEmptyLines.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvIgnoreHeaderCase.csv b/test-resources/src/main/resources/documents/csv/sourceCsvIgnoreHeaderCase.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvIgnoreHeaderCase.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvIgnoreHeaderCase.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvIgnoreSurroundingSpaces.csv b/test-resources/src/main/resources/documents/csv/sourceCsvIgnoreSurroundingSpaces.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvIgnoreSurroundingSpaces.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvIgnoreSurroundingSpaces.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvMissingColumnNames.csv b/test-resources/src/main/resources/documents/csv/sourceCsvMissingColumnNames.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvMissingColumnNames.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvMissingColumnNames.csv diff --git a/datamapper-e2e/src/test/resources/documents/csv/sourceCsvTdfFormat.csv b/test-resources/src/main/resources/documents/csv/sourceCsvTdfFormat.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/csv/sourceCsvTdfFormat.csv rename to test-resources/src/main/resources/documents/csv/sourceCsvTdfFormat.csv diff --git a/datamapper-e2e/src/test/resources/documents/sourceArrays.json b/test-resources/src/main/resources/documents/sourceArrays.json similarity index 100% rename from datamapper-e2e/src/test/resources/documents/sourceArrays.json rename to test-resources/src/main/resources/documents/sourceArrays.json diff --git a/datamapper-e2e/src/test/resources/documents/sourceCsv.csv b/test-resources/src/main/resources/documents/sourceCsv.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/sourceCsv.csv rename to test-resources/src/main/resources/documents/sourceCsv.csv diff --git a/datamapper-e2e/src/test/resources/documents/sourceJson.schema.json b/test-resources/src/main/resources/documents/sourceJson.schema.json similarity index 100% rename from datamapper-e2e/src/test/resources/documents/sourceJson.schema.json rename to test-resources/src/main/resources/documents/sourceJson.schema.json diff --git a/datamapper-e2e/src/test/resources/documents/sourceJsonArray.json b/test-resources/src/main/resources/documents/sourceJsonArray.json similarity index 100% rename from datamapper-e2e/src/test/resources/documents/sourceJsonArray.json rename to test-resources/src/main/resources/documents/sourceJsonArray.json diff --git a/test-resources/src/main/resources/documents/sourceJsonSchemaInstance.json b/test-resources/src/main/resources/documents/sourceJsonSchemaInstance.json new file mode 100644 index 0000000..ff93537 --- /dev/null +++ b/test-resources/src/main/resources/documents/sourceJsonSchemaInstance.json @@ -0,0 +1,33 @@ +{ + "sourceJsonString": "sourceJsonString", + "sourceJsonInteger": 10, + "sourceJsonLong": 20.0, + "sourceJsonFloat": 30.4, + "sourceJsonDouble": 40.0, + "sourceJsonDate": "1989-05-05", + "sourceJsonBoolean": true, + "sourceJsonShort": -50, + "sourceJsonByte": 127, + "sourceJsonChar": 3, + "smallMappingTestClass": { + "objectField1": "object1", + "objectField2": "object2", + "listOfStrings": [ + "sdf", + "sdf" + ], + "listOfIntegers": [ + 10, + 20, + 30, + 40, + 50 + ], + "listOfDoubles": [ + 10.1, + 10.2, + 10.3, + 10.4 + ] + } +} diff --git a/datamapper-e2e/src/test/resources/documents/sourceXmlInstance.xml b/test-resources/src/main/resources/documents/sourceXMLInstance.xml similarity index 100% rename from datamapper-e2e/src/test/resources/documents/sourceXmlInstance.xml rename to test-resources/src/main/resources/documents/sourceXMLInstance.xml diff --git a/datamapper-e2e/src/test/resources/documents/sourceXMLSchema.xsd b/test-resources/src/main/resources/documents/sourceXMLSchema.xsd similarity index 100% rename from datamapper-e2e/src/test/resources/documents/sourceXMLSchema.xsd rename to test-resources/src/main/resources/documents/sourceXMLSchema.xsd diff --git a/test-resources/src/main/resources/documents/sourceXMLSchemaInstance.xml b/test-resources/src/main/resources/documents/sourceXMLSchemaInstance.xml new file mode 100644 index 0000000..0e969db --- /dev/null +++ b/test-resources/src/main/resources/documents/sourceXMLSchemaInstance.xml @@ -0,0 +1,13 @@ + + + true + A + A + + 100.100 + 200.200 + 300 + 400 + 500 + XmlString + diff --git a/datamapper-e2e/src/test/resources/documents/targetArrays.json b/test-resources/src/main/resources/documents/targetArrays.json similarity index 100% rename from datamapper-e2e/src/test/resources/documents/targetArrays.json rename to test-resources/src/main/resources/documents/targetArrays.json diff --git a/datamapper-e2e/src/test/resources/documents/targetCsv.csv b/test-resources/src/main/resources/documents/targetCsv.csv similarity index 100% rename from datamapper-e2e/src/test/resources/documents/targetCsv.csv rename to test-resources/src/main/resources/documents/targetCsv.csv diff --git a/datamapper-e2e/src/test/resources/documents/targetJson.schema.json b/test-resources/src/main/resources/documents/targetJson.schema.json similarity index 100% rename from datamapper-e2e/src/test/resources/documents/targetJson.schema.json rename to test-resources/src/main/resources/documents/targetJson.schema.json diff --git a/datamapper-e2e/src/test/resources/documents/targetJsonArray.json b/test-resources/src/main/resources/documents/targetJsonArray.json similarity index 100% rename from datamapper-e2e/src/test/resources/documents/targetJsonArray.json rename to test-resources/src/main/resources/documents/targetJsonArray.json diff --git a/datamapper-e2e/src/test/resources/documents/targetXMLInstance.xml b/test-resources/src/main/resources/documents/targetXMLInstance.xml similarity index 100% rename from datamapper-e2e/src/test/resources/documents/targetXMLInstance.xml rename to test-resources/src/main/resources/documents/targetXMLInstance.xml diff --git a/datamapper-e2e/src/test/resources/documents/targetXMLSchema.xsd b/test-resources/src/main/resources/documents/targetXMLSchema.xsd similarity index 100% rename from datamapper-e2e/src/test/resources/documents/targetXMLSchema.xsd rename to test-resources/src/main/resources/documents/targetXMLSchema.xsd From a217adc017bd32d0a935857193aebcbfc8d9e226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Tue, 27 Apr 2021 23:59:10 +0200 Subject: [PATCH 19/22] Use constructor injection instead of field injection --- .../atlasmap/qe/test/steps/BackendSteps.java | 2 +- .../atlasmap/qe/test/steps/ComplexSteps.java | 19 ++++++---- .../qe/test/steps/TransformationSteps.java | 8 +++-- .../io/atlasmap/qe/test/steps/UISteps.java | 12 ++++--- .../atlasmap/qe/mapper/MappingValidator.java | 36 ++++++++++--------- 5 files changed, 47 insertions(+), 30 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java index 51a6b1e..b83bef5 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java @@ -42,7 +42,7 @@ public class BackendSteps { public BackendSteps(MappingValidator validator, ResourcesGenerator resourcesGenerator) { this.validator = validator; this.resourcesGenerator = resourcesGenerator; - validator.initializeValues(resourcesGenerator.generateResourceMap()); + validator.initializeValues(resourcesGenerator.generateResourceMap()); // TODO this is bad practice } @Given("atlasmap is clean") diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/ComplexSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/ComplexSteps.java index 3e59bcd..35da000 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/ComplexSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/ComplexSteps.java @@ -17,17 +17,22 @@ @Slf4j public class ComplexSteps { - @Inject - private MappingValidator validator; + private final MappingValidator validator; - @Inject - private AtlasmapPage atlasmapPage; + private final AtlasmapPage atlasmapPage; - @Inject - private TransformationSteps transformationSteps; + private final TransformationSteps transformationSteps; + + private final BackendSteps backendSteps; @Inject - private BackendSteps backendSteps; + public ComplexSteps(MappingValidator validator, AtlasmapPage atlasmapPage, TransformationSteps transformationSteps, + BackendSteps backendSteps) { + this.validator = validator; + this.atlasmapPage = atlasmapPage; + this.transformationSteps = transformationSteps; + this.backendSteps = backendSteps; + } @When("verify in {string} transformation that {string} is transformed to {string}") public void verifyInTransformationThatIsTransformedTo(String transformation, String input, String output) throws Throwable { diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/TransformationSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/TransformationSteps.java index 7ef9af8..80f26d0 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/TransformationSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/TransformationSteps.java @@ -15,12 +15,16 @@ @Slf4j public class TransformationSteps { + private final AtlasmapPage atlasmapPage; + @Inject - private AtlasmapPage atlasmapPage; + public TransformationSteps(AtlasmapPage atlasmapPage) { + this.atlasmapPage = atlasmapPage; + } @When("add {string} transformation on {string}") public void addTransformationOn(String transformation, String sourceTarget) { - atlasmapPage.addTransformationToTargetOrSource(transformation, sourceTarget.equals("source") ? true : false); + atlasmapPage.addTransformationToTargetOrSource(transformation, sourceTarget.equals("source")); } @And("add transformation on target") diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java index 0b829ee..0eb87d7 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java @@ -25,14 +25,18 @@ @Slf4j public class UISteps { - @Inject - private MappingValidator validator; + private final MappingValidator validator; - @Inject - private AtlasmapPage atlasmapPage; + private final AtlasmapPage atlasmapPage; private boolean internalMapping = true; + @Inject + public UISteps(MappingValidator validator, AtlasmapPage atlasmapPage) { + this.validator = validator; + this.atlasmapPage = atlasmapPage; + } + @Given("atlasmap contains TestClass") public void atlasMapContainsTestClass() throws Exception { String resp = MappingUtils.requestClass(AtlasmapPage.TEST_CLASS); diff --git a/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java index b87391e..ffd69b2 100644 --- a/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java +++ b/mapping-validator/src/main/java/io/atlasmap/qe/mapper/MappingValidator.java @@ -35,11 +35,15 @@ public class MappingValidator { private Map expectedMap; private Map sourceMap; - @Inject - private AtlasMapper atlasMapper; + private final AtlasMapper atlasMapper; + + private final ConversionService conversionService; @Inject - private ConversionService conversionService; + public MappingValidator(AtlasMapper atlasMapper, ConversionService conversionService) { + this.atlasMapper = atlasMapper; + this.conversionService = conversionService; + } public void initializeValues(Map resourceMap) { source = new SourceMappingTestClass(); @@ -226,17 +230,17 @@ public void initValidator(Map resourceMap) { sourceMap.put(source.getClass().getName(), source); } - public static void main(String[] args) { - MappingValidator mv = new MappingValidator(); - if (args.length > 1) { - mv.setMappingLocation(args[0]); - Object result = null; - try { - result = mv.processMapping(args[1]); - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println(result.toString()); - } - } +// public static void main(String[] args) { +// MappingValidator mv = new MappingValidator(); +// if (args.length > 1) { +// mv.setMappingLocation(args[0]); +// Object result = null; +// try { +// result = mv.processMapping(args[1]); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// System.out.println(result.toString()); +// } +// } } From 3e0d835ee6eb63ff9d75acbbdd740c67df04aaca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuhejda?= Date: Wed, 28 Apr 2021 00:48:48 +0200 Subject: [PATCH 20/22] Support new instance/schema dialog --- .../io/atlasmap/qe/test/AtlasmapInit.java | 24 +++++++++++-------- .../io/atlasmap/qe/test/AtlasmapPage.java | 3 ++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java index 0936615..925f166 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java @@ -80,11 +80,13 @@ public class AtlasmapInit implements EventListener { page.enableTargetClass(TargetNestedCollectionClass.class.getName()); // Source documents: - page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceArrays.json"); - page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceJsonArray.json"); - page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceJson.schema.json"); - page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceXMLInstance.xml"); - page.enableSourceDocument(TestConfiguration.getDocumentsFolderPath() + "sourceXMLSchema.xsd"); + 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() {{ put("First Record As Header", "true"); @@ -92,11 +94,13 @@ public class AtlasmapInit implements EventListener { ); // Target documents: - page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetArrays.json"); - page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetJsonArray.json"); - page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetJson.schema.json"); - page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetXMLSchema.xsd"); - page.enableTargetDocument(TestConfiguration.getDocumentsFolderPath() + "targetXMLInstance.xml"); + 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() {{ put("First Record As Header", "true"); diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java index 3f1f2e8..ac165a9 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java @@ -12,6 +12,7 @@ import static com.codeborne.selenide.Selenide.$$; import com.codeborne.selenide.WebDriverRunner; +import io.atlasmap.qe.data.source.SourceMappingTestClass; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FilenameUtils; import org.openqa.selenium.By; @@ -47,7 +48,7 @@ @Component public class AtlasmapPage { - public static final String TEST_CLASS = "SourceMappingTestClass"; + public static final String TEST_CLASS = SourceMappingTestClass.class.getSimpleName(); public void refreshPage() { Selenide.refresh(); From b9b812a76503755394f697e29ed2e7ed5b7d4e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bate=C4=BE?= Date: Fri, 17 Sep 2021 12:19:40 +0200 Subject: [PATCH 21/22] WIP rebase to prod-2.2.x --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bfc54cd..839a798 100644 --- a/pom.xml +++ b/pom.xml @@ -157,7 +157,7 @@ classpath:features ${tags} - io.atlasmap.qe.test.atlas.AtlasmapInit, + io.atlasmap.qe.test.AtlasmapInit, pretty, junit:target/cucumber/cucumber-junit.xml, json:target/cucumber/cucumber-report.json, From 91fd9c7a2d4c659ada3befa74d26e7c56c0b2f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bate=C4=BE?= Date: Tue, 22 Mar 2022 09:41:55 +0100 Subject: [PATCH 22/22] WIP fixed some issues introduced due to the merge of refactoring --- .../io/atlasmap/qe/test/AtlasmapInit.java | 27 +++---- .../io/atlasmap/qe/test/AtlasmapPage.java | 77 ++++++++----------- .../atlasmap/qe/test/steps/BackendSteps.java | 8 +- .../io/atlasmap/qe/test/steps/UISteps.java | 6 +- .../atlasmap/qe/test/utils/MappingUtils.java | 9 +-- pom.xml | 2 +- 6 files changed, 54 insertions(+), 75 deletions(-) diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java index 925f166..c485311 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapInit.java @@ -1,14 +1,5 @@ package io.atlasmap.qe.test; -import io.atlasmap.qe.data.DatesObject; -import io.atlasmap.qe.data.SmallMappingTestClass; -import io.atlasmap.qe.data.StringObject; -import io.atlasmap.qe.data.source.SourceListsClass; -import io.atlasmap.qe.data.source.SourceMappingTestClass; -import io.atlasmap.qe.data.source.SourceNestedCollectionClass; -import io.atlasmap.qe.data.target.TargetListsClass; -import io.atlasmap.qe.data.target.TargetMappingTestClass; -import io.atlasmap.qe.data.target.TargetNestedCollectionClass; import io.atlasmap.qe.test.utils.MappingUtils; import io.atlasmap.qe.test.utils.TestConfiguration; import org.apache.commons.io.FileUtils; @@ -67,17 +58,17 @@ public class AtlasmapInit implements EventListener { } // Source classes: - page.enableSourceClass(SourceMappingTestClass.class.getName()); - page.enableSourceClass(DatesObject.class.getName()); - page.enableSourceClass(SourceListsClass.class.getName()); - page.enableSourceClass(SmallMappingTestClass.class.getName()); - page.enableSourceClass(SourceNestedCollectionClass.class.getName()); + 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(TargetMappingTestClass.class.getName()); - page.enableTargetClass(StringObject.class.getName()); - page.enableTargetClass(TargetListsClass.class.getName()); - page.enableTargetClass(TargetNestedCollectionClass.class.getName()); + 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"); diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java index ac165a9..79a35ae 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/AtlasmapPage.java @@ -11,12 +11,10 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; -import com.codeborne.selenide.WebDriverRunner; import io.atlasmap.qe.data.source.SourceMappingTestClass; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FilenameUtils; import org.openqa.selenium.By; -import org.openqa.selenium.Dimension; import org.openqa.selenium.Keys; import com.codeborne.selenide.CollectionCondition; @@ -27,7 +25,6 @@ import java.util.List; import java.util.Map; -import java.util.WeakHashMap; import java.util.stream.Collectors; import io.atlasmap.qe.test.utils.ByUtils; @@ -36,13 +33,6 @@ import io.atlasmap.qe.test.utils.MappingUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.interactions.ButtonReleaseAction; -import org.openqa.selenium.interactions.ClickAndHoldAction; -import org.openqa.selenium.interactions.Coordinates; -import org.openqa.selenium.interactions.Locatable; -import org.openqa.selenium.interactions.MoveMouseAction; @Slf4j @Component @@ -198,10 +188,9 @@ public void addToMappingUsingFieldPanel(String value, boolean isSource) { public void addToMappingUsingMappingDetails(String value, boolean isSource) { final String sourcesTargetsSelector = String.format("mapping-fields-detail-%s-toggle", isSource ? "Sources" : "Targets"); SelenideElement sourcesTargetsToggle = $(ByUtils.dataTestId(sourcesTargetsSelector)).waitUntil(visible, 5000); - SelenideElement input = sourcesTargetsToggle.parent().$(By.className("pf-c-form-control")); - input.clear(); - input.sendKeys(value); - $(ByUtils.dataTestId("add-field-option-" + value)).waitUntil(Condition.exist, 10000L).click(); + SelenideElement dropdown = sourcesTargetsToggle.parent().$(ByUtils.dataTestId("mapping-details-add-field")); + dropdown.shouldBe(visible).click(); + dropdown.$(By.xpath(String.format(".//*[text()=\"%s\"]", value))).click(); } public void clickOnLinkByDataTestId(String dataTestId) { @@ -209,9 +198,8 @@ public void clickOnLinkByDataTestId(String dataTestId) { } public void clickOnValueFromPicker(String value) { - SelenideElement dropdown = $(ByUtils.dataTestId("expression-field-search")); - dropdown.$(By.cssSelector(String.format("*[label=\"%s\"]", value))).click(); + dropdown.$(By.xpath(String.format(".//*[text()=\"%s\"]", value))).click(); } public void addToConditionalMapping(String condition) { @@ -220,10 +208,11 @@ public void addToConditionalMapping(String condition) { public void selectSeparator(String action) { // FIXME: report missing data-test-id - SelenideElement delimiterLabel = $(ByUtils.dataTestId("column-mapping-details-area")).$(By.tagName("label")); + SelenideElement delimiterLabel = $(ByUtils.dataTestId("column-mapping-details-area")).$(By.xpath(".//span[text()=\"Delimiter\"]")).parent(); - delimiterLabel.sibling(0).$(By.tagName("button")).shouldBe(visible).click(); - delimiterLabel.sibling(0).$(By.tagName("ul")).$(By.xpath(".//button[text()=\"" + action +"\"]")) + SelenideElement dropdown = delimiterLabel.parent().sibling(0); + dropdown.$(By.tagName("button")).shouldBe(visible).click(); + dropdown.$(By.tagName("ul")).$(By.xpath(".//button[text()=\"" + action + "\"]")) .scrollIntoView(false) .shouldBe(visible).click(); // no longer works as of 2.2.3: @@ -276,25 +265,25 @@ public void importAdmFile(String path) { $(By.className("pf-c-spinner__tail-ball")).waitUntil(disappear, 5000); } - public void enableSourceClass(String className) { + public void enableSourceClass(String pkg, String className) { $(ByUtils.dataTestId("enable-specific-java-classes-Source-button")).shouldBe(visible).click(); - enableClass(className); + enableClass(pkg, className); } - public void enableTargetClass(String className) { + public void enableTargetClass(String pkg, String className) { $(ByUtils.dataTestId("enable-specific-java-classes-Target-button")).shouldBe(visible).click(); - enableClass(className); + enableClass(pkg, className); } - private void enableClass(String className) { + private void enableClass(String pkg, String className) { SelenideElement dropdown = $(ByUtils.dataTestId("custom-class-name-form-select")).waitUntil(visible, TestConfiguration.getWaitTimeout()); - dropdown.selectOption(className); + dropdown.selectOption(pkg + "." + className); $(ByUtils.dataTestId("collection-type-form-select")).selectOption("None"); $(ByUtils.dataTestId("confirmation-dialog-confirm-button")).click(); $(ByUtils.dataTestId("expand-collapse-" + className + "-button")).waitUntil(visible, 15000); - log.info("Class successfully enabled: " + className); + log.info("Class successfully enabled: " + pkg + "." + className); } public void enableDocument(String path, boolean isSource) { @@ -426,28 +415,30 @@ public void addTransformationOnTargetOrSource(String classSelector, boolean isSo e.click(); } - public void addConstant(String type, String value) { + public void addConstant(String type, String value, String name) { $(ByUtils.dataTestId("create-constant-button")) - .waitUntil(visible, 5000).click(); + .waitUntil(visible, 5000).click(); - $(ByUtils.dataTestId("constant-value-text-input")).waitUntil(visible, TestConfiguration.getWaitTimeout()) - .sendKeys(value); + $(ByUtils.dataTestId("constant-name-text-input")).waitUntil(visible, TestConfiguration.getWaitTimeout()) + .sendKeys(name); + $(ByUtils.dataTestId("constant-value-text-input")).shouldBe(visible) + .sendKeys(value); $(ByUtils.dataTestId("constant-type-form-select")).shouldBe(visible) - .selectOption(type); + .selectOption(type); $(ByUtils.dataTestId("confirmation-dialog-confirm-button")).click(); } public void addProperty(boolean isSource, String type, String name, String scope) { final String createPropertyButton = String.format("create-%s-property-button", isSource ? "source" : "target"); $(ByUtils.dataTestId(createPropertyButton)) - .waitUntil(visible, 5000).click(); + .waitUntil(visible, 5000).click(); - $(ByUtils.dataTestId("property-name-text-input")).waitUntil(visible, TestConfiguration.getWaitTimeout()) - .sendKeys(name); + $(ByUtils.dataTestId("property-name-text-input-tooltip")).waitUntil(visible, TestConfiguration.getWaitTimeout()) + .sendKeys(name); $(ByUtils.dataTestId("property-type-form-select")).shouldBe(visible) - .selectOption(type); + .selectOption(type); $(ByUtils.dataTestId("property-scope-form-select")).waitUntil(visible, TestConfiguration.getWaitTimeout()) - .selectOption(scope); + .selectOption(scope); $(ByUtils.dataTestId("confirmation-dialog-confirm-button")).click(); } @@ -468,8 +459,8 @@ public void selectUnitToOption(String option) { private void selectFromToOption(String fromTo, String option) { SelenideElement fromToLabel = $(ByUtils.dataTestId("column-mapping-details-area")).$(By.xpath(".//label[*/text()=\"" + fromTo + "\"]")); - fromToLabel.sibling(0).$(By.tagName("button")).shouldBe(visible).click(); - fromToLabel.sibling(0).$(By.tagName("ul")).$(By.xpath(".//button[text()=\"" + option +"\"]")) + fromToLabel.parent().sibling(0).$(By.tagName("button")).shouldBe(visible).click(); + fromToLabel.parent().sibling(0).$(By.tagName("ul")).$(By.xpath(".//button[text()=\"" + option + "\"]")) .scrollIntoView(false) .shouldBe(visible).click(); } @@ -516,7 +507,7 @@ public String getPreviewValueInTable(int number, String type) { SelenideElement[] areas = record.$$(ByUtils.dataTestIdStartsWith("results-document-mapping-preview")).toArray(new SelenideElement[0]); StringBuilder output = new StringBuilder(); for (SelenideElement area : areas) { - output.append(area.getAttribute("value") + " "); + output.append(area.getAttribute("value")).append(" "); } return output.toString().trim(); } @@ -538,8 +529,8 @@ public void openAllSubfolders() { public void openAllBucketsWithName(String bucketName) { List buckets = $$(By.id(bucketName)).shouldHave(CollectionCondition.sizeGreaterThan(0)); - for (int i = 0; i < buckets.size(); i++) { - buckets.get(i).click(); + for (SelenideElement bucket : buckets) { + bucket.click(); } } @@ -648,9 +639,7 @@ private String[] parseFieldsName(String field) { if (field.startsWith("/")) { field = field.replaceFirst("/", ""); } - - String[] fields = field.split("/"); - return fields; + return field.split("/"); } private String unwrapNestedField(SelenideElement column, String[] fields) { diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java index b83bef5..db7859e 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/BackendSteps.java @@ -288,7 +288,7 @@ public void saveAndVerifyThatContainsAs(String array, String var, String path) t TargetMappingTestClass target = (TargetMappingTestClass) validator.processMapping(TargetMappingTestClass.class.getName()); if ("listOfStrings".equals(array)) { - final List strings = target.getTargetSmallMappingTestClass().getListOfStrings(); + final List strings = target.getTargetSmallMappingTestClass().getListOfStrings(); if (var.contains("listOfIntegers")) { final List integers = target.getTargetSmallMappingTestClass().getListOfIntegers(); @@ -306,7 +306,7 @@ public void saveAndVerifyThatContainsAs(String array, String var, String path) t }); } } else if ("listOfIntegers".equals(array)) { - final List integers = target.getTargetSmallMappingTestClass().getListOfIntegers(); + final List integers = target.getTargetSmallMappingTestClass().getListOfIntegers(); if ("listOfIntegers".equals(var)) { integers.forEach(i -> { resourcesGenerator.getJsonArrays("jsonIntegers").contains(i); @@ -319,7 +319,7 @@ public void saveAndVerifyThatContainsAs(String array, String var, String path) t assertThat(integers).contains(Integer.valueOf(var)); } } else if ("listOfDoubles".equals(array)) { - final List doubles = target.getTargetSmallMappingTestClass().getListOfDoubles(); + final List doubles = target.getTargetSmallMappingTestClass().getListOfDoubles(); if ("csvIntegers".equals(var)) { doubles.forEach(i -> { resourcesGenerator.getCsvArrays("csvDoubles").contains(i); @@ -397,7 +397,7 @@ public void saveAndVerifyRepeatingMappingOfJsonObjectToObjectAs(String mapping) userSavesMappingAs(mapping); final List targetObjects = ((TargetListsClass) validator .processSingleObjectMapping(resourcesGenerator.getJsonArrays(), "sourceArrays", TargetListsClass.class.getName())).getObjects(); - final List jsonObjects = resourcesGenerator.getJsonArrays("jsonObjects"); + final List jsonObjects = resourcesGenerator.getJsonArrays("jsonObjects"); for (int i = 0; i < targetObjects.size(); i++) { assertThat(targetObjects.get(i).getFirstName()).isEqualTo(((StringObject) jsonObjects.get(i)).getFirstName()); diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java index 0eb87d7..99acb2a 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/steps/UISteps.java @@ -219,9 +219,9 @@ public void checkIfDangerWarningContainsMessage(String message) { Assert.assertTrue(this.atlasmapPage.checkDangerWarningContainMessage(message)); } - @And("set {string} constant with {string} value") - public void setConstantWithValue(String type, String value) { - atlasmapPage.addConstant(type, value); + @And("set {string} constant with name {string} and value {string}") + public void setConstantWithValue(String type, String name, String value) { + atlasmapPage.addConstant(type, value, name); } @When("set {string} property of type {string}, name {string}, scope {string}") diff --git a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MappingUtils.java b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MappingUtils.java index 7392b38..d6f2225 100644 --- a/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MappingUtils.java +++ b/datamapper-e2e/src/test/java/io/atlasmap/qe/test/utils/MappingUtils.java @@ -28,8 +28,7 @@ public class MappingUtils { private static final String LIBRARY_SERVICE = TestConfiguration.getBackendUrl() + "/v2/atlas/library/list/"; public static String requestClass(String className) throws IOException { - String resp = Request.Get(LIBRARY_SERVICE).execute().returnContent().toString(); - return resp; + return Request.Get(LIBRARY_SERVICE).execute().returnContent().toString(); } /** @@ -126,14 +125,14 @@ private static void deleteFromMappingsFolder(String wildcard) throws IOException public static void insertCharByChar(String inputValue, SelenideElement inputSelector) { for (int i = 0; i < inputValue.length(); i++) { char c = inputValue.charAt(i); - String s = new StringBuilder().append(c).toString(); + String s = String.valueOf(c); inputSelector.shouldBe(visible).sendKeys(s); } } - public static void sleep(int miliseconds) { + public static void sleep(int milliseconds) { try { - Thread.sleep(miliseconds); + Thread.sleep(milliseconds); } catch (InterruptedException e) { log.error("Interruption during thread sleep : " + e.getMessage()); } diff --git a/pom.xml b/pom.xml index 839a798..2fe58d1 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 2.17 - 2.2.3.fuse-790003 + 2.3.2.fuse-7_10_1-00008 2.8.0 3.11.1 4.12