-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from chathurace/main
Change EDI reading code to skip ignoreSegments before starting any processing work
- Loading branch information
Showing
11 changed files
with
108 additions
and
6 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
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
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
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,25 @@ | ||
import ballerina/test; | ||
|
||
@test:Config { | ||
dataProvider: ediModificationsDataProvider | ||
} | ||
function testSegmentModification(string testName) returns error? { | ||
EdiSchema schema = check getTestSchema(testName); | ||
string ediIn = check getEDIMessage(testName); | ||
json message = check fromEdiString(ediIn, schema); | ||
check saveJsonMessage(testName, message); | ||
|
||
string ediOut = check toEdiString(message, schema); | ||
string ediExpected = check getOutputEDI(testName); | ||
|
||
ediOut = prepareEDI(ediOut, schema); | ||
ediIn = prepareEDI(ediExpected, schema); | ||
|
||
test:assertEquals(ediOut, ediIn); | ||
} | ||
|
||
function ediModificationsDataProvider() returns string[][] { | ||
return [ | ||
["ignore_segments"] | ||
]; | ||
} |
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,9 @@ | ||
UNA:*? ~ | ||
IGN*12*tty:43~ | ||
HDR*ORDER_1201*ABC_Store*2008-01-01~ | ||
ITM*A-250*12~ | ||
ITM*A-45*100~ | ||
ITM*D-10*58~ | ||
ITM*K-80*250~ | ||
ITM*T-46*28~ | ||
UNZ*45*kk~ |
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,29 @@ | ||
{ | ||
"header": { | ||
"orderId": "ORDER_1201", | ||
"organization": "ABC_Store", | ||
"date": "2008-01-01" | ||
}, | ||
"items": [ | ||
{ | ||
"item": "A-250", | ||
"quantity": 12 | ||
}, | ||
{ | ||
"item": "A-45", | ||
"quantity": 100 | ||
}, | ||
{ | ||
"item": "D-10", | ||
"quantity": 58 | ||
}, | ||
{ | ||
"item": "K-80", | ||
"quantity": 250 | ||
}, | ||
{ | ||
"item": "T-46", | ||
"quantity": 28 | ||
} | ||
] | ||
} |
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,6 @@ | ||
HDR*ORDER_1201*ABC_Store*2008-01-01~ | ||
ITM*A-250*12~ | ||
ITM*A-45*100~ | ||
ITM*D-10*58~ | ||
ITM*K-80*250~ | ||
ITM*T-46*28~ |
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 @@ | ||
{"header":{"code":"HDR", "orderId":"ORDER_1201", "organization":"ABC_Store", "date":"2008-01-01"}, "items":[{"code":"ITM", "item":"A-250", "quantity":12}, {"code":"ITM", "item":"A-45", "quantity":100}, {"code":"ITM", "item":"D-10", "quantity":58}, {"code":"ITM", "item":"K-80", "quantity":250}, {"code":"ITM", "item":"T-46", "quantity":28}]} |
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,18 @@ | ||
{ | ||
"name": "SimpleOrder", | ||
"delimiters" : {"segment" : "~", "field" : "*", "component": ":", "repetition": "^"}, | ||
"ignoreSegments": ["UNA", "IGN", "UNZ"], | ||
"segments" : [ | ||
{ | ||
"code": "HDR", | ||
"tag" : "header", | ||
"fields" : [{"tag": "code"}, {"tag" : "orderId"}, {"tag" : "organization"}, {"tag" : "date"}] | ||
}, | ||
{ | ||
"code": "ITM", | ||
"tag" : "items", | ||
"maxOccurances" : -1, | ||
"fields" : [{"tag": "code"}, {"tag" : "item"}, {"tag" : "quantity", "dataType" : "int"}] | ||
} | ||
] | ||
} |
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
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