### Question:
StrategyBasedReplicationFactory implements ReplicationFactory { @Override public Replication newInstance(TableReplication tableReplication) { if (tableReplication.getReplicationStrategy() == ReplicationStrategy.PROPAGATE_DELETES) { String eventId = eventIdFactory.newEventId(EventIdPrefix.CIRCUS_TRAIN_DESTRUCTIVE.getPrefix()); CleanupLocationManager cleanupLocationManager = CleanupLocationManagerFactory.newInstance(eventId, housekeepingListener, replicaCatalogListener, tableReplication); return new DestructiveReplication(upsertReplicationFactory, tableReplication, eventId, new DestructiveSource(sourceMetaStoreClientSupplier, tableReplication), new DestructiveReplica(replicaMetaStoreClientSupplier, cleanupLocationManager, tableReplication)); } return upsertReplicationFactory.newInstance(tableReplication); } StrategyBasedReplicationFactory(
      ReplicationFactoryImpl upsertReplicationFactory,
      Supplier<CloseableMetaStoreClient> sourceMetaStoreClientSupplier,
      Supplier<CloseableMetaStoreClient> replicaMetaStoreClientSupplier,
      HousekeepingListener housekeepingListener,
      ReplicaCatalogListener replicaCatalogListener); @Override Replication newInstance(TableReplication tableReplication);  }### Answer:
@Test public void newInstance() throws Exception { StrategyBasedReplicationFactory factory = new StrategyBasedReplicationFactory(upsertReplicationFactory, sourceMetaStoreClientSupplier, replicaMetaStoreClientSupplier, housekeepingListener, replicaCatalogListener); tableReplication.setReplicationStrategy(ReplicationStrategy.PROPAGATE_DELETES); Replication replication = factory.newInstance(tableReplication); assertThat(replication, instanceOf(DestructiveReplication.class)); }
@Test public void newInstanceUpsert() throws Exception { StrategyBasedReplicationFactory factory = new StrategyBasedReplicationFactory(upsertReplicationFactory, sourceMetaStoreClientSupplier, replicaMetaStoreClientSupplier, housekeepingListener, replicaCatalogListener); tableReplication.setReplicationStrategy(ReplicationStrategy.UPSERT); factory.newInstance(tableReplication); verify(upsertReplicationFactory).newInstance(tableReplication); }