Commit 1040100a authored by Tim Olshansky's avatar Tim Olshansky Committed by GitHub

Merge pull request #155 from nicolasgnr/master

Add get group by path
parents 50bd5cc2 c4d660fa
......@@ -343,7 +343,18 @@ public class GitlabAPI {
}
public GitlabGroup getGroup(Integer groupId) throws IOException {
String tailUrl = GitlabGroup.URL + "/" + groupId;
return getGroup(groupId.toString());
}
/**
* Get a group by path
*
* @param path Path of the group
* @return
* @throws IOException
*/
public GitlabGroup getGroup(String path) throws IOException {
String tailUrl = GitlabGroup.URL + "/" + path;
return retrieve().to(tailUrl, GitlabGroup.class);
}
......
package org.gitlab.api;
import org.gitlab.api.models.GitlabGroup;
import org.gitlab.api.models.GitlabUser;
import org.junit.Before;
import org.junit.Ignore;
......@@ -119,6 +120,27 @@ public class GitlabAPITest {
}
@Test
public void testGetGroupByPath() throws IOException {
// Given
String name = "groupName";
String path = "groupPath";
GitlabGroup originalGroup = api.createGroup(name, path);
// When
GitlabGroup group = api.getGroup(path);
// Then:
assertNotNull(group);
assertEquals(originalGroup.getId(), group.getId());
assertEquals(originalGroup.getName(), group.getName());
assertEquals(originalGroup.getPath(), group.getPath());
// Cleanup
api.deleteGroup(group.getId());
}
private String randVal(String postfix) {
return rand + "-" + postfix;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment