1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.internal.macro.ctsreport

File ResultExtractorTest.java

 

Code metrics

0
46
4
1
124
80
4
0.09
11.5
4
1

Classes

Class Line # Actions
ResultExtractorTest 38 46 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.internal.macro.ctsreport;
21   
22    import java.util.Arrays;
23    import java.util.Iterator;
24    import java.util.List;
25    import java.util.Map;
26    import java.util.Set;
27   
28    import org.apache.commons.lang3.tuple.Pair;
29    import org.junit.Assert;
30    import org.junit.Before;
31   
32    /**
33    * Unit tests for {@link ResultExtractor}.
34    *
35    * @version $Id: ee5263d10247b28a718adaa39709359cb6eba675 $
36    * @since 4.1M2
37    */
 
38    public class ResultExtractorTest
39    {
40    private List<Result> results;
41   
 
42  3 toggle @Before
43    public void setUpResults()
44    {
45  3 TestParser parser = new TestParser();
46  3 this.results = Arrays.asList(
47    parser.parse("simple/italic/italic1 [xwiki/2.0, IN:.inout.txt, CTS:.inout.xml] - Passed"),
48    parser.parse("simple/italic/italic1 [xwiki/2.1, IN:.inout.txt, CTS:.inout.xml] - Passed"),
49    parser.parse("simple/bold/bold1 [xwiki/2.0, IN:.inout.txt, CTS:.inout.xml] - Passed"),
50    parser.parse("simple/bold/bold1 [xwiki/2.0, OUT:.inout.txt, CTS:.inout.xml] - Passed")
51    );
52    }
53   
 
54  1 toggle @org.junit.Test
55    public void extractByTestName()
56    {
57  1 ResultExtractor extractor = new ResultExtractor();
58  1 Set<String> testNames = extractor.extractByTestName(this.results);
59   
60  1 Assert.assertEquals(2, testNames.size());
61  1 Iterator<String> it = testNames.iterator();
62  1 Assert.assertEquals("simple/bold/bold1", it.next());
63  1 Assert.assertEquals("simple/italic/italic1", it.next());
64    }
65   
 
66  1 toggle @org.junit.Test
67    public void extractBySyntaxes()
68    {
69  1 ResultExtractor extractor = new ResultExtractor();
70  1 Map<String, Pair<Set<Test>, Set<Test>>> tests = extractor.extractBySyntax(this.results);
71   
72  1 Assert.assertEquals(2, tests.size());
73   
74  1 Set<Test> inTestsForXWiki20 = tests.get("xwiki/2.0").getLeft();
75  1 Assert.assertEquals(2, inTestsForXWiki20.size());
76  1 Iterator<Test> it = inTestsForXWiki20.iterator();
77  1 Assert.assertEquals("simple/bold/bold1", it.next().prefix);
78  1 Assert.assertEquals("simple/italic/italic1", it.next().prefix);
79   
80  1 Set<Test> outTestsForXWiki20 = tests.get("xwiki/2.0").getRight();
81  1 Assert.assertEquals(1, outTestsForXWiki20.size());
82  1 Assert.assertEquals("simple/bold/bold1", outTestsForXWiki20.iterator().next().prefix);
83   
84  1 Set<Test> inTestsForXWiki21 = tests.get("xwiki/2.1").getLeft();
85  1 Assert.assertEquals(1, inTestsForXWiki21.size());
86  1 Assert.assertEquals("simple/italic/italic1", inTestsForXWiki21.iterator().next().prefix);
87   
88  1 Set<Test> outTestsForXWiki21 = tests.get("xwiki/2.1").getRight();
89  1 Assert.assertEquals(0, outTestsForXWiki21.size());
90    }
91   
 
92  1 toggle @org.junit.Test
93    public void normalize()
94    {
95  1 ResultExtractor extractor = new ResultExtractor();
96  1 Set<String> testNames = extractor.extractByTestName(this.results);
97  1 Map<String, Pair<Set<Test>, Set<Test>>> tests = extractor.extractBySyntax(this.results);
98  1 extractor.normalize(testNames, tests);
99   
100  1 Assert.assertEquals(2, tests.size());
101   
102  1 Set<Test> inTestsForXWiki20 = tests.get("xwiki/2.0").getLeft();
103  1 Assert.assertEquals(2, inTestsForXWiki20.size());
104  1 Iterator<Test> it = inTestsForXWiki20.iterator();
105  1 Assert.assertEquals("simple/bold/bold1", it.next().prefix);
106  1 Assert.assertEquals("simple/italic/italic1", it.next().prefix);
107   
108  1 Set<Test> outTestsForXWiki20 = tests.get("xwiki/2.0").getRight();
109  1 it = outTestsForXWiki20.iterator();
110  1 Assert.assertEquals(2, outTestsForXWiki20.size());
111  1 Assert.assertEquals("simple/bold/bold1", it.next().prefix);
112  1 Assert.assertEquals("simple/italic/italic1", it.next().prefix);
113   
114  1 Set<Test> inTestsForXWiki21 = tests.get("xwiki/2.1").getLeft();
115  1 it = inTestsForXWiki21.iterator();
116  1 Assert.assertEquals(2, inTestsForXWiki21.size());
117  1 Assert.assertEquals("simple/bold/bold1", it.next().prefix);
118  1 Assert.assertEquals("simple/italic/italic1", it.next().prefix);
119   
120  1 Set<Test> outTestsForXWiki21 = tests.get("xwiki/2.1").getRight();
121  1 Assert.assertEquals(0, outTestsForXWiki21.size());
122    }
123   
124    }