Skip to content

Commit

Permalink
Reset validator at end of interchange (#367)
Browse files Browse the repository at this point in the history
Fixes #366

Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar authored May 16, 2023
1 parent 3a682e0 commit 770d33b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public void interchangeEnd() {

if (validator != null) {
validator.validateLoopSyntax(this);
validator.reset();
}

enqueueEvent(EDIStreamEvent.END_INTERCHANGE, EDIStreamValidationError.NONE, "", null, location);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import io.xlate.edi.schema.SchemaFactory;
import io.xlate.edi.stream.EDIInputFactory;
import io.xlate.edi.stream.EDIStreamConstants.Delimiters;
import io.xlate.edi.test.StaEDITestUtil;
import io.xlate.edi.stream.EDIStreamEvent;
import io.xlate.edi.stream.EDIStreamException;
import io.xlate.edi.stream.EDIStreamReader;
Expand Down Expand Up @@ -2124,6 +2123,10 @@ void testMultipleInterchangesInStream() throws EDIStreamException, IOException {
case END_INTERCHANGE:
interchangeEnd++;
break;
case SEGMENT_ERROR:
case ELEMENT_OCCURRENCE_ERROR:
case ELEMENT_DATA_ERROR:
fail("Unexpected error: " + reader.getErrorType());
default:
break;
}
Expand All @@ -2132,7 +2135,7 @@ void testMultipleInterchangesInStream() throws EDIStreamException, IOException {
reader.close();
}

assertEquals(2, interchangeStart);
assertEquals(2, interchangeEnd);
assertEquals(3, interchangeStart);
assertEquals(3, interchangeEnd);
}
}
20 changes: 16 additions & 4 deletions src/test/resources/x12/simple997-multiple-interchanges.edi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ISA*00* *00* *ZZ*ReceiverID *ZZ*Sender *050812*1953*^*00501*508121953*0*P*:~
ISA*00* *00* *ZZ*ReceiverID *ZZ*Sender *050812*1953*^*00501*000000001*0*P*:~
GS*FA*ReceiverDept*SenderDept*20050812*195335*000005*X*005010X230~
ST*997*0001~
AK1*HC*000001~
Expand All @@ -9,8 +9,8 @@ AK5*R*5~
AK9*R*1*1*0~
SE*8*0001~
GE*1*000005~
IEA*1*508121953~
ISA*00* *00* *ZZ*ReceiverID *ZZ*Sender *050812*1953*^*00501*508121953*0*P*:~
IEA*1*000000001~
ISA*00* *00* *ZZ*ReceiverID *ZZ*Sender *050812*1953*^*00501*000000002*0*P*:~
GS*FA*ReceiverDept*SenderDept*20050812*195335*000005*X*005010X230~
ST*997*0001~
AK1*HC*000001~
Expand All @@ -21,4 +21,16 @@ AK5*R*5~
AK9*R*1*1*0~
SE*8*0001~
GE*1*000005~
IEA*1*508121953~
IEA*1*000000002~
ISA*00* *00* *ZZ*ReceiverID *ZZ*Sender *050812*1953*^*00501*000000003*0*P*:~
GS*FA*ReceiverDept*SenderDept*20050812*195335*000005*X*005010X230~
ST*997*0001~
AK1*HC*000001~
AK2*837*0021~
AK3*NM1*8**8~
AK4*8*66*7*MI~
AK5*R*5~
AK9*R*1*1*0~
SE*8*0001~
GE*1*000005~
IEA*1*000000003~

0 comments on commit 770d33b

Please sign in to comment.