コード例 #1
0
  /** Gets a group. */
  @Test
  public void getGroup() throws Exception {
    // stub for expected request to get the group
    stubFor(
        get(urlEqualTo("/api/v3/groups/1?private_token=" + PRIVATE_TOKEN))
            .willReturn(aResponse().withStatus(200).withBodyFile("/api/v3/groups/1.json")));

    GitLabGroupInfo group = client.getGroup(1);
    assertThat(group.getId(), is(1));
    assertThat(group.getName(), is("Group Name"));
    assertThat(group.getPath(), is("groupname"));
  }
コード例 #2
0
  /** Gets all groups for the authenticated user. */
  @Test
  public void getAllGroups() throws Exception {
    // stub for expected request to get all groups
    stubFor(
        get(urlEqualTo("/api/v3/groups?private_token=" + PRIVATE_TOKEN))
            .willReturn(aResponse().withStatus(200).withBodyFile("/api/v3/groups.json")));

    List<GitLabGroupInfo> groups = client.getGroups();

    assertThat(groups, hasSize(1));

    GitLabGroupInfo group = groups.get(0);
    assertThat(group.getId(), is(1));
    assertThat(group.getName(), is("Group Name"));
    assertThat(group.getPath(), is("groupname"));
  }