### Question:
DestructiveReplica { public boolean tableIsUnderCircusTrainControl() throws TException { try (CloseableMetaStoreClient client = replicaMetaStoreClientSupplier.get()) { if (!client.tableExists(databaseName, tableName)) { return true; } String sourceTableParameterValue = client .getTable(databaseName, tableName) .getParameters() .get(CircusTrainTableParameter.SOURCE_TABLE.parameterName()); if (sourceTableParameterValue != null) { String qualifiedName = tableReplication.getSourceTable().getQualifiedName(); return qualifiedName.equals(sourceTableParameterValue); } } return false; } DestructiveReplica(
      Supplier<CloseableMetaStoreClient> replicaMetaStoreClientSupplier,
      CleanupLocationManager cleanupLocationManager,
      TableReplication tableReplication); boolean tableIsUnderCircusTrainControl(); void dropDeletedPartitions(final List<String> sourcePartitionNames); void dropTable();  }### Answer:
@Test public void tableIsUnderCircusTrainControl() throws Exception { when(client.tableExists(DATABASE, REPLICA_TABLE)).thenReturn(true); when(client.getTable(DATABASE, REPLICA_TABLE)).thenReturn(table); assertThat(replica.tableIsUnderCircusTrainControl(), is(true)); verify(client).close(); }
@Test public void tableIsUnderCircusTrainControlTableDoesNotExist() throws Exception { when(client.tableExists(DATABASE, REPLICA_TABLE)).thenReturn(false); assertThat(replica.tableIsUnderCircusTrainControl(), is(true)); verify(client).close(); }
@Test public void tableIsUnderCircusTrainControlParameterDoesNotMatch() throws Exception { when(client.tableExists(DATABASE, REPLICA_TABLE)).thenReturn(true); table.putToParameters(CircusTrainTableParameter.SOURCE_TABLE.parameterName(), "different.table"); when(client.getTable(DATABASE, REPLICA_TABLE)).thenReturn(table); assertThat(replica.tableIsUnderCircusTrainControl(), is(false)); verify(client).close(); }
@Test public void tableIsUnderCircusTrainControlParameterIsNull() throws Exception { when(client.tableExists(DATABASE, REPLICA_TABLE)).thenReturn(true); Map<String, String> parameters = new HashMap<>(); table.setParameters(parameters); when(client.getTable(DATABASE, REPLICA_TABLE)).thenReturn(table); assertThat(replica.tableIsUnderCircusTrainControl(), is(false)); verify(client).close(); }