@Test
public void migrate_data_previously_store_in_elastic_search() throws Exception {

    String existingId = AbstractDeploymentConfig.generateId("versionOK", "envId");
    // given a configuration store in ES
    when(alienDao.findById(DeploymentMatchingConfiguration.class, existingId)).thenReturn(new DeploymentMatchingConfiguration("versionOK", "envId"));
    // given the location of the existing config is defined
    Path configLocalPath = Paths.get("target/deployment_config_dao_test/config");
    Files.deleteIfExists(configLocalPath);
    when(localGitRepositoryPathResolver.resolve(eq(DeploymentMatchingConfiguration.class), eq(existingId))).thenReturn(configLocalPath);
    // when looking for a config that not existing in Git yet
    DeploymentMatchingConfiguration config = dao.findById(DeploymentMatchingConfiguration.class, existingId);
    // then we get data from ES
    assertThat(config).isNotNull();
    assertThat(config.getId()).isEqualTo(existingId);
    // ES data has been deleted
    verify(alienDao).delete(DeploymentMatchingConfiguration.class, existingId);
    // check data has been migrated into git
    assertThat(Files.exists(configLocalPath)).isTrue();
}