CoderUtil { static <T> T findFirstValidInput(T[] inputs) { for (T input : inputs) { if (input != null) { return input; } } throw new HadoopIllegalArgumentException( "Invalid inputs are found, all being null"); } private  CoderUtil();   }
@Test public void testFindFirstValidInput() { byte[][] inputs = new byte[numInputs][]; inputs[8] = ByteBuffer.allocate(4).putInt(1234).array(); byte[] firstValidInput = CoderUtil.findFirstValidInput(inputs); assertEquals(firstValidInput, inputs[8]); }
@Test(expected = HadoopIllegalArgumentException.class) public void testNoValidInput() { byte[][] inputs = new byte[numInputs][]; CoderUtil.findFirstValidInput(inputs); }