// Path: copybook4java/src/main/java/com/nordea/oss/copybook/CopyBookSerializer.java
// public class CopyBookSerializer {
//     private CopyBookMapper serializer;
// 
//     public CopyBookSerializer(Class<?> type) {
//         this(type, false);
//     }
// 
//     public CopyBookSerializer(Class<?> type, boolean debug) {
//         this(type, null, debug);
//     }
// 
//     public CopyBookSerializer(Class<?> type, Class<CopyBookMapper> mapper, boolean debug) {
//         CopyBookParser parser = new CopyBookParser(type, debug);
//         try {
//             if(mapper != null) {
//                 serializer = mapper.getDeclaredConstructor().newInstance();
// 
//             } else {
//                 serializer = parser.getSerializerClass().getDeclaredConstructor().newInstance();
//             }
//             serializer.initialize(parser.getConfig());
// 
//         } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
//             throw new CopyBookException("Failed to load Serialization class("+ parser.getSerializerClass().getSimpleName() +")", e);
//         }
//     }
// 
//     public <T> byte[] serialize(T obj) {
//         return serializer.serialize(obj);
//     }
// 
//     public <T> T deserialize(byte[] bytes, Class<T> type) {
//         return serializer.deserialize(bytes, type);
//     }
// 
//     public <T> T deserialize(InputStream inputStream, Class<T> type) throws IOException {
//         return deserialize(ByteUtils.toByteArray(inputStream), type);
//     }
// 
//     public List<CopyBookException> getErrors() {
//         return null; // TODO: Implement depending on errorValue
//     }
// 
//     public int getMinRecordSize() {
//         return serializer.getMinRecordSize();
//     }
// 
//     public int getMaxRecordSize() {
//         return serializer.getMaxRecordSize();
//     }
// 
// }


import com.nordea.oss.copybook.CopyBookSerializer;
import com.nordea.oss.copybook.annotations.CopyBook;
import com.nordea.oss.copybook.annotations.CopyBookLine;
import java.math.BigDecimal;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertArrayEquals;
    @CopyBook(type = FullLastArrayShortMapper.class)
    static public class DecimalFieldOccursTwoTimes {
        @CopyBookLine("01 COUNT PIC 9.")
        public int fields_count;
        @CopyBookLine("01 FIELDS OCCURS 10 TIMES PIC 9(3)V9(2).")
        public BigDecimal[] fields;
    }

    @org.junit.Test
    public void testDecimalFieldOccursTwoTimes() throws Exception {
        CopyBookSerializer serializer = new CopyBookSerializer(DecimalFieldOccursTwoTimes.class);
        DecimalFieldOccursTwoTimes test = new DecimalFieldOccursTwoTimes();
        test.fields = new BigDecimal[] {new BigDecimal("1.00"), new BigDecimal("2.00")};
        test.fields_count = test.fields.length;
        byte[] testBytes = serializer.serialize(test);
        assertEquals(1 + 5 * test.fields_count, testBytes.length);
        DecimalFieldOccursTwoTimes test2 = serializer.deserialize(testBytes, DecimalFieldOccursTwoTimes.class);
        assertArrayEquals(test.fields, test2.fields);
    }

    @CopyBook(type = FullLastArrayShortMapper.class)
    static public class SignedDecimalFieldOccursTwoTimes {
        @CopyBookLine("01 COUNT PIC 9.")
        public int fields_count;
        @CopyBookLine("01 FIELDS OCCURS 10 TIMES PIC S9(3)V9(2).")
        public BigDecimal[] fields;
    }

    @org.junit.Test
    public void testSignedDecimalFieldOccursTwoTimes() throws Exception {
// Path: copybook4java/src/main/java/com/nordea/oss/copybook/CopyBookSerializer.java
// public class CopyBookSerializer {
//     private CopyBookMapper serializer;
// 
//     public CopyBookSerializer(Class<?> type) {
//         this(type, false);
//     }
// 
//     public CopyBookSerializer(Class<?> type, boolean debug) {
//         this(type, null, debug);
//     }
// 
//     public CopyBookSerializer(Class<?> type, Class<CopyBookMapper> mapper, boolean debug) {
//         CopyBookParser parser = new CopyBookParser(type, debug);
//         try {
//             if(mapper != null) {
//                 serializer = mapper.getDeclaredConstructor().newInstance();
// 
//             } else {
//                 serializer = parser.getSerializerClass().getDeclaredConstructor().newInstance();
//             }
//             serializer.initialize(parser.getConfig());
// 
//         } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
//             throw new CopyBookException("Failed to load Serialization class("+ parser.getSerializerClass().getSimpleName() +")", e);
//         }
//     }
// 
//     public <T> byte[] serialize(T obj) {
//         return serializer.serialize(obj);
//     }
// 
//     public <T> T deserialize(byte[] bytes, Class<T> type) {
//         return serializer.deserialize(bytes, type);
//     }
// 
//     public <T> T deserialize(InputStream inputStream, Class<T> type) throws IOException {
//         return deserialize(ByteUtils.toByteArray(inputStream), type);
//     }
// 
//     public List<CopyBookException> getErrors() {
//         return null; // TODO: Implement depending on errorValue
//     }
// 
//     public int getMinRecordSize() {
//         return serializer.getMinRecordSize();
//     }
// 
//     public int getMaxRecordSize() {
//         return serializer.getMaxRecordSize();
//     }
// 
// }


// Path: copybook4java/src/test/java/com/nordea/oss/copybook/serializers/CopyBookFullLastArrayShortSerializerTest.java
import com.nordea.oss.copybook.CopyBookSerializer;
import com.nordea.oss.copybook.annotations.CopyBook;
import com.nordea.oss.copybook.annotations.CopyBookLine;
import java.math.BigDecimal;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertArrayEquals;

    @CopyBook(type = FullLastArrayShortMapper.class)
    static public class DecimalFieldOccursTwoTimes {
        @CopyBookLine("01 COUNT PIC 9.")
        public int fields_count;
        @CopyBookLine("01 FIELDS OCCURS 10 TIMES PIC 9(3)V9(2).")
        public BigDecimal[] fields;
    }

    @org.junit.Test
    public void testDecimalFieldOccursTwoTimes() throws Exception {
        CopyBookSerializer serializer = new CopyBookSerializer(DecimalFieldOccursTwoTimes.class);
        DecimalFieldOccursTwoTimes test = new DecimalFieldOccursTwoTimes();
        test.fields = new BigDecimal[] {new BigDecimal("1.00"), new BigDecimal("2.00")};
        test.fields_count = test.fields.length;
        byte[] testBytes = serializer.serialize(test);
        assertEquals(1 + 5 * test.fields_count, testBytes.length);
        DecimalFieldOccursTwoTimes test2 = serializer.deserialize(testBytes, DecimalFieldOccursTwoTimes.class);
        assertArrayEquals(test.fields, test2.fields);
    }

    @CopyBook(type = FullLastArrayShortMapper.class)
    static public class SignedDecimalFieldOccursTwoTimes {
        @CopyBookLine("01 COUNT PIC 9.")
        public int fields_count;
        @CopyBookLine("01 FIELDS OCCURS 10 TIMES PIC S9(3)V9(2).")
        public BigDecimal[] fields;
    }

    @org.junit.Test
    public void testSignedDecimalFieldOccursTwoTimes() throws Exception {
        CopyBookSerializer serializer = new CopyBookSerializer(SignedDecimalFieldOccursTwoTimes.class);