### Question:
SourceFactory implements HiveEndpointFactory<Source> { @Override public Source newInstance(TableReplication tableReplication) { boolean snapshotsDisabled = true; if (tableReplication.getReplicationMode() == ReplicationMode.FULL) { snapshotsDisabled = sourceCatalog.isDisableSnapshots(); } return new Source(sourceCatalog, sourceHiveConf, sourceMetaStoreClientSupplier, sourceCatalogListener, snapshotsDisabled, tableReplication.getSourceTable().getTableLocation()); } @Autowired  SourceFactory(
      SourceCatalog sourceCatalog,
      @Value("#{sourceHiveConf}") HiveConf sourceHiveConf,
      @Value("#{sourceMetaStoreClientSupplier}") Supplier<CloseableMetaStoreClient> sourceMetaStoreClientSupplier,
      SourceCatalogListener sourceCatalogListener); @Override Source newInstance(TableReplication tableReplication);  }### Answer:
@Test public void newInstanceFullReplicationMode() throws Exception { when(tableReplication.getReplicationMode()).thenReturn(ReplicationMode.FULL); when(sourceCatalog.isDisableSnapshots()).thenReturn(false); SourceFactory sourceFactory = new SourceFactory(sourceCatalog, sourceHiveConf, sourceMetaStoreClientSupplier, sourceCatalogListener); Source source = sourceFactory.newInstance(tableReplication); assertFalse(source.isSnapshotsDisabled()); }
@Test public void newInstanceMetadataMirrorReplicationModeOverridesDisabledSnapshots() throws Exception { when(tableReplication.getReplicationMode()).thenReturn(ReplicationMode.METADATA_MIRROR); when(sourceCatalog.isDisableSnapshots()).thenReturn(false); SourceFactory sourceFactory = new SourceFactory(sourceCatalog, sourceHiveConf, sourceMetaStoreClientSupplier, sourceCatalogListener); Source source = sourceFactory.newInstance(tableReplication); assertTrue(source.isSnapshotsDisabled()); }
@Test public void newInstanceMetadataUpdateReplicationModeOverridesDisabledSnapshots() throws Exception { when(tableReplication.getReplicationMode()).thenReturn(ReplicationMode.METADATA_UPDATE); when(sourceCatalog.isDisableSnapshots()).thenReturn(false); SourceFactory sourceFactory = new SourceFactory(sourceCatalog, sourceHiveConf, sourceMetaStoreClientSupplier, sourceCatalogListener); Source source = sourceFactory.newInstance(tableReplication); assertTrue(source.isSnapshotsDisabled()); }