@Test public void testApplyTo() { String key = "file.cfg"; ParseTreeSentences parseTree = new ParseTreeSentences(); parseTree.setSentences(ImmutableList.of("test")); Warnings warnings = new Warnings(); warnings.getParseWarnings().add(new ParseWarning(1, "text", "context", null)); ParseEnvironmentBgpTableResult result = new ParseEnvironmentBgpTableResult( 0, new BatfishLoggerHistory(), key, "name", new BgpAdvertisementsByVrf(), warnings, parseTree); SortedMap<String, BgpAdvertisementsByVrf> bgpTables = new TreeMap<>(); ParseEnvironmentBgpTablesAnswerElement answerElement = new ParseEnvironmentBgpTablesAnswerElement(); result.applyTo(bgpTables, new BatfishLogger("debug", false), answerElement); SortedMap<String, ParseTreeSentences> answerParseTrees = answerElement.getParseTrees(); SortedMap<String, Warnings> answerWarnings = answerElement.getWarnings(); assertThat(answerParseTrees, hasEntry(key, parseTree)); assertThat(answerWarnings, hasEntry(key, warnings)); }
@Override public void applyTo( SortedMap<String, BgpAdvertisementsByVrf> bgpTables, BatfishLogger logger, ParseEnvironmentBgpTablesAnswerElement answerElement) { appendHistory(logger); String filename = Paths.get(_key).getFileName().toString(); if (_bgpTable != null) { String hostname = _name; if (bgpTables.containsKey(hostname)) { throw new BatfishException("Duplicate hostname: " + hostname); } else { bgpTables.put(hostname, _bgpTable); if (!_warnings.isEmpty()) { answerElement.getWarnings().put(filename, _warnings); } if (!_parseTree.isEmpty()) { answerElement.getParseTrees().put(filename, _parseTree); } if (_bgpTable.getUnrecognized()) { answerElement.getParseStatus().put(filename, ParseStatus.PARTIALLY_UNRECOGNIZED); } else { answerElement.getParseStatus().put(filename, ParseStatus.PASSED); } } } else { answerElement.getParseStatus().put(filename, _status); if (_status == ParseStatus.FAILED) { answerElement .getErrors() .put(filename, ((BatfishException) _failureCause).getBatfishStackTrace()); answerElement .getErrorDetails() .put( filename, new ErrorDetails( Throwables.getStackTraceAsString( firstNonNull(_failureCause.getCause(), _failureCause)))); } } }
ParseEnvironmentBgpTableResult extends BatfishJobResult<
        SortedMap<String, BgpAdvertisementsByVrf>, ParseEnvironmentBgpTablesAnswerElement> { @Override public void applyTo( SortedMap<String, BgpAdvertisementsByVrf> bgpTables, BatfishLogger logger, ParseEnvironmentBgpTablesAnswerElement answerElement) { appendHistory(logger); String filename = Paths.get(_key).getFileName().toString(); if (_bgpTable != null) { String hostname = _name; if (bgpTables.containsKey(hostname)) { throw new BatfishException("Duplicate hostname: " + hostname); } else { bgpTables.put(hostname, _bgpTable); if (!_warnings.isEmpty()) { answerElement.getWarnings().put(filename, _warnings); } if (!_parseTree.isEmpty()) { answerElement.getParseTrees().put(filename, _parseTree); } if (_bgpTable.getUnrecognized()) { answerElement.getParseStatus().put(filename, ParseStatus.PARTIALLY_UNRECOGNIZED); } else { answerElement.getParseStatus().put(filename, ParseStatus.PASSED); } } } else { answerElement.getParseStatus().put(filename, _status); if (_status == ParseStatus.FAILED) { answerElement .getErrors() .put(filename, ((BatfishException) _failureCause).getBatfishStackTrace()); answerElement .getErrorDetails() .put( filename, new ErrorDetails( Throwables.getStackTraceAsString( firstNonNull(_failureCause.getCause(), _failureCause)))); } } } }
ParseEnvironmentBgpTableResult extends BatfishJobResult<
        SortedMap<String, BgpAdvertisementsByVrf>, ParseEnvironmentBgpTablesAnswerElement> { @Override public void applyTo( SortedMap<String, BgpAdvertisementsByVrf> bgpTables, BatfishLogger logger, ParseEnvironmentBgpTablesAnswerElement answerElement) { appendHistory(logger); String filename = Paths.get(_key).getFileName().toString(); if (_bgpTable != null) { String hostname = _name; if (bgpTables.containsKey(hostname)) { throw new BatfishException("Duplicate hostname: " + hostname); } else { bgpTables.put(hostname, _bgpTable); if (!_warnings.isEmpty()) { answerElement.getWarnings().put(filename, _warnings); } if (!_parseTree.isEmpty()) { answerElement.getParseTrees().put(filename, _parseTree); } if (_bgpTable.getUnrecognized()) { answerElement.getParseStatus().put(filename, ParseStatus.PARTIALLY_UNRECOGNIZED); } else { answerElement.getParseStatus().put(filename, ParseStatus.PASSED); } } } else { answerElement.getParseStatus().put(filename, _status); if (_status == ParseStatus.FAILED) { answerElement .getErrors() .put(filename, ((BatfishException) _failureCause).getBatfishStackTrace()); answerElement .getErrorDetails() .put( filename, new ErrorDetails( Throwables.getStackTraceAsString( firstNonNull(_failureCause.getCause(), _failureCause)))); } } } ParseEnvironmentBgpTableResult(
      long elapsedTime,
      BatfishLoggerHistory history,
      String key,
      String name,
      BgpAdvertisementsByVrf bgpTable,
      Warnings warnings,
      ParseTreeSentences parseTree);  ParseEnvironmentBgpTableResult(
      long elapsedTime, BatfishLoggerHistory history, String key, Throwable failureCause);  ParseEnvironmentBgpTableResult(
      long elapsedTime,
      BatfishLoggerHistory history,
      String key,
      Warnings warnings,
      ParseStatus status); }
ParseEnvironmentBgpTableResult extends BatfishJobResult<
        SortedMap<String, BgpAdvertisementsByVrf>, ParseEnvironmentBgpTablesAnswerElement> { @Override public void applyTo( SortedMap<String, BgpAdvertisementsByVrf> bgpTables, BatfishLogger logger, ParseEnvironmentBgpTablesAnswerElement answerElement) { appendHistory(logger); String filename = Paths.get(_key).getFileName().toString(); if (_bgpTable != null) { String hostname = _name; if (bgpTables.containsKey(hostname)) { throw new BatfishException("Duplicate hostname: " + hostname); } else { bgpTables.put(hostname, _bgpTable); if (!_warnings.isEmpty()) { answerElement.getWarnings().put(filename, _warnings); } if (!_parseTree.isEmpty()) { answerElement.getParseTrees().put(filename, _parseTree); } if (_bgpTable.getUnrecognized()) { answerElement.getParseStatus().put(filename, ParseStatus.PARTIALLY_UNRECOGNIZED); } else { answerElement.getParseStatus().put(filename, ParseStatus.PASSED); } } } else { answerElement.getParseStatus().put(filename, _status); if (_status == ParseStatus.FAILED) { answerElement .getErrors() .put(filename, ((BatfishException) _failureCause).getBatfishStackTrace()); answerElement .getErrorDetails() .put( filename, new ErrorDetails( Throwables.getStackTraceAsString( firstNonNull(_failureCause.getCause(), _failureCause)))); } } } ParseEnvironmentBgpTableResult(
      long elapsedTime,
      BatfishLoggerHistory history,
      String key,
      String name,
      BgpAdvertisementsByVrf bgpTable,
      Warnings warnings,
      ParseTreeSentences parseTree);  ParseEnvironmentBgpTableResult(
      long elapsedTime, BatfishLoggerHistory history, String key, Throwable failureCause);  ParseEnvironmentBgpTableResult(
      long elapsedTime,
      BatfishLoggerHistory history,
      String key,
      Warnings warnings,
      ParseStatus status); @Override void appendHistory(BatfishLogger logger); @Override void applyTo(
      SortedMap<String, BgpAdvertisementsByVrf> bgpTables,
      BatfishLogger logger,
      ParseEnvironmentBgpTablesAnswerElement answerElement); BgpAdvertisementsByVrf getBgpTable(); String getKey(); @Override BatfishLoggerHistory getHistory(); @Override String toString(); }
ParseEnvironmentBgpTableResult extends BatfishJobResult<
        SortedMap<String, BgpAdvertisementsByVrf>, ParseEnvironmentBgpTablesAnswerElement> { @Override public void applyTo( SortedMap<String, BgpAdvertisementsByVrf> bgpTables, BatfishLogger logger, ParseEnvironmentBgpTablesAnswerElement answerElement) { appendHistory(logger); String filename = Paths.get(_key).getFileName().toString(); if (_bgpTable != null) { String hostname = _name; if (bgpTables.containsKey(hostname)) { throw new BatfishException("Duplicate hostname: " + hostname); } else { bgpTables.put(hostname, _bgpTable); if (!_warnings.isEmpty()) { answerElement.getWarnings().put(filename, _warnings); } if (!_parseTree.isEmpty()) { answerElement.getParseTrees().put(filename, _parseTree); } if (_bgpTable.getUnrecognized()) { answerElement.getParseStatus().put(filename, ParseStatus.PARTIALLY_UNRECOGNIZED); } else { answerElement.getParseStatus().put(filename, ParseStatus.PASSED); } } } else { answerElement.getParseStatus().put(filename, _status); if (_status == ParseStatus.FAILED) { answerElement .getErrors() .put(filename, ((BatfishException) _failureCause).getBatfishStackTrace()); answerElement .getErrorDetails() .put( filename, new ErrorDetails( Throwables.getStackTraceAsString( firstNonNull(_failureCause.getCause(), _failureCause)))); } } } ParseEnvironmentBgpTableResult(
      long elapsedTime,
      BatfishLoggerHistory history,
      String key,
      String name,
      BgpAdvertisementsByVrf bgpTable,
      Warnings warnings,
      ParseTreeSentences parseTree);  ParseEnvironmentBgpTableResult(
      long elapsedTime, BatfishLoggerHistory history, String key, Throwable failureCause);  ParseEnvironmentBgpTableResult(
      long elapsedTime,
      BatfishLoggerHistory history,
      String key,
      Warnings warnings,
      ParseStatus status); @Override void appendHistory(BatfishLogger logger); @Override void applyTo(
      SortedMap<String, BgpAdvertisementsByVrf> bgpTables,
      BatfishLogger logger,
      ParseEnvironmentBgpTablesAnswerElement answerElement); BgpAdvertisementsByVrf getBgpTable(); String getKey(); @Override BatfishLoggerHistory getHistory(); @Override String toString();  }