Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/OrganizationTest.java50
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamServiceTest.java17
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Organization.java99
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java20
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java24
5 files changed, 205 insertions, 5 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/OrganizationTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/OrganizationTest.java
new file mode 100644
index 00000000..5787f5aa
--- /dev/null
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/OrganizationTest.java
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * Copyright (c) 2018 Singaram Subramanian <to.ramsubramanian@gmail.com>
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Singaram Subramanian (Capital One) - (Bug: 529850)
+ * User teams across GitHub organizations implementation
+ *****************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.egit.github.core.Organization;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link Organization}
+ */
+public class OrganizationTest {
+
+ /**
+ * Test default state of organization
+ */
+ @Test
+ public void defaultState() {
+ Organization organization = new Organization();
+ assertEquals(0, organization.getId());
+ assertNull(organization.getLogin());
+ assertNull(organization.getDescription());
+ assertNull(organization.getUrl());
+ }
+
+ /**
+ * Test updating organization fields
+ */
+ @Test
+ public void updateFields() {
+ Organization organization = new Organization();
+ assertEquals(12, organization.setId(12).getId());
+ assertEquals("orgName", organization.setLogin("orgName").getLogin());
+ assertEquals("description", organization.setDescription("description").getDescription());
+ assertEquals("url", organization.setUrl("url").getUrl());
+ }
+}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamServiceTest.java
index 06b53163..ea5c6044 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamServiceTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/TeamServiceTest.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2011, 2015 GitHub Inc. and others
+ * Copyright (c) 2011, 2018 GitHub Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,8 @@
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
* Michael Mathews (Arizona Board of Regents) - (Bug: 447419)
* Team Membership API implementation
+ * Singaram Subramanian (Capital One) - (Bug: 529850)
+ * User teams across GitHub organizations implementation
*****************************************************************************/
package org.eclipse.egit.github.core.tests;
@@ -422,4 +424,17 @@ public class TeamServiceTest {
request.setUri(Utils.page("/repos/o/n/teams"));
verify(client).get(request);
}
+
+ /**
+ * Get current user's teams across all GitHub organizations
+ *
+ * @throws IOException
+ */
+ @Test
+ public void getAllTeams() throws IOException {
+ service.getTeams();
+ GitHubRequest request = new GitHubRequest();
+ request.setUri(Utils.page("/user/teams"));
+ verify(client).get(request);
+ }
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Organization.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Organization.java
new file mode 100644
index 00000000..4d7fb245
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Organization.java
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * Copyright (c) 2018 Singaram Subramanian <to.ramsubramanian@gmail.com>
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Singaram Subramanian (Capital One) - (Bug: 529850)
+ * User teams across GitHub organizations implementation
+ *****************************************************************************/
+package org.eclipse.egit.github.core;
+
+import java.io.Serializable;
+
+/**
+ * Organization model class.
+ *
+ * Contains information about the GitHub organization that a particular
+ * GitHub Team is associated with.
+ *
+ * @see Team
+ */
+public class Organization implements Serializable {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = -747906610305335107L;
+
+ private int id;
+
+ private String login;
+
+ private String description;
+
+ private String url;
+
+ /**
+ * @return the id
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public Organization setId(int id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * @return the login
+ */
+ public String getLogin() {
+ return login;
+ }
+
+ /**
+ * @param login the login to set
+ */
+ public Organization setLogin(String login) {
+ this.login = login;
+ return this;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public Organization setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * @param url the url to set
+ */
+ public Organization setUrl(String url) {
+ this.url = url;
+ return this;
+ }
+
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java
index f6436b31..1dbbf1f4 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2011 GitHub Inc.
+ * Copyright (c) 2011, 2018 GitHub Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,8 @@
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ * Singaram Subramanian (Capital One) - (Bug: 529850)
+ * User teams across GitHub organizations implementation
*****************************************************************************/
package org.eclipse.egit.github.core;
@@ -34,6 +36,8 @@ public class Team implements Serializable {
private String url;
+ private Organization organization;
+
/**
* @return id
*/
@@ -130,4 +134,18 @@ public class Team implements Serializable {
return this;
}
+ /**
+ * @return the organization
+ */
+ public Organization getOrganization() {
+ return organization;
+ }
+
+ /**
+ * @param organization the organization to set
+ */
+ public void setOrganization(Organization organization) {
+ this.organization = organization;
+ }
+
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java
index e2a59a48..847403f9 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2011, 2014 GitHub Inc. and others
+ * Copyright (c) 2011, 2018 GitHub Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,8 @@
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
* Michael Mathews (Arizona Board of Regents) - (Bug: 447419)
* Team Membership API implementation
+ * Singaram Subramanian (Capital One) - (Bug: 529850)
+ * User teams across GitHub organizations implementation
*****************************************************************************/
package org.eclipse.egit.github.core.service;
@@ -19,8 +21,7 @@ import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_MEMBE
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_ORGS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_TEAMS;
-
-import com.google.gson.reflect.TypeToken;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_USER;
import java.io.IOException;
import java.util.HashMap;
@@ -36,6 +37,8 @@ import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.client.GitHubRequest;
import org.eclipse.egit.github.core.client.PagedRequest;
+import com.google.gson.reflect.TypeToken;
+
/**
* Service class for working with organization teams
*
@@ -380,4 +383,19 @@ public class TeamService extends GitHubService {
}.getType());
return getAll(request);
}
+
+ /**
+ * Get teams of the current user across all of the GitHub organizations
+ *
+ * @return list of teams
+ * @throws IOException
+ */
+ public List<Team> getTeams() throws IOException {
+ StringBuilder uri = new StringBuilder(SEGMENT_USER).append(SEGMENT_TEAMS);
+ PagedRequest<Team> request = createPagedRequest();
+ request.setUri(uri);
+ request.setType(new TypeToken<List<Team>>(){}.getType());
+ return getAll(request);
+ }
+
}

Back to the top