Giter Site home page Giter Site logo

Comments (5)

ctmay4 avatar ctmay4 commented on July 24, 2024

I created a test that is working in SegmentTest. It uses the new helper method which is not released, but you could easily just replace the two string addElement with new Element(id, value). Please look at that. It runs properly in the integration tests.

@Test
void testReadmeExample() {
    Loop isaLoop = new Loop("ISA_LOOP");

    Segment segment = new Segment("ISA");
    segment.addElement("01", "00");
    segment.addElement("02", "          ");
    segment.addElement("03", "01");
    segment.addElement("04", "SECRET    ");
    segment.addElement("05", "ZZ");
    segment.addElement("06", "SUBMITTERS.ID  ");
    segment.addElement("07", "ZZ");
    segment.addElement("08", "RECEIVERS.ID   ");
    segment.addElement("09", "030101");
    segment.addElement("10", "1253");
    segment.addElement("11", "U");
    segment.addElement("12", "00501");
    segment.addElement("13", "000000905");
    segment.addElement("14", "1");
    segment.addElement("15", "T");
    segment.addElement("16", ":");
    isaLoop.addSegment(segment);

    segment = new Segment("IEA");
    segment.addElement("01", "1");
    segment.addElement("02", "000000905");
    isaLoop.addSegment(segment);

    assertEquals(2, isaLoop.getSegments().size());
}

from x12-parser.

ModemMisuser avatar ModemMisuser commented on July 24, 2024

I created a test that is working in SegmentTest. It uses the new helper method which is not released, but you could easily just replace the two string addElement with new Element(id, value). Please look at that. It runs properly in the integration tests.

@Test
void testReadmeExample() {
    Loop isaLoop = new Loop("ISA_LOOP");

    Segment segment = new Segment("ISA");
    segment.addElement("01", "00");
    segment.addElement("02", "          ");
    segment.addElement("03", "01");
    segment.addElement("04", "SECRET    ");
    segment.addElement("05", "ZZ");
    segment.addElement("06", "SUBMITTERS.ID  ");
    segment.addElement("07", "ZZ");
    segment.addElement("08", "RECEIVERS.ID   ");
    segment.addElement("09", "030101");
    segment.addElement("10", "1253");
    segment.addElement("11", "U");
    segment.addElement("12", "00501");
    segment.addElement("13", "000000905");
    segment.addElement("14", "1");
    segment.addElement("15", "T");
    segment.addElement("16", ":");
    isaLoop.addSegment(segment);

    segment = new Segment("IEA");
    segment.addElement("01", "1");
    segment.addElement("02", "000000905");
    isaLoop.addSegment(segment);

    assertEquals(2, isaLoop.getSegments().size());
}

The index parameter also has to be an int, not a String; I had to remove the quotes to even get it to compile.

I am still getting IndexOutOfBoundsException when using lines of the form,

    segment.addElement(1, new Element("00", "00"));

from x12-parser.

ctmay4 avatar ctmay4 commented on July 24, 2024

That is a different issue. The elements are stored as a collection on the segment. You cannot add at a specific index if it doesn't already exist. To be honest, the addElement at a specific index method should probably just be removed.

Just use it without the index and if it is the first one it will be added at the first index.

segment.addElement(new Element("00", "00"));

This library has been used much more for reading X12 files. The APIs for creating new files could definitely be cleaned up.

from x12-parser.

ModemMisuser avatar ModemMisuser commented on July 24, 2024

That is a different issue. The elements are stored as a collection on the segment. You cannot add at a specific index if it doesn't already exist. To be honest, the addElement at a specific index method should probably just be removed.

Just use it without the index and if it is the first one it will be added at the first index.

segment.addElement(new Element("00", "00"));

This library has been used much more for reading X12 files. The APIs for creating new files could definitely be cleaned up.

Fair enough. I need to mainly create files, so I'll probably be extending the heck out of this. Things like automatically adding the SE for an ST with the proper count and such... that should all be automatic.

from x12-parser.

ctmay4 avatar ctmay4 commented on July 24, 2024

I understand. As I said, we developed this because we needed to read different types of X12 files. The creation APIs were basically added to allow us to more easily unit test.

from x12-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.