From 33d8d8b21c5586f1328c8c3e7f6049037ae5fd0d Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 4 Nov 2011 17:21:30 -0400 Subject: [PATCH] Moved SearchType enum to Constants --- src/com/gitblit/Constants.java | 21 ++++++++++++++ src/com/gitblit/SyndicationServlet.java | 5 ++-- src/com/gitblit/utils/JGitUtils.java | 23 +-------------- src/com/gitblit/utils/SyndicationUtils.java | 4 +-- src/com/gitblit/wicket/WicketUtils.java | 6 ++-- src/com/gitblit/wicket/pages/CommitPage.java | 8 ++--- .../gitblit/wicket/pages/RepositoryPage.java | 20 ++++++------- src/com/gitblit/wicket/pages/SearchPage.java | 4 +-- src/com/gitblit/wicket/pages/TagPage.java | 3 +- src/com/gitblit/wicket/panels/BasePanel.java | 8 ++--- .../gitblit/wicket/panels/BranchesPanel.java | 6 ++-- .../gitblit/wicket/panels/HistoryPanel.java | 6 ++-- src/com/gitblit/wicket/panels/LogPanel.java | 6 ++-- .../gitblit/wicket/panels/SearchPanel.java | 8 ++--- tests/com/gitblit/tests/JGitUtilsTest.java | 29 +++++++++---------- 15 files changed, 76 insertions(+), 81 deletions(-) diff --git a/src/com/gitblit/Constants.java b/src/com/gitblit/Constants.java index 2543ea12..3204a553 100644 --- a/src/com/gitblit/Constants.java +++ b/src/com/gitblit/Constants.java @@ -227,4 +227,25 @@ public class Constants { return name(); } } + + /** + * Enumeration of the search types. + */ + public static enum SearchType { + AUTHOR, COMMITTER, COMMIT; + + public static SearchType forName(String name) { + for (SearchType type : values()) { + if (type.name().equalsIgnoreCase(name)) { + return type; + } + } + return COMMIT; + } + + @Override + public String toString() { + return name().toLowerCase(); + } + } } diff --git a/src/com/gitblit/SyndicationServlet.java b/src/com/gitblit/SyndicationServlet.java index af0fab71..128df43f 100644 --- a/src/com/gitblit/SyndicationServlet.java +++ b/src/com/gitblit/SyndicationServlet.java @@ -33,7 +33,6 @@ import com.gitblit.models.RepositoryModel; import com.gitblit.models.SyndicatedEntryModel; import com.gitblit.utils.HttpUtils; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.utils.StringUtils; import com.gitblit.utils.SyndicationUtils; @@ -131,9 +130,9 @@ public class SyndicationServlet extends HttpServlet { String objectId = request.getParameter("h"); String l = request.getParameter("l"); String searchString = request.getParameter("s"); - SearchType searchType = SearchType.COMMIT; + Constants.SearchType searchType = Constants.SearchType.COMMIT; if (!StringUtils.isEmpty(request.getParameter("st"))) { - SearchType type = SearchType.forName(request.getParameter("st")); + Constants.SearchType type = Constants.SearchType.forName(request.getParameter("st")); if (type != null) { searchType = type; } diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 80147d46..c61b3d9f 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -924,27 +924,6 @@ public class JGitUtils { return list; } - /** - * Enumeration of the search types. - */ - public static enum SearchType { - AUTHOR, COMMITTER, COMMIT; - - public static SearchType forName(String name) { - for (SearchType type : values()) { - if (type.name().equalsIgnoreCase(name)) { - return type; - } - } - return COMMIT; - } - - @Override - public String toString() { - return name().toLowerCase(); - } - } - /** * Search the commit history for a case-insensitive match to the value. * Search results require a specified SearchType of AUTHOR, COMMITTER, or @@ -963,7 +942,7 @@ public class JGitUtils { * @return matching list of commits */ public static List searchRevlogs(Repository repository, String objectId, - String value, final SearchType type, int offset, int maxCount) { + String value, final com.gitblit.Constants.SearchType type, int offset, int maxCount) { final String lcValue = value.toLowerCase(); List list = new ArrayList(); if (maxCount == 0) { diff --git a/src/com/gitblit/utils/SyndicationUtils.java b/src/com/gitblit/utils/SyndicationUtils.java index 85d5f8d2..4ba56223 100644 --- a/src/com/gitblit/utils/SyndicationUtils.java +++ b/src/com/gitblit/utils/SyndicationUtils.java @@ -22,13 +22,11 @@ import java.io.OutputStreamWriter; import java.net.URLConnection; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import com.gitblit.Constants; import com.gitblit.GitBlitException; import com.gitblit.models.SyndicatedEntryModel; -import com.gitblit.utils.JGitUtils.SearchType; import com.sun.syndication.feed.synd.SyndCategory; import com.sun.syndication.feed.synd.SyndCategoryImpl; import com.sun.syndication.feed.synd.SyndContent; @@ -163,7 +161,7 @@ public class SyndicationUtils { * @throws {@link IOException} */ public static List readSearchFeed(String url, String repository, - String branch, String fragment, SearchType searchType, int numberOfEntries, + String branch, String fragment, Constants.SearchType searchType, int numberOfEntries, String username, char[] password) throws IOException { // determine parameters List parameters = new ArrayList(); diff --git a/src/com/gitblit/wicket/WicketUtils.java b/src/com/gitblit/wicket/WicketUtils.java index e5b7f697..f47663ca 100644 --- a/src/com/gitblit/wicket/WicketUtils.java +++ b/src/com/gitblit/wicket/WicketUtils.java @@ -39,13 +39,13 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType; import org.wicketstuff.googlecharts.AbstractChartData; import org.wicketstuff.googlecharts.IChartData; +import com.gitblit.Constants; import com.gitblit.Constants.FederationPullStatus; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.FederationModel; import com.gitblit.models.Metric; import com.gitblit.utils.HttpUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.utils.StringUtils; import com.gitblit.utils.TimeUtils; @@ -311,7 +311,7 @@ public class WicketUtils { } public static PageParameters newSearchParameter(String repositoryName, String commitId, - String search, SearchType type) { + String search, Constants.SearchType type) { if (StringUtils.isEmpty(commitId)) { return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name()); } @@ -320,7 +320,7 @@ public class WicketUtils { } public static PageParameters newSearchParameter(String repositoryName, String commitId, - String search, SearchType type, int pageNumber) { + String search, Constants.SearchType type, int pageNumber) { if (StringUtils.isEmpty(commitId)) { return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name() + ",page=" + pageNumber); diff --git a/src/com/gitblit/wicket/pages/CommitPage.java b/src/com/gitblit/wicket/pages/CommitPage.java index ad334467..dd3decbe 100644 --- a/src/com/gitblit/wicket/pages/CommitPage.java +++ b/src/com/gitblit/wicket/pages/CommitPage.java @@ -31,13 +31,13 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; +import com.gitblit.Constants; import com.gitblit.DownloadZipServlet; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.GitNote; import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.CommitHeaderPanel; import com.gitblit.wicket.panels.CommitLegendPanel; @@ -78,12 +78,12 @@ public class CommitPage extends RepositoryPage { addRefs(r, c); // author - add(createPersonPanel("commitAuthor", c.getAuthorIdent(), SearchType.AUTHOR)); + add(createPersonPanel("commitAuthor", c.getAuthorIdent(), Constants.SearchType.AUTHOR)); add(WicketUtils.createTimestampLabel("commitAuthorDate", c.getAuthorIdent().getWhen(), getTimeZone())); // committer - add(createPersonPanel("commitCommitter", c.getCommitterIdent(), SearchType.COMMITTER)); + add(createPersonPanel("commitCommitter", c.getCommitterIdent(), Constants.SearchType.COMMITTER)); add(WicketUtils.createTimestampLabel("commitCommitterDate", c.getCommitterIdent().getWhen(), getTimeZone())); @@ -125,7 +125,7 @@ public class CommitPage extends RepositoryPage { GitNote entry = item.getModelObject(); item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef))); item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(), - SearchType.AUTHOR)); + Constants.SearchType.AUTHOR)); item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef .getAuthorIdent().getWhen(), getTimeZone())); item.add(new Label("noteContent", GitBlit.self().processCommitMessage( diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index 2d616a49..4c417d95 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -38,12 +38,12 @@ import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; +import com.gitblit.Constants; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.SyndicationServlet; import com.gitblit.models.RepositoryModel; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.utils.StringUtils; import com.gitblit.utils.TicgitUtils; import com.gitblit.wicket.GitBlitWebSession; @@ -206,7 +206,7 @@ public abstract class RepositoryPage extends BasePage { protected abstract String getPageName(); protected Component createPersonPanel(String wicketId, PersonIdent identity, - SearchType searchType) { + Constants.SearchType searchType) { String name = identity == null ? "" : identity.getName(); String address = identity == null ? "" : identity.getEmailAddress(); boolean showEmail = GitBlit.getBoolean(Keys.web.showEmailAddresses, false); @@ -241,10 +241,10 @@ public abstract class RepositoryPage extends BasePage { } } - protected void setPersonSearchTooltip(Component component, String value, SearchType searchType) { - if (searchType.equals(SearchType.AUTHOR)) { + protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) { + if (searchType.equals(Constants.SearchType.AUTHOR)) { WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value); - } else if (searchType.equals(SearchType.COMMITTER)) { + } else if (searchType.equals(Constants.SearchType.COMMITTER)) { WicketUtils.setHtmlTooltip(component, getString("gb.searchForCommitter") + " " + value); } } @@ -298,13 +298,13 @@ public abstract class RepositoryPage extends BasePage { private final IModel searchBoxModel = new Model(""); - private final IModel searchTypeModel = new Model(SearchType.COMMIT); + private final IModel searchTypeModel = new Model(Constants.SearchType.COMMIT); public SearchForm(String id, String repositoryName) { super(id); this.repositoryName = repositoryName; - DropDownChoice searchType = new DropDownChoice("searchType", - Arrays.asList(SearchType.values())); + DropDownChoice searchType = new DropDownChoice("searchType", + Arrays.asList(Constants.SearchType.values())); searchType.setModel(searchTypeModel); add(searchType.setVisible(GitBlit.getBoolean(Keys.web.showSearchTypeSelection, false))); TextField searchBox = new TextField("searchBox", searchBoxModel); @@ -320,13 +320,13 @@ public abstract class RepositoryPage extends BasePage { @Override public void onSubmit() { - SearchType searchType = searchTypeModel.getObject(); + Constants.SearchType searchType = searchTypeModel.getObject(); String searchString = searchBoxModel.getObject(); if (searchString == null) { // FIXME IE intermittently has no searchString. Wicket bug? return; } - for (SearchType type : SearchType.values()) { + for (Constants.SearchType type : Constants.SearchType.values()) { if (searchString.toLowerCase().startsWith(type.name().toLowerCase() + ":")) { searchType = type; searchString = searchString.substring(type.name().toLowerCase().length() + 1) diff --git a/src/com/gitblit/wicket/pages/SearchPage.java b/src/com/gitblit/wicket/pages/SearchPage.java index 335c40d7..d4728d79 100644 --- a/src/com/gitblit/wicket/pages/SearchPage.java +++ b/src/com/gitblit/wicket/pages/SearchPage.java @@ -18,7 +18,7 @@ package com.gitblit.wicket.pages; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import com.gitblit.utils.JGitUtils.SearchType; +import com.gitblit.Constants; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.SearchPanel; @@ -29,7 +29,7 @@ public class SearchPage extends RepositoryPage { String value = WicketUtils.getSearchString(params); String type = WicketUtils.getSearchType(params); - SearchType searchType = SearchType.forName(type); + Constants.SearchType searchType = Constants.SearchType.forName(type); int pageNumber = WicketUtils.getPage(params); int prevPage = Math.max(0, pageNumber - 1); diff --git a/src/com/gitblit/wicket/pages/TagPage.java b/src/com/gitblit/wicket/pages/TagPage.java index a346670e..b1ab0714 100644 --- a/src/com/gitblit/wicket/pages/TagPage.java +++ b/src/com/gitblit/wicket/pages/TagPage.java @@ -27,7 +27,6 @@ import org.eclipse.jgit.lib.Repository; import com.gitblit.models.RefModel; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.LinkPanel; import com.gitblit.wicket.panels.RefsPanel; @@ -80,7 +79,7 @@ public class TagPage extends RepositoryPage { linkClass, linkParameters)); add(new Label("taggedObjectType", getString(typeKey))); - add(createPersonPanel("tagger", tagRef.getAuthorIdent(), SearchType.AUTHOR)); + add(createPersonPanel("tagger", tagRef.getAuthorIdent(), com.gitblit.Constants.SearchType.AUTHOR)); Date when = new Date(0); if (tagRef.getAuthorIdent() != null) { when = tagRef.getAuthorIdent().getWhen(); diff --git a/src/com/gitblit/wicket/panels/BasePanel.java b/src/com/gitblit/wicket/panels/BasePanel.java index 9dda03c2..8ea2a697 100644 --- a/src/com/gitblit/wicket/panels/BasePanel.java +++ b/src/com/gitblit/wicket/panels/BasePanel.java @@ -22,9 +22,9 @@ import org.apache.wicket.Component; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.Model; +import com.gitblit.Constants; import com.gitblit.GitBlit; import com.gitblit.Keys; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.WicketUtils; @@ -41,10 +41,10 @@ public abstract class BasePanel extends Panel { .getTimezone() : TimeZone.getDefault(); } - protected void setPersonSearchTooltip(Component component, String value, SearchType searchType) { - if (searchType.equals(SearchType.AUTHOR)) { + protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) { + if (searchType.equals(Constants.SearchType.AUTHOR)) { WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value); - } else if (searchType.equals(SearchType.COMMITTER)) { + } else if (searchType.equals(Constants.SearchType.COMMITTER)) { WicketUtils.setHtmlTooltip(component, getString("gb.searchForCommitter") + " " + value); } } diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java index d45c0e62..6eb40199 100644 --- a/src/com/gitblit/wicket/panels/BranchesPanel.java +++ b/src/com/gitblit/wicket/panels/BranchesPanel.java @@ -29,11 +29,11 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider; import org.apache.wicket.model.StringResourceModel; import org.eclipse.jgit.lib.Repository; +import com.gitblit.Constants; import com.gitblit.SyndicationServlet; import com.gitblit.models.RefModel; import com.gitblit.models.RepositoryModel; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.pages.BranchesPage; @@ -95,8 +95,8 @@ public class BranchesPanel extends BasePanel { String author = entry.getAuthorIdent().getName(); LinkPanel authorLink = new LinkPanel("branchAuthor", "list", author, SearchPage.class, WicketUtils.newSearchParameter(model.name, - entry.getName(), author, SearchType.AUTHOR)); - setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR); + entry.getName(), author, Constants.SearchType.AUTHOR)); + setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR); item.add(authorLink); // short message diff --git a/src/com/gitblit/wicket/panels/HistoryPanel.java b/src/com/gitblit/wicket/panels/HistoryPanel.java index 9ad407ca..16f95f22 100644 --- a/src/com/gitblit/wicket/panels/HistoryPanel.java +++ b/src/com/gitblit/wicket/panels/HistoryPanel.java @@ -30,13 +30,13 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; +import com.gitblit.Constants; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.PathModel; import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.RefModel; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.pages.BlobDiffPage; @@ -109,8 +109,8 @@ public class HistoryPanel extends BasePanel { String author = entry.getAuthorIdent().getName(); LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author, SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, - author, SearchType.AUTHOR)); - setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR); + author, Constants.SearchType.AUTHOR)); + setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR); item.add(authorLink); // merge icon diff --git a/src/com/gitblit/wicket/panels/LogPanel.java b/src/com/gitblit/wicket/panels/LogPanel.java index 66fddd2c..90b6745f 100644 --- a/src/com/gitblit/wicket/panels/LogPanel.java +++ b/src/com/gitblit/wicket/panels/LogPanel.java @@ -29,11 +29,11 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; +import com.gitblit.Constants; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.RefModel; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.pages.CommitDiffPage; @@ -100,8 +100,8 @@ public class LogPanel extends BasePanel { String author = entry.getAuthorIdent().getName(); LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author, SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, - author, SearchType.AUTHOR)); - setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR); + author, Constants.SearchType.AUTHOR)); + setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR); item.add(authorLink); // merge icon diff --git a/src/com/gitblit/wicket/panels/SearchPanel.java b/src/com/gitblit/wicket/panels/SearchPanel.java index d118790c..44b499b2 100644 --- a/src/com/gitblit/wicket/panels/SearchPanel.java +++ b/src/com/gitblit/wicket/panels/SearchPanel.java @@ -28,11 +28,11 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; +import com.gitblit.Constants; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.RefModel; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.pages.CommitDiffPage; @@ -47,7 +47,7 @@ public class SearchPanel extends BasePanel { private boolean hasMore; public SearchPanel(String wicketId, final String repositoryName, final String objectId, - final String value, SearchType searchType, Repository r, int limit, int pageOffset) { + final String value, Constants.SearchType searchType, Repository r, int limit, int pageOffset) { super(wicketId); boolean pageResults = limit <= 0; int itemsPerPage = GitBlit.getInteger(Keys.web.itemsPerPage, 50); @@ -93,8 +93,8 @@ public class SearchPanel extends BasePanel { String author = entry.getAuthorIdent().getName(); LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author, SearchPage.class, WicketUtils.newSearchParameter(repositoryName, objectId, - author, SearchType.AUTHOR)); - setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR); + author, Constants.SearchType.AUTHOR)); + setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR); item.add(authorLink); // merge icon diff --git a/tests/com/gitblit/tests/JGitUtilsTest.java b/tests/com/gitblit/tests/JGitUtilsTest.java index 0d7aa635..594d090d 100644 --- a/tests/com/gitblit/tests/JGitUtilsTest.java +++ b/tests/com/gitblit/tests/JGitUtilsTest.java @@ -42,7 +42,6 @@ import com.gitblit.models.PathModel; import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.RefModel; import com.gitblit.utils.JGitUtils; -import com.gitblit.utils.JGitUtils.SearchType; import com.gitblit.utils.StringUtils; public class JGitUtilsTest extends TestCase { @@ -306,37 +305,37 @@ public class JGitUtilsTest extends TestCase { } public void testSearchTypes() throws Exception { - assertTrue(SearchType.forName("commit").equals(SearchType.COMMIT)); - assertTrue(SearchType.forName("committer").equals(SearchType.COMMITTER)); - assertTrue(SearchType.forName("author").equals(SearchType.AUTHOR)); - assertTrue(SearchType.forName("unknown").equals(SearchType.COMMIT)); - - assertTrue(SearchType.COMMIT.toString().equals("commit")); - assertTrue(SearchType.COMMITTER.toString().equals("committer")); - assertTrue(SearchType.AUTHOR.toString().equals("author")); + assertTrue(com.gitblit.Constants.SearchType.forName("commit").equals(com.gitblit.Constants.SearchType.COMMIT)); + assertTrue(com.gitblit.Constants.SearchType.forName("committer").equals(com.gitblit.Constants.SearchType.COMMITTER)); + assertTrue(com.gitblit.Constants.SearchType.forName("author").equals(com.gitblit.Constants.SearchType.AUTHOR)); + assertTrue(com.gitblit.Constants.SearchType.forName("unknown").equals(com.gitblit.Constants.SearchType.COMMIT)); + + assertTrue(com.gitblit.Constants.SearchType.COMMIT.toString().equals("commit")); + assertTrue(com.gitblit.Constants.SearchType.COMMITTER.toString().equals("committer")); + assertTrue(com.gitblit.Constants.SearchType.AUTHOR.toString().equals("author")); } public void testSearchRevlogs() throws Exception { - assertTrue(JGitUtils.searchRevlogs(null, null, "java", SearchType.COMMIT, 0, 0).size() == 0); - List results = JGitUtils.searchRevlogs(null, null, "java", SearchType.COMMIT, 0, + assertTrue(JGitUtils.searchRevlogs(null, null, "java", com.gitblit.Constants.SearchType.COMMIT, 0, 0).size() == 0); + List results = JGitUtils.searchRevlogs(null, null, "java", com.gitblit.Constants.SearchType.COMMIT, 0, 3); assertTrue(results.size() == 0); // test commit message search Repository repository = GitBlitSuite.getHelloworldRepository(); - results = JGitUtils.searchRevlogs(repository, null, "java", SearchType.COMMIT, 0, 3); + results = JGitUtils.searchRevlogs(repository, null, "java", com.gitblit.Constants.SearchType.COMMIT, 0, 3); assertTrue(results.size() == 3); // test author search - results = JGitUtils.searchRevlogs(repository, null, "timothy", SearchType.AUTHOR, 0, -1); + results = JGitUtils.searchRevlogs(repository, null, "timothy", com.gitblit.Constants.SearchType.AUTHOR, 0, -1); assertTrue(results.size() == 1); // test committer search - results = JGitUtils.searchRevlogs(repository, null, "mike", SearchType.COMMITTER, 0, 10); + results = JGitUtils.searchRevlogs(repository, null, "mike", com.gitblit.Constants.SearchType.COMMITTER, 0, 10); assertTrue(results.size() == 10); // test paging and offset - RevCommit commit = JGitUtils.searchRevlogs(repository, null, "mike", SearchType.COMMITTER, + RevCommit commit = JGitUtils.searchRevlogs(repository, null, "mike", com.gitblit.Constants.SearchType.COMMITTER, 9, 1).get(0); assertTrue(results.get(9).equals(commit)); -- 2.39.5