@Test public void testComputeAnswerMetadata() { String columnName = "col"; String issueColumnName = "colIssue"; int value = 5; int excludedValue = 6; String major = "major"; String minor = "minor"; int severity = 1; Issue issueValue = new Issue("a", severity, new Issue.Type(major, minor)); Answer testAnswer = new Answer(); testAnswer.addAnswerElement( new TableAnswerElement( new TableMetadata( ImmutableList.of( new ColumnMetadata(columnName, Schema.INTEGER, "foobar"), new ColumnMetadata(issueColumnName, Schema.ISSUE, "barfoo")), new DisplayHints().getTextDesc())) .addRow(Row.of(columnName, value, issueColumnName, issueValue)) .addExcludedRow(Row.of(columnName, excludedValue, issueColumnName, issueValue), "foo")); testAnswer.setStatus(AnswerStatus.SUCCESS); assertThat( AnswerMetadataUtil.computeAnswerMetadata(testAnswer, _logger), equalTo( AnswerMetadata.builder() .setMetrics( Metrics.builder() .setAggregations( ImmutableMap.of( columnName, ImmutableMap.of(Aggregation.MAX, value), issueColumnName, ImmutableMap.of(Aggregation.MAX, severity))) .setNumExcludedRows(1) .setNumRows(1) .build()) .setStatus(AnswerStatus.SUCCESS) .build())); }
public static @Nonnull AnswerMetadata computeAnswerMetadata( @Nonnull Answer answer, @Nonnull BatfishLogger logger) { try { return AnswerMetadata.builder() .setMetrics(computeMetrics(answer, logger)) .setStatus(answer.getStatus()) .build(); } catch (Exception e) { return AnswerMetadata.forStatus(AnswerStatus.FAILURE); } }
AnswerMetadataUtil { public static @Nonnull AnswerMetadata computeAnswerMetadata( @Nonnull Answer answer, @Nonnull BatfishLogger logger) { try { return AnswerMetadata.builder() .setMetrics(computeMetrics(answer, logger)) .setStatus(answer.getStatus()) .build(); } catch (Exception e) { return AnswerMetadata.forStatus(AnswerStatus.FAILURE); } } }
AnswerMetadataUtil { public static @Nonnull AnswerMetadata computeAnswerMetadata( @Nonnull Answer answer, @Nonnull BatfishLogger logger) { try { return AnswerMetadata.builder() .setMetrics(computeMetrics(answer, logger)) .setStatus(answer.getStatus()) .build(); } catch (Exception e) { return AnswerMetadata.forStatus(AnswerStatus.FAILURE); } } private  AnswerMetadataUtil(); }
AnswerMetadataUtil { public static @Nonnull AnswerMetadata computeAnswerMetadata( @Nonnull Answer answer, @Nonnull BatfishLogger logger) { try { return AnswerMetadata.builder() .setMetrics(computeMetrics(answer, logger)) .setStatus(answer.getStatus()) .build(); } catch (Exception e) { return AnswerMetadata.forStatus(AnswerStatus.FAILURE); } } private  AnswerMetadataUtil(); static @Nonnull AnswerMetadata computeAnswerMetadata(
      @Nonnull Answer answer, @Nonnull BatfishLogger logger); }
AnswerMetadataUtil { public static @Nonnull AnswerMetadata computeAnswerMetadata( @Nonnull Answer answer, @Nonnull BatfishLogger logger) { try { return AnswerMetadata.builder() .setMetrics(computeMetrics(answer, logger)) .setStatus(answer.getStatus()) .build(); } catch (Exception e) { return AnswerMetadata.forStatus(AnswerStatus.FAILURE); } } private  AnswerMetadataUtil(); static @Nonnull AnswerMetadata computeAnswerMetadata(
      @Nonnull Answer answer, @Nonnull BatfishLogger logger);  }