@Test public void exceptionHandlingRequiredFilesMissing() throws Exception { TakstParser takstParser = new TakstParser(); File dir = FileUtils.toFile(getClass().getClassLoader().getResource("data/incomplete/")); try { takstParser.parseFiles(dir.listFiles()); fail("expected the parser to complain about missing file"); } catch (ParserException e) { assertTrue(e.getMessage().contains("lms28.txt")); // the missing file } }
@Test public void exceptionHandlingUnparsable() throws Exception { TakstParser takstParser = new TakstParser(); File dir = FileUtils.toFile(getClass().getClassLoader().getResource("data/unparsable/")); try { takstParser.parseFiles(dir.listFiles()); fail("expected the parser to complain about missing file"); } catch (ParserException e) { assertTrue(e.getMessage().contains("8100009555S")); // the offending value assertTrue(e.getMessage().contains("Laegemiddel")); // the name of the entity involved } }