@Test(expected = EbtsBuildingException.class) public void type7asType4TestFailure() throws Exception { Ebts ebts = new Ebts(); GenericRecord type1 = new GenericRecord(1); type1.setField(3, new Field("0400")); type1.setField(8, new Field("WVMEDS001")); GenericRecord type2 = new GenericRecord(2); type2.setField(2, new Field("04")); type2.setField(19, new Field("Smith,John")); type2.getField(19).getOccurrences().add(new Occurrence("Smith,Johnny")); type2.setField(18, new Field("Smith,Jo")); type2.setField(41, new Field("B")); type2.setField(40, new Field("A")); List<String> strings = new ArrayList<String>(); strings.add("Test1"); strings.add("Test2"); strings.add("Test3"); List<Occurrence> occs = EbtsUtils.convertStringList(strings); occs.add(new Occurrence("HI")); occs.remove(new Occurrence("HI")); type2.setField(50,new Field(occs)); int[] header = new int[]{4, 1, 1, 6, 1, 2, 2, 1}; BinaryHeaderImageRecord type7 = new BinaryHeaderImageRecord(7,header); type7.setImageData(new byte[]{}); ebts.addRecord(type1); ebts.addRecord(type2); ebts.addRecord(type7); EbtsBuilder ebtsBuilder = new EbtsBuilder(); byte[] binaryData = ebtsBuilder.build(ebts); Ebts parsedEbts = EbtsParser.parse(binaryData,Type7Handling.TREAT_AS_TYPE4); log.info("{}",parsedEbts); }
public byte[] build(final Ebts ebts) throws EbtsBuildingException { this.ebts = ebts; final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final List<LogicalRecord> records = ebts.getAllRecords(); for (final LogicalRecord record : records) { if (genericTypes.contains(record.getRecordType())) { genericBuilder((GenericRecord)record,baos); } else if (binaryHeaderTypes.contains(record.getRecordType())) { binaryHeaderBuilder((BinaryHeaderImageRecord)record,baos); } } return baos.toByteArray(); }
EbtsBuilder { public byte[] build(final Ebts ebts) throws EbtsBuildingException { this.ebts = ebts; final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final List<LogicalRecord> records = ebts.getAllRecords(); for (final LogicalRecord record : records) { if (genericTypes.contains(record.getRecordType())) { genericBuilder((GenericRecord)record,baos); } else if (binaryHeaderTypes.contains(record.getRecordType())) { binaryHeaderBuilder((BinaryHeaderImageRecord)record,baos); } } return baos.toByteArray(); } }
EbtsBuilder { public byte[] build(final Ebts ebts) throws EbtsBuildingException { this.ebts = ebts; final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final List<LogicalRecord> records = ebts.getAllRecords(); for (final LogicalRecord record : records) { if (genericTypes.contains(record.getRecordType())) { genericBuilder((GenericRecord)record,baos); } else if (binaryHeaderTypes.contains(record.getRecordType())) { binaryHeaderBuilder((BinaryHeaderImageRecord)record,baos); } } return baos.toByteArray(); } EbtsBuilder();  EbtsBuilder(final int precedingZeros); }
EbtsBuilder { public byte[] build(final Ebts ebts) throws EbtsBuildingException { this.ebts = ebts; final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final List<LogicalRecord> records = ebts.getAllRecords(); for (final LogicalRecord record : records) { if (genericTypes.contains(record.getRecordType())) { genericBuilder((GenericRecord)record,baos); } else if (binaryHeaderTypes.contains(record.getRecordType())) { binaryHeaderBuilder((BinaryHeaderImageRecord)record,baos); } } return baos.toByteArray(); } EbtsBuilder();  EbtsBuilder(final int precedingZeros); void setPrecedingZeros(final int precedingZeros); byte[] build(final Ebts ebts); }
EbtsBuilder { public byte[] build(final Ebts ebts) throws EbtsBuildingException { this.ebts = ebts; final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final List<LogicalRecord> records = ebts.getAllRecords(); for (final LogicalRecord record : records) { if (genericTypes.contains(record.getRecordType())) { genericBuilder((GenericRecord)record,baos); } else if (binaryHeaderTypes.contains(record.getRecordType())) { binaryHeaderBuilder((BinaryHeaderImageRecord)record,baos); } } return baos.toByteArray(); } EbtsBuilder();  EbtsBuilder(final int precedingZeros); void setPrecedingZeros(final int precedingZeros); byte[] build(final Ebts ebts);  }