diff options
author | chris.poon | 2015-08-27 17:19:17 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2015-08-27 23:42:14 +0000 |
commit | 612d39ca972617ee4c4893c1b1d47a2865035cfa (patch) | |
tree | f2dc8422dd349e79fcaf4e41e6d41eeb7d4f416f | |
parent | fb0dd853c932e1a0f14ca302c2bcfe53a5e7393c (diff) | |
download | org.eclipse.mylyn.reviews-612d39ca972617ee4c4893c1b1d47a2865035cfa.tar.gz org.eclipse.mylyn.reviews-612d39ca972617ee4c4893c1b1d47a2865035cfa.tar.xz org.eclipse.mylyn.reviews-612d39ca972617ee4c4893c1b1d47a2865035cfa.zip |
475408: gerrit dashboard doesn't show owner for git.eclipse.org
Change-Id: Id5083eda372fcb65f94ee89325af4025cf15aa88
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=475408
Signed-off-by: chris.poon <chris.poon@tasktop.com>
4 files changed, 54 insertions, 82 deletions
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritRestClient.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritRestClient.java index c3e61bbd6..d4cedc0e7 100644 --- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritRestClient.java +++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritRestClient.java @@ -22,6 +22,7 @@ import org.eclipse.mylyn.internal.gerrit.core.client.GerritHttpClient.ErrorHandl import org.eclipse.mylyn.internal.gerrit.core.client.GerritService.GerritRequest; import org.eclipse.mylyn.internal.gerrit.core.client.data.GerritQueryResult; +import com.google.common.collect.ImmutableList; import com.google.gson.reflect.TypeToken; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -74,6 +75,8 @@ public class GerritRestClient { protected static final String GET_LABELS_OPTION = "LABELS"; //$NON-NLS-1$ + protected static final String GET_DETAILED_ACCOUNTS_OPTION = "DETAILED_ACCOUNTS"; //$NON-NLS-1$ + private final GerritHttpClient client; public GerritRestClient(GerritHttpClient client) { @@ -189,25 +192,7 @@ public class GerritRestClient { */ public List<GerritQueryResult> executeQuery(IProgressMonitor monitor, final String queryString) throws GerritException { - return executeQuery(monitor, queryString, GET_LABELS_OPTION); - } - - /** - * Sends a query for the changes visible to the caller to the gerrit server with the possibility of adding options - * to the query. - * - * @param monitor - * A progress monitor - * @param queryString - * The specific gerrit change query - * @param optionString - * Query options ("&o=" parameter). Only applicable for the REST API, ignored otherwise. May be null. - * @return a list of GerritQueryResults built from the parsed query result (ChangeInfo:s) - * @throws GerritException - */ - public List<GerritQueryResult> executeQuery(IProgressMonitor monitor, final String queryString, String optionString) - throws GerritException { - return executeQueryInternal(monitor, queryString, optionString); + return executeQuery(monitor, queryString, ImmutableList.of(GET_LABELS_OPTION, GET_DETAILED_ACCOUNTS_OPTION)); } /** @@ -218,16 +203,21 @@ public class GerritRestClient { * A progress monitor * @param queryString * The specific gerrit change query - * @param optionString - * Query options ("&o=" parameter). May be null or empty. + * @param optionsList + * List of query options ("&o=" parameter). Only applicable for the REST API, ignored otherwise. May be + * null or empty. * @return a list of GerritQueryResults built from the parsed query result (ChangeInfo:s) * @throws GerritException */ - protected List<GerritQueryResult> executeQueryInternal(IProgressMonitor monitor, final String queryString, - String optionString) throws GerritException { + public List<GerritQueryResult> executeQuery(IProgressMonitor monitor, final String queryString, + List<String> optionsList) throws GerritException { String uri = "/changes/?q=" + GerritClient.encode(queryString); //$NON-NLS-1$ - if (StringUtils.isNotBlank(optionString)) { - uri += "&o=" + GerritClient.encode(optionString); //$NON-NLS-1$ + if (optionsList != null && !optionsList.isEmpty()) { + for (String option : optionsList) { + if (StringUtils.isNotBlank(option)) { + uri += "&o=" + GerritClient.encode(option); //$NON-NLS-1$ + } + } } TypeToken<List<GerritQueryResult>> queryResultListType = new TypeToken<List<GerritQueryResult>>() { }; @@ -254,7 +244,7 @@ public class GerritRestClient { * user. On Gerrit 2.4 and earlier closed reviews are not included. */ public List<GerritQueryResult> queryMyReviews(IProgressMonitor monitor) throws GerritException { - return executeQueryInternal(monitor, "owner:self OR reviewer:self", GET_LABELS_OPTION); //$NON-NLS-1$ + return executeQuery(monitor, "owner:self OR reviewer:self"); //$NON-NLS-1$ } /** diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/data/GerritPerson.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/data/GerritPerson.java index 56cf1f71d..8d3ade518 100644 --- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/data/GerritPerson.java +++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/data/GerritPerson.java @@ -18,6 +18,8 @@ public class GerritPerson { private String name; + private String _account_id; + public String getName() { return name; } diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/GerritConnectorTest.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/GerritConnectorTest.java index c54023a29..8d40b6240 100644 --- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/GerritConnectorTest.java +++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/GerritConnectorTest.java @@ -86,7 +86,9 @@ public class GerritConnectorTest extends TestCase { // 'expand' the abbreviated SHA-1 with 'a's String objId = StringUtils.rightPad(value.substring(1), Constants.OBJECT_ID_STRING_LENGTH, 'a'); assertTrue(ObjectId.isId(objId)); + TaskAttribute owner = result.getRoot().getAttribute(GerritTaskSchema.getDefault().OWNER.getKey()); + assertNotNull(owner); + assertTrue(StringUtils.isNotBlank(owner.getValue())); } } - } diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java index ab9af976e..3384022e6 100644 --- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java +++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java @@ -56,6 +56,7 @@ import org.junit.Before; import org.junit.Test; import org.mockito.verification.VerificationMode; +import com.google.common.collect.ImmutableList; import com.google.gerrit.reviewdb.Account; import com.google.gerrit.reviewdb.Patch.ChangeType; import com.google.gerrit.reviewdb.Patch.Key; @@ -105,6 +106,8 @@ public class GerritClientTest extends TestCase { private static final String GET_LABELS_OPTION = "LABELS"; //$NON-NLS-1$ + private static final String GET_DETAILED_ACCOUNTS_OPTION = "DETAILED_ACCOUNTS"; //$NON-NLS-1$ + private GerritHarness harness; private GerritClient client; @@ -179,15 +182,11 @@ public class GerritClientTest extends TestCase { } private List<GerritQueryResult> executeQuery(String query) throws GerritException { - List<GerritQueryResult> results = null; - results = client.getRestClient().executeQuery(new NullProgressMonitor(), query); - return results; + return client.getRestClient().executeQuery(new NullProgressMonitor(), query); } - private List<GerritQueryResult> executeQuery(String query, String option) throws GerritException { - List<GerritQueryResult> results = null; - results = client.getRestClient().executeQuery(new NullProgressMonitor(), query, option); - return results; + private List<GerritQueryResult> executeQuery(String query, List<String> options) throws GerritException { + return client.getRestClient().executeQuery(new NullProgressMonitor(), query, options); } @Test @@ -200,24 +199,32 @@ public class GerritClientTest extends TestCase { @Test public void testExecuteQueryWithNullOption() throws Exception { String query = "status:open"; - String option = null; - List<GerritQueryResult> results = executeQuery(query, option); + List<String> options = null; + List<GerritQueryResult> results = executeQuery(query, options); + assertNotNull(results); + } + + @Test + public void testExecuteQueryWithEmptyList() throws Exception { + String query = "status:open"; + List<String> options = ImmutableList.of(); + List<GerritQueryResult> results = executeQuery(query, options); assertNotNull(results); } @Test public void testExecuteQueryWithEmptyOption() throws Exception { String query = "status:open"; - String option = ""; - List<GerritQueryResult> results = executeQuery(query, option); + List<String> options = ImmutableList.of(""); + List<GerritQueryResult> results = executeQuery(query, options); assertNotNull(results); } @Test public void testExecuteQueryWithOption() throws Exception { String query = "status:open"; - String option = GET_LABELS_OPTION; - List<GerritQueryResult> results = executeQuery(query, option); + List<String> options = ImmutableList.of(GET_LABELS_OPTION); + List<GerritQueryResult> results = executeQuery(query, options); assertNotNull(results); for (int index = 0; index < results.size(); index++) { assertNotNull(results.get(index)); @@ -225,68 +232,39 @@ public class GerritClientTest extends TestCase { } } - private List<GerritQueryResult> executeQueryRest(String query) throws GerritException { - return client.getRestClient().executeQuery(new NullProgressMonitor(), query); - } - - private List<GerritQueryResult> executeQueryRest(String query, String option) throws GerritException { - return client.getRestClient().executeQuery(new NullProgressMonitor(), query, option); - } - - @Test - public void testExecuteQueryRestWithoutOption() throws Exception { - String query = "status:open"; - List<GerritQueryResult> results = executeQueryRest(query); - - assertNotNull(results); - } - - @Test - public void testExecuteQueryRestWithNullOption() throws Exception { - String query = "status:open"; - String option = null; - List<GerritQueryResult> results = executeQueryRest(query, option); - assertNotNull(results); - } - - @Test - public void testExecuteQueryRestWithEmptyOption() throws Exception { - String query = "status:open"; - String option = ""; - List<GerritQueryResult> results = null; - results = executeQueryRest(query, option); - assertNotNull(results); - } - @Test - public void testExecuteQueryvWithOption() throws Exception { + public void testExecuteQueryWithMultipleOptions() throws Exception { String query = "status:open"; - String option = GET_LABELS_OPTION; - List<GerritQueryResult> results = executeQuery(query, option); + List<String> options = ImmutableList.of(GET_LABELS_OPTION, GET_DETAILED_ACCOUNTS_OPTION); + List<GerritQueryResult> results = executeQuery(query, options); assertNotNull(results); + for (int index = 0; index < results.size(); index++) { + assertNotNull(results.get(index)); + assertNotNull(results.get(index).getReviewLabel()); + } } @Test public void testExecuteQueryAllMerged() throws GerritException { String query = "status:merged"; - String option = GET_LABELS_OPTION; - List<GerritQueryResult> results = executeQuery(query, option); + List<String> options = ImmutableList.of(GET_LABELS_OPTION); + List<GerritQueryResult> results = executeQuery(query, options); assertNotNull(results); } @Test public void testExecuteQueryAllAbandoned() throws GerritException { String query = "status:abandoned"; - String option = GET_LABELS_OPTION; - List<GerritQueryResult> results = executeQuery(query, option); + List<String> options = ImmutableList.of(GET_LABELS_OPTION); + List<GerritQueryResult> results = executeQuery(query, options); assertNotNull(results); } @Test public void testExecuteQueryisStarred() throws GerritException { String query = "is:starred status:open"; - String option = GET_LABELS_OPTION; - List<GerritQueryResult> results = executeQuery(query, option); + List<String> options = ImmutableList.of(GET_LABELS_OPTION); + List<GerritQueryResult> results = executeQuery(query, options); assertNotNull(results); } |