Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

MetricUtilsTest.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2011 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit.tests;
  17. import static org.junit.Assert.assertEquals;
  18. import static org.junit.Assert.assertTrue;
  19. import java.util.List;
  20. import java.util.TimeZone;
  21. import org.eclipse.jgit.lib.Repository;
  22. import org.junit.Test;
  23. import com.gitblit.models.Metric;
  24. import com.gitblit.utils.MetricUtils;
  25. public class MetricUtilsTest {
  26. @Test
  27. public void testMetrics() throws Exception {
  28. testMetrics(GitBlitSuite.getHelloworldRepository());
  29. testMetrics(GitBlitSuite.getJGitRepository());
  30. }
  31. private void testMetrics(Repository repository) throws Exception {
  32. List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null,
  33. TimeZone.getDefault());
  34. repository.close();
  35. assertTrue("No date metrics found!", metrics.size() > 0);
  36. }
  37. @Test
  38. public void testAuthorMetrics() throws Exception {
  39. Repository repository = GitBlitSuite.getHelloworldRepository();
  40. List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, null, true);
  41. List<Metric> byName = MetricUtils.getAuthorMetrics(repository, null, false);
  42. repository.close();
  43. assertEquals("No author metrics found!", 9, byEmail.size());
  44. assertEquals("No author metrics found!", 8, byName.size());
  45. }
  46. }