James Moger
2012-01-31 78dc06a87f82ed19e3eebe1f16dc6c1bdaf5fbc5
commit | author | age
793f76 1 /*
JM 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
7e8873 18 import static org.junit.Assert.assertEquals;
JM 19 import static org.junit.Assert.assertTrue;
20
793f76 21 import java.util.List;
JM 22
23 import org.eclipse.jgit.lib.Repository;
7e8873 24 import org.junit.Test;
793f76 25
JM 26 import com.gitblit.models.Metric;
27 import com.gitblit.utils.MetricUtils;
28
7e8873 29 public class MetricUtilsTest {
793f76 30
7e8873 31     @Test
793f76 32     public void testMetrics() throws Exception {
88598b 33         testMetrics(GitBlitSuite.getHelloworldRepository());
JM 34         testMetrics(GitBlitSuite.getBluezGnomeRepository());
35     }
36
37     private void testMetrics(Repository repository) throws Exception {
1fa5e8 38         List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null);
793f76 39         repository.close();
a125cf 40         assertTrue("No date metrics found!", metrics.size() > 0);
JM 41     }
008322 42
7e8873 43     @Test
a125cf 44     public void testAuthorMetrics() throws Exception {
JM 45         Repository repository = GitBlitSuite.getHelloworldRepository();
1fa5e8 46         List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, null, true);
JM 47         List<Metric> byName = MetricUtils.getAuthorMetrics(repository, null, false);
a125cf 48         repository.close();
7e8873 49         assertEquals("No author metrics found!", 9, byEmail.size());
JM 50         assertEquals("No author metrics found!", 8, byName.size());
793f76 51     }
JM 52 }