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