DatabaseSet { public DatabaseSet deepCopy(Map<String, DataBase> newDBs) throws Exception { DatabaseSet newDataSet = new DatabaseSet(); newDataSet.name = this.name; newDataSet.provider = this.provider; newDataSet.dbCategory = this.dbCategory; newDataSet.strategy = this.strategy; newDataSet.mgrEnabled = this.mgrEnabled; newDataSet.mgrReadWriteSplittingEnabled = this.mgrReadWriteSplittingEnabled; newDataSet.databases = new HashMap<>(); newDataSet.databases.putAll(newDBs); newDataSet.initShards(); return newDataSet; } DatabaseSet(String name, String provider, Map<String, DataBase> databases);  DatabaseSet(String name, String provider, Map<String, DataBase> databases,boolean mgrEnabled);  DatabaseSet(String name, String provider, String shardStrategy, Map<String, DataBase> databases);  DatabaseSet(String name, String provider, String shardStrategy, Map<String, DataBase> databases, boolean mgrEnabled);  DatabaseSet(String name, String provider, String shardStrategy, ShardingStrategy strategy, Map<String, DataBase> databases);  DatabaseSet(String name, String provider, String shardStrategy, ShardingStrategy strategy, Map<String, DataBase> databases, boolean mgrEnabled); private  DatabaseSet(); DatabaseSet deepCopy(Map<String, DataBase> newDBs); void remove(String dbName); void initShards(); String getName(); String getProvider(); DatabaseCategory getDatabaseCategory(); boolean isShardingSupported(); boolean isShardByTable(); boolean isTableShardingSupported(String tableName); Map<String, DataBase> getDatabases(); void validate(String shard); Set<String> getAllShards(); ShardingStrategy getStrategy(); List<DataBase> getMasterDbs(); List<DataBase> getSlaveDbs(); List<DataBase> getMasterDbs(String shard); List<DataBase> getSlaveDbs(String shard); boolean isMgrEnabled(); boolean isMgrReadWriteSplittingEnabled(); DatabaseSet setMgrReadWriteSplittingEnabled(boolean mgrReadWriteSplittingEnabled); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testDeepCopy() throws Exception { DatabaseSet databaseSet1 = databaseSet.deepCopy( ImmutableMap.of("db2", new DataBase("db2", true, "sh", "connectionString"))); Assert.assertEquals("db2", databaseSet1.getDatabases().get("db2").getName()); databaseSet1.remove("db2"); Assert.assertTrue(databaseSet1.getDatabases().isEmpty()); Assert.assertEquals(MYSQL_PROVIDER, databaseSet1.getProvider()); }