1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.text

File XWikiToStringBuilderTest.java

 

Code metrics

0
4
3
2
70
38
3
0.75
1.33
1.5
1

Classes

Class Line # Actions
XWikiToStringBuilderTest 37 1 0% 1 0
1.0100%
XWikiToStringBuilderTest.TestClass 39 3 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

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.text;
21   
22    import java.util.Arrays;
23    import java.util.LinkedHashMap;
24    import java.util.List;
25    import java.util.Map;
26   
27    import org.junit.Test;
28   
29    import org.junit.Assert;
30   
31    /**
32    * Unit tests for {@link XWikiToStringBuilder}.
33    *
34    * @version $Id: 283a72f658188494712d3907902f7f79478f5940 $
35    * @since 4.0M2
36    */
 
37    public class XWikiToStringBuilderTest
38    {
 
39    public class TestClass
40    {
41    private String field1 = "value1";
42    private Integer field2 = 100;
43    private Map<String, String> field3 = new LinkedHashMap<String, String>();
44    private List<String> field4 = Arrays.asList("value");
45   
 
46  1 toggle public TestClass()
47    {
48  1 this.field3.put("key1", "value1");
49  1 this.field3.put("key2", "value2");
50    }
51   
 
52  1 toggle @Override
53    public String toString()
54    {
55  1 return new XWikiToStringBuilder(this)
56    .append("field1", field1)
57    .append("field2", field2)
58    .append("field3", field3)
59    .append("field4", field4)
60    .toString();
61    }
62    }
63   
 
64  1 toggle @Test
65    public void toStringBuilder()
66    {
67  1 Assert.assertEquals("field1 = [value1], field2 = [100], field3 = [[key1] = [value1], [key2] = [value2]], "
68    + "field4 = [[value]]", new TestClass().toString());
69    }
70    }