From 74b4db841f41835ab96521d2bd93dee318b94000 Mon Sep 17 00:00:00 2001 From: Singaram Subramanian Date: Sun, 25 Feb 2018 14:26:43 -0800 Subject: Get user's teams across GitHub organizations User may belong to different teams in different GitHub organizations. This change is to retrieve all those teams across organizations using GitHub APIs. Bug: 529850 Change-Id: I703c3385e26ffcd4e34aa1aa1515f6e53fbdf008 Signed-off-by: Singaram Subramanian --- .../egit/github/core/tests/OrganizationTest.java | 50 ++++++++++++++++++++++ .../egit/github/core/tests/TeamServiceTest.java | 17 +++++++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/OrganizationTest.java (limited to 'org.eclipse.egit.github.core.tests/src/org/eclipse') 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 + * 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); + } } -- cgit v1.2.3