private ValuesIndexManager setupMockObjects(
      String dsName, String table, String indexName, String variableName, Variable variable) {
    ValuesIndexManager indexManager = createMock(ValuesIndexManager.class);
    Datasource datasource = createMockDatasource(dsName, table);

    ValueTable mockTable = datasource.getValueTable(table);
    reset(mockTable);
    ValueTableValuesIndex mockTableIndex = createMock(ValueTableValuesIndex.class);
    expect(mockTableIndex.getIndexName()).andReturn(indexName).anyTimes();
    expect(mockTableIndex.getFieldName("LAST_MEAL_WHEN"))
        .andReturn(indexName + "-LAST_MEAL_WHEN")
        .anyTimes();
    expect(mockTableIndex.getFieldName("RES_FIRST_HEIGHT"))
        .andReturn(indexName + "-RES_FIRST_HEIGHT")
        .anyTimes();
    replay(mockTableIndex);

    expect(mockTable.getVariable(variableName)).andReturn(variable).anyTimes();
    expect(indexManager.getIndex(mockTable)).andReturn(mockTableIndex).anyTimes();
    replay(indexManager);
    replay(mockTable);

    MagmaEngine.get().addDatasource(datasource);

    return indexManager;
  }
 @Override
 public void importIdentifiers(
     @NotNull IdentifiersMapping idMapping, Datasource sourceDatasource, @Nullable String select)
     throws IOException {
   try {
     for (ValueTable vt : sourceDatasource.getValueTables()) {
       if (idMapping.isForTable(vt)) {
         importIdentifiers(idMapping, vt, select);
       }
     }
   } finally {
     if (MagmaEngine.get().hasTransientDatasource(sourceDatasource.getName()))
       MagmaEngine.get().removeTransientDatasource(sourceDatasource.getName());
   }
 }
  private Datasource createMockDatasource(String dsName, String... tables) {
    Datasource mockDatasource = createMock(Datasource.class);
    mockDatasource.initialise();
    EasyMock.expectLastCall().once();
    mockDatasource.dispose();
    EasyMock.expectLastCall().once();

    expect(mockDatasource.getName()).andReturn(dsName).anyTimes();
    for (String table : tables) {
      ValueTable mockTable = createMock(ValueTable.class);
      expect(mockTable.getName()).andReturn(table).anyTimes();
      expect(mockDatasource.getValueTable(table)).andReturn(mockTable).anyTimes();
      replay(mockTable);
    }
    replay(mockDatasource);
    return mockDatasource;
  }