### Question:
ProdRecordProcessor implements RecordProcessor<ProdData> { public ProdData process(String[] col) throws BadDataException { if (col.length < 7) { throw new BadDataException("too few columns"); } else if (col.length > 7) { throw new BadDataException("too many columns"); } Integer code = null; try { code = Integer.valueOf(col[0]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (code < 0) { throw new BadDataException("code < 0"); } return new ProdData(code, col[1], col[2], col[3], col[4], col[5], col[6]); }  ProdData process(String[] col);  }### Answer:
@Test(expected=BadDataException.class) public void processTooFewCols() throws BadDataException { final RecordProcessor<ProdData> proc = new ProdRecordProcessor(); proc.process(new String[] { "foo" }); }
@Test(expected=BadDataException.class) public void processTooManyCols() throws BadDataException { final RecordProcessor<ProdData> proc = new ProdRecordProcessor(); final String[] cols = new String[9]; Arrays.fill(cols, "foo"); proc.process(cols); }
@Test public void processJustRightCols() throws BadDataException { final ProdData pd = new ProdData(code, name, version, os_code, mfg_code, language, app_type); final RecordProcessor<ProdData> proc = new ProdRecordProcessor(); assertEquals(pd, proc.process(new String[] { String.valueOf(code), name, version, os_code, mfg_code, language, app_type })); }
@Test(expected=BadDataException.class) public void processNonnumericCode() throws BadDataException { final RecordProcessor<ProdData> proc = new ProdRecordProcessor(); proc.process(new String[] { "not a number", "", "", "", "", "", "" }); }
@Test(expected=BadDataException.class) public void processNegativeCode() throws BadDataException { final RecordProcessor<ProdData> proc = new ProdRecordProcessor(); proc.process(new String[] { "-1", "", "", "", "", "", "" }); }