### Question:
GenericPackager extends ISOBasePackager implements Configurable { @Override protected int getFirstField() { if (firstField != null) return Integer.parseInt (firstField); else return super.getFirstField(); } GenericPackager();  GenericPackager(String filename);  GenericPackager(InputStream input); void setConfiguration(Configuration cfg); void readFile(String filename); void readFile(InputStream input); @Override void setLogger(Logger logger, String realm); @Override String getDescription();  }### Answer:
@Test public void testGetFirstField() throws Throwable { GenericPackager genericValidatingPackager = new GenericValidatingPackager(); ISOFieldPackager[] fld = new ISOFieldPackager[3]; fld[1] = new IFA_BITMAP(); genericValidatingPackager.setFieldPackager(fld); int result = genericValidatingPackager.getFirstField(); assertEquals(2, result, "result"); }
@Test public void testGetFirstField1() throws Throwable { GenericPackager genericPackager = new GenericPackager(); ISOFieldPackager[] fld = new ISOFieldPackager[3]; genericPackager.setFieldPackager(fld); int result = genericPackager.getFirstField(); assertEquals(1, result, "result"); }
@Test public void testGetFirstFieldThrowsArrayIndexOutOfBoundsException() throws Throwable { GenericPackager genericValidatingPackager = new GenericValidatingPackager(); ISOFieldPackager[] fld = new ISOFieldPackager[1]; genericValidatingPackager.setFieldPackager(fld); assertEquals(0, genericValidatingPackager.getFirstField()); }
@Test public void testGetFirstFieldThrowsNullPointerException() throws Throwable { GenericPackager genericPackager = new GenericPackager(); try { genericPackager.getFirstField(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot load from object array because \"this.fld\" is null", ex.getMessage(), "ex.getMessage()"); } } }