-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: CSV document does not persist with inspection parameters
Fixes: #3288
- Loading branch information
1 parent
42f30ff
commit 32e8110
Showing
5 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...eference-mappings/src/test/java/io/atlasmap/itests/reference/csv_to_java/CsvJavaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2017 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.atlasmap.itests.reference.csv_to_java; | ||
|
||
import io.atlasmap.api.AtlasContext; | ||
import io.atlasmap.api.AtlasSession; | ||
import io.atlasmap.itests.reference.AtlasMappingBaseTest; | ||
import io.atlasmap.itests.reference.AtlasTestUtil; | ||
import io.atlasmap.java.test.TargetFlatPrimitiveClass; | ||
import io.atlasmap.json.test.AtlasJsonTestUnrootedMapper; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class CsvJavaTest extends AtlasMappingBaseTest { | ||
|
||
protected TargetFlatPrimitiveClass executeMapping(String fileName) throws Exception { | ||
AtlasContext context = atlasContextFactory.createContext(new File(fileName).toURI()); | ||
AtlasSession session = context.createSession(); | ||
String source = AtlasTestUtil.loadFileAsString( | ||
"src/test/resources/csvToJava/atlasmapping-csvWithHeaders.csv"); | ||
session.setDefaultSourceDocument(source); | ||
context.process(session); | ||
|
||
assertFalse(session.hasErrors(), printAudit(session)); | ||
Object object = session.getDefaultTargetDocument(); | ||
assertNotNull(object); | ||
return (TargetFlatPrimitiveClass) object; | ||
} | ||
|
||
@Test | ||
public void testProcess() throws Exception { | ||
TargetFlatPrimitiveClass object = executeMapping("src/test/resources/csvToJava/atlasmapping-csvWithHeaders.json"); | ||
assertEquals("row0", object.getBoxedStringArrayField()[0]); | ||
assertEquals("row1", object.getBoxedStringArrayField()[1]); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
lib/itests/reference-mappings/src/test/resources/csvToJava/atlasmapping-csvWithHeaders.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sourceCsvString,sourceCsvInteger | ||
row0,0 | ||
row1,1 |
56 changes: 56 additions & 0 deletions
56
lib/itests/reference-mappings/src/test/resources/csvToJava/atlasmapping-csvWithHeaders.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"AtlasMapping" : { | ||
"jsonType" : "io.atlasmap.v2.AtlasMapping", | ||
"dataSource" : [ { | ||
"jsonType" : "io.atlasmap.v2.DataSource", | ||
"id" : "sourceCsv-c7982b9e-90b4-44ed-8b52-283e6f1e853c", | ||
"name" : "sourceCsv", | ||
"description" : "Source document sourceCsv type: CSV", | ||
"uri" : "atlas:csv:sourceCsv-c7982b9e-90b4-44ed-8b52-283e6f1e853c?firstRecordAsHeader=true", | ||
"dataSourceType" : "SOURCE" | ||
}, { | ||
"jsonType" : "io.atlasmap.v2.DataSource", | ||
"id" : "io.atlasmap.java.test.TargetFlatPrimitiveClass", | ||
"name" : "io.atlasmap.java.test.TargetFlatPrimitiveClass", | ||
"description" : "Java document class io.atlasmap.java.test.TargetFlatPrimitiveClass", | ||
"uri" : "atlas:java:io.atlasmap.java.test.TargetFlatPrimitiveClass?className=io.atlasmap.java.test.TargetFlatPrimitiveClass", | ||
"dataSourceType" : "TARGET" | ||
} ], | ||
"mappings" : { | ||
"mapping" : [ { | ||
"jsonType" : "io.atlasmap.v2.Mapping", | ||
"mappingType" : "MAP", | ||
"inputFieldGroup" : { | ||
"jsonType" : "io.atlasmap.v2.FieldGroup", | ||
"actions" : [ ], | ||
"field" : [ { | ||
"jsonType" : "io.atlasmap.csv.v2.CsvField", | ||
"docId" : "sourceCsv-c7982b9e-90b4-44ed-8b52-283e6f1e853c", | ||
"path" : "/<>/sourceCsvString", | ||
"fieldType" : "STRING", | ||
"name" : "sourceCsvString" | ||
} ] | ||
}, | ||
"inputField" : [ ], | ||
"outputField" : [ { | ||
"jsonType" : "io.atlasmap.java.v2.JavaField", | ||
"docId" : "io.atlasmap.java.test.TargetFlatPrimitiveClass", | ||
"path" : "/boxedStringArrayField<>", | ||
"fieldType" : "STRING", | ||
"name" : "boxedStringArrayField" | ||
} ], | ||
"id" : "mapping.50044" | ||
}] | ||
}, | ||
"lookupTables" : { | ||
"lookupTable" : [ ] | ||
}, | ||
"constants" : { | ||
"constant" : [ ] | ||
}, | ||
"properties" : { | ||
"property" : [ ] | ||
}, | ||
"name" : "UI.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters