Search in sources :

Example 1 with PatternMatchingJGitEnvironmentRepository

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository in project spring-cloud-config by spring-cloud.

the class MultipleJGitEnvironmentApplicationPlaceholderRepositoryTests method getUri.

private String getUri(String pattern) {
    String uri = null;
    Map<String, PatternMatchingJGitEnvironmentRepository> repoMappings = this.repository.getRepos();
    for (PatternMatchingJGitEnvironmentRepository repo : repoMappings.values()) {
        String[] mappingPattern = repo.getPattern();
        if (mappingPattern != null && mappingPattern.length != 0) {
            uri = repo.getUri();
            break;
        }
    }
    return uri;
}
Also used : PatternMatchingJGitEnvironmentRepository(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository)

Example 2 with PatternMatchingJGitEnvironmentRepository

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository in project spring-cloud-config by spring-cloud.

the class MultipleJGitEnvironmentProfilePlaceholderRepositoryTests method getUri.

private String getUri(String pattern) {
    String uri = null;
    Map<String, PatternMatchingJGitEnvironmentRepository> repoMappings = this.repository.getRepos();
    for (PatternMatchingJGitEnvironmentRepository repo : repoMappings.values()) {
        String[] mappingPattern = repo.getPattern();
        if (mappingPattern != null && mappingPattern.length != 0) {
            uri = repo.getUri();
            break;
        }
    }
    return uri;
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PatternMatchingJGitEnvironmentRepository(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository)

Example 3 with PatternMatchingJGitEnvironmentRepository

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository in project spring-cloud-config by spring-cloud.

the class MultipleJGitEnvironmentProfilePlaceholderRepositoryTests method createRepositories.

private Map<String, PatternMatchingJGitEnvironmentRepository> createRepositories() throws Exception {
    String test1Uri = ConfigServerTestUtils.prepareLocalRepo("test1-config-repo");
    ConfigServerTestUtils.prepareLocalRepo("test2-config-repo");
    Map<String, PatternMatchingJGitEnvironmentRepository> repos = new HashMap<>();
    repos.put("templates", createRepository("test", "*-config-repo", test1Uri.replace("test1-config-repo", "{profile}")));
    return repos;
}
Also used : HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PatternMatchingJGitEnvironmentRepository(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository)

Example 4 with PatternMatchingJGitEnvironmentRepository

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository in project spring-cloud-config by spring-cloud.

the class MultipleJGitEnvironmentRepositoryTests method getUri.

private String getUri(String pattern) {
    String uri = null;
    Map<String, PatternMatchingJGitEnvironmentRepository> repoMappings = this.repository.getRepos();
    for (PatternMatchingJGitEnvironmentRepository repo : repoMappings.values()) {
        String[] mappingPattern = repo.getPattern();
        if (mappingPattern != null && mappingPattern.length != 0) {
            uri = repo.getUri();
            break;
        }
    }
    return uri;
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PatternMatchingJGitEnvironmentRepository(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository)

Example 5 with PatternMatchingJGitEnvironmentRepository

use of org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository in project spring-cloud-config by spring-cloud.

the class MultipleJGitEnvironmentRepositoryTests method shouldSetTransportConfigCallback.

@Test
public void shouldSetTransportConfigCallback() throws Exception {
    TransportConfigCallback mockCallback1 = mock(TransportConfigCallback.class);
    TransportConfigCallback mockCallback2 = mock(TransportConfigCallback.class);
    PatternMatchingJGitEnvironmentRepository repo1 = createRepository("test1", "*test1*", "test1Uri");
    PatternMatchingJGitEnvironmentRepository repo2 = createRepository("test2", "*test2*", "test2Uri");
    repo2.setTransportConfigCallback(mockCallback2);
    Map<String, PatternMatchingJGitEnvironmentRepository> repos = new HashMap<>();
    repos.put("test1", repo1);
    repos.put("test2", repo2);
    this.repository.setRepos(repos);
    this.repository.setTransportConfigCallback(mockCallback1);
    this.repository.afterPropertiesSet();
    assertEquals(repo1.getTransportConfigCallback(), mockCallback1);
    assertEquals(repo2.getTransportConfigCallback(), mockCallback2);
}
Also used : HashMap(java.util.HashMap) TransportConfigCallback(org.eclipse.jgit.api.TransportConfigCallback) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PatternMatchingJGitEnvironmentRepository(org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository) Test(org.junit.Test)

Aggregations

PatternMatchingJGitEnvironmentRepository (org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.PatternMatchingJGitEnvironmentRepository)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 HashMap (java.util.HashMap)3 File (java.io.File)2 TransportConfigCallback (org.eclipse.jgit.api.TransportConfigCallback)1 Test (org.junit.Test)1