Example usage for org.eclipse.jgit.lib StoredConfig getStringList

List of usage examples for org.eclipse.jgit.lib StoredConfig getStringList

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib StoredConfig getStringList.

Prototype

public String[] getStringList(final String section, String subsection, final String name) 

Source Link

Document

Get a list of string values

If this instance was created with a base, the base's values are returned first (if any).

Usage

From source file:org.jboss.tools.openshift.test.util.ResourceMocks.java

License:Open Source License

public static org.eclipse.core.resources.IProject mockGitSharedProject(String name, String gitRemoteUri)
        throws CoreException {
    org.eclipse.core.resources.IProject project = createEclipseProject(name);

    when(project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY)).thenReturn(GitProvider.ID);

    when(project.getWorkingLocation(any()))
            .thenReturn(new Path(ResourcesPlugin.getWorkspace().getRoot().getFullPath().toString()));

    StoredConfig config = mock(StoredConfig.class);
    when(config.getSubsections("remote")).thenReturn(new HashSet<String>(Arrays.asList("origin")));
    when(config.getStringList(any(), any(), any())).thenReturn(new String[] { gitRemoteUri });
    when(config.getStringList("remote", "origin", "url")).thenReturn(new String[] { gitRemoteUri });

    Repository repository = mock(Repository.class);
    when(repository.getConfig()).thenReturn(config);

    RepositoryMapping mapping = mock(RepositoryMapping.class);
    when(mapping.getRepository()).thenReturn(repository);

    GitProjectData data = mock(GitProjectData.class);
    when(data.getRepositoryMapping(project)).thenReturn(mapping);

    GitProvider repositoryProvider = mock(GitProvider.class);
    when(repositoryProvider.getID()).thenReturn(GitProvider.ID);
    when(repositoryProvider.getData()).thenReturn(data);
    when(project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY)).thenReturn(repositoryProvider);

    return project;
}