Skip to content

Commit

Permalink
Revert "Change ASN 856 parsing error messages (#153)" (#154)
Browse files Browse the repository at this point in the history
* Revert "Change ASN 856 parsing error messages (#153)"

This reverts commit 694f2cd.

* don't update version
  • Loading branch information
x0l08og authored Nov 8, 2024
1 parent 694f2cd commit 33a6f0c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ private void parseShipmentLoop(X12Loop unparsedLoop, AsnTransactionSet asnTx) {
}
} else {
asnTx.addX12ErrorDetailForLoop(
new X12ErrorDetail("HL", "03", "Invalid Looping Structure",
"first HL is not a shipment it was " + unparsedLoop.getCode()));
new X12ErrorDetail("HL", "03", "first HL is not a shipment it was " + unparsedLoop.getCode()));
}
}

Expand Down Expand Up @@ -248,7 +247,7 @@ private void parseOrderLoop(X12Loop unparsedLoop, Shipment shipment, AsnTransact

} else {
asnTx.addX12ErrorDetailForLoop(
new X12ErrorDetail("HL", "03", "Invalid Looping Structure", "expected Order HL but got " + unparsedLoop.getCode()));
new X12ErrorDetail("HL", "03", "Unexpected child loop", "expected Order HL but got " + unparsedLoop.getCode()));
}
}

Expand Down Expand Up @@ -681,8 +680,7 @@ protected void handleLooping(SegmentIterator segments, AsnTransactionSet asnTx)
} else {
// doesn't start w/ HL
asnTx.addX12ErrorDetailForLoop(
new X12ErrorDetail(currentSegment.getIdentifier(), null, "Invalid Looping Structure",
"missing shipment loop"));
new X12ErrorDetail(currentSegment.getIdentifier(), null, "missing shipment loop"));
// we should back it up
// and let the parser keep going
// with that segment
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/walmartlabs/x12/util/loop/X12LoopUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@

public final class X12LoopUtil {

private static final String INVALID_LOOPING_STRUCTURE_ERROR = "Invalid Looping Structure";

private static final String MISSING_PARENT_ERROR = "HL segment is missing parent";
private static final String ALREADY_EXISTS_ERROR = "HL segment already exists";

/**
* check the segment for the start of HL
* @param segment
Expand Down Expand Up @@ -169,14 +170,14 @@ private static X12ErrorDetail loopAlreadyExistsErrorDetail(X12Loop loop) {
sb.append("HL segment with id (")
.append(loop.getHierarchicalId())
.append(") already exists");
return new X12ErrorDetail(X12Loop.HIERARCHY_LOOP_ID, null, INVALID_LOOPING_STRUCTURE_ERROR, sb.toString());
return new X12ErrorDetail(X12Loop.HIERARCHY_LOOP_ID, null, ALREADY_EXISTS_ERROR, sb.toString());
}

private static X12ErrorDetail loopMissingParentErrorDetail(X12Loop loop) {
StringBuilder sb = new StringBuilder();
sb.append("HL segment with id (").append(loop.getHierarchicalId()).append(")");
sb.append(" is missing parent (").append(loop.getParentHierarchicalId()).append(")");
return new X12ErrorDetail(X12Loop.HIERARCHY_LOOP_ID, null, INVALID_LOOPING_STRUCTURE_ERROR, sb.toString());
return new X12ErrorDetail(X12Loop.HIERARCHY_LOOP_ID, null, MISSING_PARENT_ERROR, sb.toString());
}

private X12LoopUtil() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void test_Parsing_Asn856_badLoops() throws IOException {
X12ErrorDetail loopError = loopErrors.get(0);
assertEquals("HL", loopError.getSegmentId());
assertNull(loopError.getElementId());
assertEquals("Invalid Looping Structure", loopError.getIssueText());
assertEquals("HL segment is missing parent", loopError.getIssueText());
assertEquals("HL segment with id (2) is missing parent (99)", loopError.getInvalidValue());

// BSN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ public void test_doParse_NoHierarchicalLoops() {
List<X12ErrorDetail> loopErrors = asnTx.getLoopingErrors();
assertNotNull(loopErrors);
assertEquals(1, loopErrors.size());
assertEquals("Invalid Looping Structure", loopErrors.get(0).getIssueText());
assertEquals("missing shipment loop", loopErrors.get(0).getInvalidValue());
assertEquals("missing shipment loop", loopErrors.get(0).getIssueText());

// BSN
assertEquals("05755986", asnTx.getShipmentIdentification());
Expand All @@ -176,8 +175,7 @@ public void test_doParse_FirstLoop_NotShipment() {
// looping check
List<X12ErrorDetail> loopErrors = asnTx.getLoopingErrors();
assertEquals(1, loopErrors.size());
assertEquals("Invalid Looping Structure", loopErrors.get(0).getIssueText());
assertEquals("first HL is not a shipment it was X", loopErrors.get(0).getInvalidValue());
assertEquals("first HL is not a shipment it was X", loopErrors.get(0).getIssueText());

// BSN
assertEquals("05755986", asnTx.getShipmentIdentification());
Expand All @@ -195,7 +193,7 @@ public void test_doParseSecondLoop_NotOrder() {
// looping check
List<X12ErrorDetail> loopErrors = asnTx.getLoopingErrors();
assertEquals(1, loopErrors.size());
assertEquals("Invalid Looping Structure", loopErrors.get(0).getIssueText());
assertEquals("Unexpected child loop", loopErrors.get(0).getIssueText());
assertEquals("expected Order HL but got X", loopErrors.get(0).getInvalidValue());

// BSN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@ public void test_Parsing_AdvanceShipNoticeDocument_bad_loop() {
assertNotNull(loopErrors);
assertEquals(2, loopErrors.size());
// loop error 1
assertEquals("Invalid Looping Structure", loopErrors.get(0).getIssueText());
assertEquals("HL segment already exists", loopErrors.get(0).getIssueText());
assertEquals("HL segment with id (1) already exists", loopErrors.get(0).getInvalidValue());
// loop error 2
assertEquals("Invalid Looping Structure", loopErrors.get(1).getIssueText());
assertEquals("HL segment is missing parent", loopErrors.get(1).getIssueText());
assertEquals("HL segment with id (3) is missing parent (2)", loopErrors.get(1).getInvalidValue());

// Shipment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public void test_findHierarchicalLoops_one_loop_missing_parent() {
X12ErrorDetail loopError = loopErrors.get(0);
assertEquals("HL", loopError.getSegmentId());
assertNull(loopError.getElementId());
assertEquals("Invalid Looping Structure", loopError.getIssueText());
assertEquals("HL segment is missing parent", loopError.getIssueText());
assertEquals("HL segment with id (4) is missing parent (3)", loopError.getInvalidValue());
}

Expand Down Expand Up @@ -347,7 +347,7 @@ public void test_findHierarchicalLoops_one_loop_repeated_id() {
X12ErrorDetail loopError = loopErrors.get(0);
assertEquals("HL", loopError.getSegmentId());
assertNull(loopError.getElementId());
assertEquals("Invalid Looping Structure", loopError.getIssueText());
assertEquals("HL segment already exists", loopError.getIssueText());
assertEquals("HL segment with id (2) already exists", loopError.getInvalidValue());
}

Expand Down

0 comments on commit 33a6f0c

Please sign in to comment.