@Test public void testValidateNoErrors() throws Exception { final EtmPoint point = mock(EtmPoint.class); mockStatic(PointFactory.class); when(PointFactory.getPoint(CompileErrorValidator.class, "validate")).thenReturn(point); final File listingFile = mock(File.class); final ListingParseResult result = mock(ListingParseResult.class); when(listingParser.parseListing(listingFile)).thenReturn(result); validator.validate(listingFile); verify(point).collect(); }
public void validate(final File listingFile) { if (listingFile == null) throw new NullPointerException("File cannot be null."); final EtmPoint point = PointFactory.getPoint(getClass(), "validate"); try { ListingParseResult parserResult; try { parserResult = listingParser.parseListing(listingFile); } catch (final IOException e) { throw new CclCommandException( "Failed to parse listing data from file: " + listingFile.getAbsolutePath(), e); } if (!parserResult.getErrors().isEmpty()) throw new CclCompilationException( "Failure to compile code: " + parserResult.getErrors().iterator().next().getMessage()); } finally { point.collect(); } }
CompileErrorValidator { public void validate(final File listingFile) { if (listingFile == null) throw new NullPointerException("File cannot be null."); final EtmPoint point = PointFactory.getPoint(getClass(), "validate"); try { ListingParseResult parserResult; try { parserResult = listingParser.parseListing(listingFile); } catch (final IOException e) { throw new CclCommandException( "Failed to parse listing data from file: " + listingFile.getAbsolutePath(), e); } if (!parserResult.getErrors().isEmpty()) throw new CclCompilationException( "Failure to compile code: " + parserResult.getErrors().iterator().next().getMessage()); } finally { point.collect(); } } }
CompileErrorValidator { public void validate(final File listingFile) { if (listingFile == null) throw new NullPointerException("File cannot be null."); final EtmPoint point = PointFactory.getPoint(getClass(), "validate"); try { ListingParseResult parserResult; try { parserResult = listingParser.parseListing(listingFile); } catch (final IOException e) { throw new CclCommandException( "Failed to parse listing data from file: " + listingFile.getAbsolutePath(), e); } if (!parserResult.getErrors().isEmpty()) throw new CclCompilationException( "Failure to compile code: " + parserResult.getErrors().iterator().next().getMessage()); } finally { point.collect(); } } CompileErrorValidator(final ListingParser listingParser); }
CompileErrorValidator { public void validate(final File listingFile) { if (listingFile == null) throw new NullPointerException("File cannot be null."); final EtmPoint point = PointFactory.getPoint(getClass(), "validate"); try { ListingParseResult parserResult; try { parserResult = listingParser.parseListing(listingFile); } catch (final IOException e) { throw new CclCommandException( "Failed to parse listing data from file: " + listingFile.getAbsolutePath(), e); } if (!parserResult.getErrors().isEmpty()) throw new CclCompilationException( "Failure to compile code: " + parserResult.getErrors().iterator().next().getMessage()); } finally { point.collect(); } } CompileErrorValidator(final ListingParser listingParser); static CompileErrorValidator getInstance(); void validate(final File listingFile); }
CompileErrorValidator { public void validate(final File listingFile) { if (listingFile == null) throw new NullPointerException("File cannot be null."); final EtmPoint point = PointFactory.getPoint(getClass(), "validate"); try { ListingParseResult parserResult; try { parserResult = listingParser.parseListing(listingFile); } catch (final IOException e) { throw new CclCommandException( "Failed to parse listing data from file: " + listingFile.getAbsolutePath(), e); } if (!parserResult.getErrors().isEmpty()) throw new CclCompilationException( "Failure to compile code: " + parserResult.getErrors().iterator().next().getMessage()); } finally { point.collect(); } } CompileErrorValidator(final ListingParser listingParser); static CompileErrorValidator getInstance(); void validate(final File listingFile);  }