FactModelGuvnorUploader { static byte[] getFileBytes(String filePath) { byte[] data = null; try { data = IOUtils.toByteArray(new FileInputStream(filePath)); } catch (FileNotFoundException e) { LOGGER.error("ERROR: File not found"); LOGGER.error(e.getMessage(), e); } catch (IOException e) { LOGGER.error("ERROR: IOException"); LOGGER.error(e.getMessage(), e); } return data; }  static void main(String[] args);  }
@Test public void testGetFileBytes() { String testFilePath = "src/test/resources/testFile.txt"; byte[] bytes = FactModelGuvnorUploader.getFileBytes(testFilePath); assertEquals(116, bytes[0]); assertEquals(101, bytes[1]); assertEquals(115, bytes[2]); assertEquals(116, bytes[3]); }
@Test public void testGetFileBytes_Throws_FileNotFoundException() { String testFilePath = "src/test/resources/DoesntExist.txt"; byte[] bytes = FactModelGuvnorUploader.getFileBytes(testFilePath); assertNull(bytes); }