Skip to content

Commit

Permalink
fix some inspections (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelaszek committed Jun 16, 2020
1 parent 46f5ee5 commit 9c4712c
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions src/test/java/com/imsweb/x12/reader/X12ReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,13 @@
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.apache.commons.io.IOUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.junit.Assert;
import org.junit.Test;

import com.imsweb.x12.Element;
import com.imsweb.x12.LineBreak;
import com.imsweb.x12.Loop;
import com.imsweb.x12.X12;
import com.imsweb.x12.mapping.TransactionDefinition;
import com.imsweb.x12.reader.X12Reader.FileType;
import com.imsweb.x12.writer.X12Writer;

public class X12ReaderTest {

Expand All @@ -53,7 +46,7 @@ public void testConstructors() throws IOException {
assertEquals(fromFileUtf8.getLoops().get(0).toString(), fromInputStreamUtf8.getLoops().get(0).toString());
assertEquals(fromFileUtf8.getLoops().get(0).toString(), fromReaderUtf8.getLoops().get(0).toString());
}

@Test
public void testMultipleGSLoops() throws Exception {
URL url = this.getClass().getResource("/837_5010/x12_multiple_gs.txt");
Expand Down Expand Up @@ -146,7 +139,7 @@ public void testWithInputStreamConstructor() throws Exception {

validate837Valid(reader.getLoops().get(0));
}

@Test
public void testBadValidCode() throws Exception {
URL url = this.getClass().getResource("/837_5010/x12_bad_valid_code.txt");
Expand Down Expand Up @@ -944,14 +937,14 @@ public void testComplex() throws Exception {
assertNotNull(loop.getLoop("ST_LOOP", 0).getSegment("ST"));
assertEquals("837", loop.getLoop("ST_LOOP", 0).getSegment("ST").getElementValue("ST01"));
assertEquals("987654", loop.getLoop("ST_LOOP", 0).getSegment("ST").getElementValue("ST02"));
assertNotNull(loop.getLoop("ST_LOOP",0).getSegment("SE"));
assertNotNull(loop.getLoop("ST_LOOP", 0).getSegment("SE"));
assertEquals("25", loop.getLoop("ST_LOOP", 0).getSegment("SE").getElementValue("SE01"));
assertEquals("987654", loop.getLoop("ST_LOOP", 0).getSegment("SE").getElementValue("SE02"));

assertNotNull(loop.getLoop("ST_LOOP", 1).getSegment("ST"));
assertEquals("837", loop.getLoop("ST_LOOP", 1).getSegment("ST").getElementValue("ST01"));
assertEquals("987655", loop.getLoop("ST_LOOP", 1).getSegment("ST").getElementValue("ST02"));
assertNotNull(loop.getLoop("ST_LOOP",1).getSegment("SE"));
assertNotNull(loop.getLoop("ST_LOOP", 1).getSegment("SE"));
assertEquals("26", loop.getLoop("ST_LOOP", 1).getSegment("SE").getElementValue("SE01"));
assertEquals("987655", loop.getLoop("ST_LOOP", 1).getSegment("SE").getElementValue("SE02"));

Expand Down Expand Up @@ -1295,14 +1288,14 @@ public void testX223Repeated2320() throws Exception {
Assert.assertEquals(1, loop.getLoop("2000B").getLoop("2320", 0).findLoop("2330B").size());
Assert.assertEquals(1, loop.getLoop("2000B").getLoop("2320", 1).findLoop("2330A").size());
Assert.assertEquals(1, loop.getLoop("2000B").getLoop("2320", 1).findLoop("2330B").size());
Assert.assertEquals("S", loop.getLoop("2320",0).getSegment(0).getElement("SBR01").getValue());
Assert.assertEquals("T", loop.getLoop("2320",1).getSegment(0).getElement("SBR01").getValue());
Assert.assertEquals("JOHN", loop.getLoop("2320",0).getLoop("2330A").getSegment(0).getElement("NM104").getValue());
Assert.assertEquals("JANE", loop.getLoop("2320",1).getLoop("2330A").getSegment(0).getElement("NM104").getValue());
Assert.assertEquals("AETNA", loop.getLoop("2320",0).getLoop("2330B").getSegment(0).getElement("NM103").getValue());
Assert.assertEquals("ANOTHER NAME", loop.getLoop("2320",1).getLoop("2330B").getSegment(0).getElement("NM103").getValue());
Assert.assertEquals("S", loop.getLoop("2320", 0).getSegment(0).getElement("SBR01").getValue());
Assert.assertEquals("T", loop.getLoop("2320", 1).getSegment(0).getElement("SBR01").getValue());
Assert.assertEquals("JOHN", loop.getLoop("2320", 0).getLoop("2330A").getSegment(0).getElement("NM104").getValue());
Assert.assertEquals("JANE", loop.getLoop("2320", 1).getLoop("2330A").getSegment(0).getElement("NM104").getValue());
Assert.assertEquals("AETNA", loop.getLoop("2320", 0).getLoop("2330B").getSegment(0).getElement("NM103").getValue());
Assert.assertEquals("ANOTHER NAME", loop.getLoop("2320", 1).getLoop("2330B").getSegment(0).getElement("NM103").getValue());
}

@Test
public void test277CAAccepted() throws Exception {
URL url = this.getClass().getResource("/837_5010/x12_277CA_accepted.txt");
Expand Down Expand Up @@ -1331,7 +1324,7 @@ public void test277CAAccepted() throws Exception {
Assert.assertEquals("Should be able to see a approval status code - CSCC", "A2", statusCodeElement.getSubValues().get(0));
Assert.assertEquals("Should be able to see a approval status code - CSC", "20", statusCodeElement.getSubValues().get(1));
}

@Test
public void test277CARejected() throws Exception {
URL url = this.getClass().getResource("/837_5010/x12_277CA_rejected.txt");
Expand All @@ -1353,7 +1346,7 @@ public void test277CARejected() throws Exception {
Assert.assertEquals("Should be able to see a approval status code - CSC", "562", statusCodeElement.getSubValues().get(1));
Assert.assertEquals("Should be able to see a approval status code - EIC", "85", statusCodeElement.getSubValues().get(2));
}

@Test
public void test999Accepted() throws Exception {
URL url = this.getClass().getResource("/837_5010/x12_999_accepted.txt");
Expand All @@ -1364,9 +1357,9 @@ public void test999Accepted() throws Exception {
Loop loop = reader.getLoops().get(0);
assertEquals(1, loop.getLoops().size());
Assert.assertEquals("A", loop.getLoop("GS_LOOP").getLoop("ST_LOOP").getLoop("HEADER").getLoop("2000").getSegment("IK5").getElement("IK501").getValue());

}

@Test
public void test999Rejected() throws Exception {
URL url = this.getClass().getResource("/837_5010/x12_999_rejected.txt");
Expand All @@ -1377,6 +1370,6 @@ public void test999Rejected() throws Exception {
Loop loop = reader.getLoops().get(0);
assertEquals(1, loop.getLoops().size());
Assert.assertEquals("R", loop.getLoop("GS_LOOP").getLoop("ST_LOOP").getLoop("HEADER").getLoop("2000").getSegment("IK5").getElement("IK501").getValue());

}
}

0 comments on commit 9c4712c

Please sign in to comment.