### Question:
CleanTableFunction implements Function<TableAndMetadata, TableAndMetadata> { @Override public TableAndMetadata apply(TableAndMetadata tableAndMetadata) { if (tableAndMetadata == null) { return null; } Table tableCopy = tableAndMetadata.getTable().deepCopy(); for (CircusTrainTableParameter p : CircusTrainTableParameter.values()) { tableCopy.getParameters().remove(p.parameterName()); } for (ExcludedHiveParameter p : ExcludedHiveParameter.values()) { tableCopy.getParameters().remove(p.parameterName()); } return new TableAndMetadata(tableAndMetadata.getSourceTable(), tableAndMetadata.getSourceLocation(), tableCopy); }  @Override TableAndMetadata apply(TableAndMetadata tableAndMetadata);  }### Answer:
@Test public void verbatimCopy() { TableAndMetadata table = newTableAndMetadata(DATABASE, TABLE); TableAndMetadata tableCopy = function.apply(table); assertFalse(tableCopy == table); assertThat(tableCopy, is(table)); }
@Test public void cleansedCopy() { TableAndMetadata table = newTableAndMetadata(DATABASE, TABLE); for (CircusTrainTableParameter p : CircusTrainTableParameter.values()) { table.getTable().getParameters().put(p.parameterName(), "sourceTable"); } for (ExcludedHiveParameter p : ExcludedHiveParameter.values()) { table.getTable().getParameters().put(p.parameterName(), "1234567890"); } TableAndMetadata tableCopy = function.apply(table); assertFalse(tableCopy == table); assertThat(tableCopy, is(not(table))); assertThat(tableCopy.getTable().getDbName(), is(DATABASE)); assertThat(tableCopy.getTable().getTableName(), is(TABLE)); assertThat(tableCopy.getTable().getCreateTime(), is(CREATE_TIME)); assertThat(tableCopy.getTable().getOwner(), is(OWNER)); assertThat(tableCopy.getTable().getPrivileges().getUserPrivileges().size(), is(1)); assertThat(tableCopy.getTable().getPrivileges().getUserPrivileges().get("read"), is(notNullValue())); assertThat(tableCopy.getTable().getSd().getCols(), is(COLS)); assertThat(tableCopy.getTable().getSd().getInputFormat(), is(INPUT_FORMAT)); assertThat(tableCopy.getTable().getSd().getOutputFormat(), is(OUTPUT_FORMAT)); assertThat(tableCopy.getTable().getParameters().size(), is(1)); assertThat(tableCopy.getTable().getParameters().get("com.company.parameter"), is("abc")); }