@Test
public void provideCatalogMetadataTest() throws ConnectorException {

    ClusterName clusterName = new ClusterName(CLUSTER_NAME);
    MongoMetadataEngine spyMetadataEngine = PowerMockito.spy(MongoMetadataEngine.getInstance(connectionHandler));
    TableMetadata tableMetadata1 = mock(TableMetadata.class);
    TableMetadata tableMetadata2 = mock(TableMetadata.class);
    TableName tableName1 = new TableName(DB_NAME, TABLE_NAME);
    TableName tableName2 = new TableName(DB_NAME, TABLE_NAME_SEC);
    when(tableMetadata1.getName()).thenReturn(tableName1);
    when(tableMetadata2.getName()).thenReturn(tableName2);
    Set<String> set = new TreeSet<>();
    set.add(TABLE_NAME);
    set.add(TABLE_NAME_SEC);
    when(client.getDB(DB_NAME)).thenReturn(database);
    when(database.getCollectionNames()).thenReturn(set);
    PowerMockito.doReturn(tableMetadata1).when(spyMetadataEngine)
                    .provideTableMetadata(new TableName(DB_NAME, TABLE_NAME), clusterName, connection);
    PowerMockito.doReturn(tableMetadata2).when(spyMetadataEngine)
                    .provideTableMetadata(new TableName(DB_NAME, TABLE_NAME_SEC), clusterName, connection);
    CatalogMetadata providedCatalogMetadata = spyMetadataEngine.provideCatalogMetadata(new CatalogName(DB_NAME),
                    clusterName, connection);
    Assert.assertEquals(providedCatalogMetadata.getName().getName(), DB_NAME);
    Assert.assertEquals(providedCatalogMetadata.getTables().size(), 2);
    Assert.assertEquals(providedCatalogMetadata.getTables().get(tableName1), tableMetadata1);
    Assert.assertEquals(providedCatalogMetadata.getTables().get(tableName2), tableMetadata2);
}