### Question:
UnpartitionedTableMetadataUpdateReplication implements Replication { @Override public void replicate() throws CircusTrainException { try { replica.validateReplicaTable(replicaDatabaseName, replicaTableName); try (CloseableMetaStoreClient client = replica.getMetaStoreClientSupplier().get()) { String previousLocation = getPreviousLocation(client); ReplicaLocationManager replicaLocationManager = new MetadataUpdateReplicaLocationManager(client, TableType.UNPARTITIONED, previousLocation, replicaDatabaseName, replicaTableName); TableAndStatistics sourceTableAndStatistics = source.getTableAndStatistics(database, table); replica .updateMetadata(eventId, sourceTableAndStatistics, replicaDatabaseName, replicaTableName, replicaLocationManager); } LOG.info("Metadata updated for table {}.{} (no data copied).", database, table); } catch (Throwable t) { throw new CircusTrainException("Unable to replicate", t); } } UnpartitionedTableMetadataUpdateReplication(
      String database,
      String table,
      Source source,
      Replica replica,
      EventIdFactory eventIdFactory,
      String replicaDatabaseName,
      String replicaTableName); @Override void replicate(); @Override String name(); @Override String getEventId();  }### Answer:
@Test public void typical() throws Exception { when(replica.getTable(client, DATABASE, TABLE)).thenReturn(Optional.of(previousReplicaTable)); when(previousReplicaTable.getSd()).thenReturn(sd); when(sd.getLocation()).thenReturn(tableLocation); UnpartitionedTableMetadataUpdateReplication replication = new UnpartitionedTableMetadataUpdateReplication(DATABASE, TABLE, source, replica, eventIdFactory, DATABASE, TABLE); replication.replicate(); InOrder replicationOrder = inOrder(replica); replicationOrder.verify(replica).validateReplicaTable(DATABASE, TABLE); replicationOrder.verify(replica).updateMetadata(eq(EVENT_ID), eq(sourceTableAndStatistics), eq(DATABASE), eq(TABLE), any(ReplicaLocationManager.class)); }
@Test public void throwExceptionWhenReplicaTableDoesNotExist() throws Exception { expectedException.expect(CircusTrainException.class); expectedException.expectCause(isA(InvalidReplicationModeException.class)); when(replica.getTable(client, DATABASE, TABLE)).thenReturn(Optional.<Table> absent()); UnpartitionedTableMetadataUpdateReplication replication = new UnpartitionedTableMetadataUpdateReplication(DATABASE, TABLE, source, replica, eventIdFactory, DATABASE, TABLE); replication.replicate(); }