/** Adds {@code nodes} (which are present in only one snapshot) to the {@code table} */ private void addOneSnapshotNodes(SetView<String> nodes, TableAnswerElement table) { for (String node : nodes) { table.addRow(Row.builder(table.getMetadata().toColumnMap()).put(COL_NODE, node).build()); } } }
/** Computes the summary of this table, given the assertion */ public AnswerSummary computeSummary(Assertion assertion) { String notes = "Found " + _rows.size() + " results"; return computeSummary(assertion, notes); }
@Test public void testAddRowExtraColumn() { TableAnswerElement table = new TableAnswerElement(twoKeyTableMetadata); Row row = Row.builder().put("key1", null).put("key2", null).put("key3", null).build(); _thrown.expect(IllegalArgumentException.class); _thrown.expectMessage( String.format( "Row columns %s do not match metadata columns metadata %s", row.getColumnNames(), twoKeyTableMetadata.toColumnMap().keySet())); table.addRow(row); } }
static TableMetadata getTableMetadata() { List<ColumnMetadata> columnMetadata = ImmutableList.of( new ColumnMetadata(COL_NODE, Schema.NODE, "The node where action takes place"), new ColumnMetadata(COL_VRF, Schema.STRING, "The VRF where action takes place"), new ColumnMetadata( COL_PEER, Schema.NODE, "The node's neighbor to which the action applies"), new ColumnMetadata(COL_ACTION, Schema.STRING, "The action that takes place"), new ColumnMetadata(COL_PREFIX, Schema.PREFIX, "The prefix in question")); return new TableMetadata(columnMetadata, TEXT_DESC); }
/** * Returns a new {@link Row} with the given entries. * * <p>{@code objects} should be an even number of parameters, where the 0th and every even * parameter is a {@link String} representing the name of a column. The columns names and the * actual objects (in odd parameters) must be compliant with the metadata map in {@code columns}. */ public static Row of(Map<String, ColumnMetadata> columns, Object... objects) { return builder(columns).rowOf(objects); }
/** This used to be the old signature, changed now to {@link #getKey(List)} */ @Deprecated public List<Object> getKey(TableMetadata metadata) { return getKey(metadata.getColumnMetadata()); }
/** This used to be the old signature, changed now to {@link #getValue(List)} */ @Deprecated public List<Object> getValue(TableMetadata metadata) { return getValue(metadata.getColumnMetadata()); }
/** Mirrors the values of all columns in {@code otherRow} */ public RowBuilder putAll(Row otherRow) { return putAll(otherRow, otherRow.getColumnNames()); }
@Override protected Integer featureValueOf(Rows actual) { return actual.size(); } }
/** Returns an {@link UntypedRowBuilder} object for Row */ public static UntypedRowBuilder builder() { return new UntypedRowBuilder(); }
/** Returns a {@link TypedRowBuilder} object for Row */ public static TypedRowBuilder builder(Map<String, ColumnMetadata> columns) { return new TypedRowBuilder(columns); }
@Test public void testAddRowMissingColumn() { TableAnswerElement table = new TableAnswerElement(twoKeyTableMetadata); Row row = Row.builder().put("key1", null).build(); _thrown.expect(IllegalArgumentException.class); _thrown.expectMessage( String.format( "Row columns %s do not match metadata columns metadata %s", row.getColumnNames(), twoKeyTableMetadata.toColumnMap().keySet())); table.addRow(row); }