### Question:
CleanPartitionFunction implements Function<PartitionAndMetadata, PartitionAndMetadata> { @Override public PartitionAndMetadata apply(PartitionAndMetadata partitionAndMetadata) { if (partitionAndMetadata == null) { return null; } Partition partitionCopy = partitionAndMetadata.getPartition().deepCopy(); for (CircusTrainTableParameter p : CircusTrainTableParameter.values()) { partitionCopy.getParameters().remove(p.parameterName()); } for (ExcludedHiveParameter p : ExcludedHiveParameter.values()) { partitionCopy.getParameters().remove(p.parameterName()); } return new PartitionAndMetadata(partitionAndMetadata.getSourceTable(), partitionAndMetadata.getSourceLocation(), partitionCopy); }  @Override PartitionAndMetadata apply(PartitionAndMetadata partitionAndMetadata);  }### Answer:
@Test public void verbatimCopy() { PartitionAndMetadata partition = newPartitionAndMetadata(DATABASE, TABLE, "val"); PartitionAndMetadata partitionCopy = function.apply(partition); assertFalse(partitionCopy == partition); assertThat(partitionCopy, is(partition)); }
@Test public void cleansedCopy() { PartitionAndMetadata partition = newPartitionAndMetadata(DATABASE, TABLE, "val"); for (CircusTrainTableParameter p : CircusTrainTableParameter.values()) { partition.getPartition().getParameters().put(p.parameterName(), "sourceTable"); } for (ExcludedHiveParameter p : ExcludedHiveParameter.values()) { partition.getPartition().getParameters().put(p.parameterName(), "1234567890"); } PartitionAndMetadata partitionCopy = function.apply(partition); assertFalse(partitionCopy == partition); assertThat(partitionCopy, is(not(partition))); assertThat(partitionCopy.getPartition().getDbName(), is(DATABASE)); assertThat(partitionCopy.getPartition().getTableName(), is(TABLE)); assertThat(partitionCopy.getPartition().getCreateTime(), is(CREATE_TIME)); List<String> partitionValues = ImmutableList.of("val"); assertThat(partitionCopy.getPartition().getValues(), is(partitionValues)); assertThat(partitionCopy.getPartition().getPrivileges().getUserPrivileges().size(), is(1)); assertThat(partitionCopy.getPartition().getPrivileges().getUserPrivileges().get("read"), is(notNullValue())); assertThat(partitionCopy.getPartition().getSd().getCols(), is(COLS)); assertThat(partitionCopy.getPartition().getSd().getInputFormat(), is(INPUT_FORMAT)); assertThat(partitionCopy.getPartition().getSd().getOutputFormat(), is(OUTPUT_FORMAT)); assertThat(partitionCopy.getPartition().getParameters().size(), is(1)); assertThat(partitionCopy.getPartition().getParameters().get("com.company.parameter"), is("abc")); }