### Question:
CSVService { public List<KeyPairs> fromCSV(InputStream inputStream) throws Exception { Reader reader = new InputStreamReader(inputStream); Iterable<CSVRecord> records = CSVFormat.RFC4180.withFirstRecordAsHeader().parse(reader); Iterable<CSVRecord> iterable = () -> records.iterator(); Stream<CSVRecord> stream = StreamSupport.stream(iterable.spliterator(), false); return stream.map((entry) -> { String ethAddress = entry.get(0); String btcAddress = entry.get(1); LOG.info("Reading: ETH={} BTC={}", ethAddress, btcAddress); return new KeyPairs(btcAddress, ethAddress, true); }).collect(Collectors.toList()); }  List<KeyPairs> fromCSV(InputStream inputStream);  }### Answer:
@Test public void testFromCSV() throws Exception { InputStream inputStream = CSVServiceTest.class.getResourceAsStream("/publickeys-dev.csv"); List<KeyPairs> keyPairsList = csvService.fromCSV(inputStream); assertEquals(100, keyPairsList.size()); }
@Test(expected = Exception.class) public void testFromCSV_Error_Reading_Format() throws Exception { Mockito.mock(CSVFormat.class); when(CSVFormat.DEFAULT.parse(any())).thenThrow(new Exception()); InputStream inputStream = CSVServiceTest.class.getResourceAsStream("/publickeys-dev.csv"); csvService.fromCSV(inputStream); }