CSVMetadataLoader extends FileWithMetadataAction implements EOCAware { public String[] readMetadataFields(CSVReader reader) throws IOException { String[] metadataFields = reader.readNext(); if(metadataFields==null) throw new RuntimeException("Empty input file"); boolean hasFile = false; for(int i=0; i < metadataFields.length; i++) { String value = getParameter(metadataFields[i]); if(value != null) metadataFields[i]=value; logger.debug("Metadata field " + i + ": " + metadataFields[i]); if(Parameters.PARAM_FILE.equals(metadataFields[i])) hasFile=true; } if(!hasFile) { throw new RuntimeException("The header should contain the 'file' parameter or there should be a mapping for one of headers parameters to 'file'"); } return metadataFields; }  @Override String getInputPath(); void setInputFile(File inputFile); CSVReader createReader(); FileInfo processLine(String[] nextLine, String[] metadataFields); String[] readMetadataFields(CSVReader reader); String getCategory(); void setNameSpace(String nameSpace); void setContentType(String contentType); @Override void beforeSendEOC();  }
@Test public final void testReadMetadataFields() throws Exception { setUp(); CSVReader reader = metadataLoader.createReader(); String[] metadataFields = metadataLoader.readMetadataFields(reader); assertEquals(4, metadataFields.length); assertEquals("path",metadataFields[0]); assertEquals("InputMetadata1",metadataFields[1]); assertEquals("InputMetadata2",metadataFields[2]); assertEquals("InputMetadata3",metadataFields[3]); reader.close(); }