### Question:
CTCSubFieldPackager extends ISOBaseValidatingPackager { public int unpack ( ISOComponent m, byte[] b ) throws ISOException { LogEvent evt = new LogEvent ( this, "unpack" ); int consumed = 0; for ( int i=0; consumed < b.length ; i++ ) { ISOComponent c = fld[i].createComponent( i ); consumed += fld[i].unpack ( c, b, consumed ); if ( logger != null ) { evt.addMessage ("<unpack fld=\"" + i +"\" packager=\"" +fld[i].getClass().getName()+ "\">"); evt.addMessage (" <value>" +c.getValue().toString() + "</value>"); evt.addMessage ("</unpack>"); } m.set(c); } Logger.log (evt); return consumed; } CTCSubFieldPackager(); byte[] pack( ISOComponent c ); int unpack( ISOComponent m, byte[] b ); ISOComponent validate( ISOComponent c );  }### Answer:
@Test public void testUnpack() throws Throwable { byte[] b = new byte[0]; int result = new CTCSubFieldPackager().unpack(new ISOField(), b); assertEquals(0, result, "result"); }
@Test public void testUnpackThrowsISOException() throws Throwable { CTCSubFieldPackager cTCSubFieldPackager = new CTCSubFieldPackager(); ISOFieldPackager[] fld = new ISOFieldPackager[6]; fld[0] = new IFA_LLLLCHAR(100, "testCTCSubFieldPackagerDescription"); cTCSubFieldPackager.setFieldPackager(fld); byte[] b = new byte[4]; try { cTCSubFieldPackager.unpack(new ISOField(), b); fail("Expected ISOException to be thrown"); } catch (ISOException ex) { assertEquals("org.jpos.iso.IFA_LLLLCHAR: Problem unpacking field 0", ex.getMessage(), "ex.getMessage()"); assertEquals("Invalid character found. Expected digit.", ex.getNested().getMessage(), "ex.getNested().getMessage()"); } }
@Test public void testUnpackThrowsNullPointerException() throws Throwable { assertThrows(NullPointerException.class, () -> { ISOFieldPackager[] fld = new ISOFieldPackager[4]; fld[0] = new IFE_CHAR(); CTCSubFieldPackager cTCSubFieldPackager = new CTCSubFieldPackager(); cTCSubFieldPackager.setFieldPackager(fld); byte[] b = new byte[2]; cTCSubFieldPackager.unpack(null, b); }); }
@Test public void testUnpackThrowsNullPointerException2() throws Throwable { assertThrows(NullPointerException.class, () -> { new CTCSubFieldPackager().unpack(new ISOBinaryField(100), (byte[]) null); }); }