### Question:
PartitionPredicateFactory { public PartitionPredicate newInstance(TableReplication tableReplication) { if (tableReplication.getSourceTable().isGeneratePartitionFilter()) { return new DiffGeneratedPartitionPredicate(sourceFactory.newInstance(tableReplication), replicaFactory.newInstance(tableReplication), tableReplication, checksumFunction); } else { return new SpelParsedPartitionPredicate(expressionParser, tableReplication); } } PartitionPredicateFactory(
      HiveEndpointFactory<? extends HiveEndpoint> sourceFactory,
      HiveEndpointFactory<? extends HiveEndpoint> replicaFactory,
      SpringExpressionParser expressionParser,
      Function<Path, String> checksumFunction); PartitionPredicate newInstance(TableReplication tableReplication);  }### Answer:
@Test public void newInstanceSpelParsedPartitionPredicate() throws Exception { when(sourceTable.isGeneratePartitionFilter()).thenReturn(false); PartitionPredicate predicate = partitionPredicateFactory.newInstance(tableReplication); assertThat(predicate, instanceOf(SpelParsedPartitionPredicate.class)); }
@Test public void newInstanceDiffGeneratedPartitionPredicate() throws Exception { when(sourceTable.isGeneratePartitionFilter()).thenReturn(true); when(sourceFactory.newInstance(tableReplication)).thenReturn(source); when(replicaFactory.newInstance(tableReplication)).thenReturn(replica); PartitionPredicate predicate = partitionPredicateFactory.newInstance(tableReplication); assertThat(predicate, instanceOf(DiffGeneratedPartitionPredicate.class)); }