View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.lang3.builder;
18  
19  import static org.junit.jupiter.api.Assertions.assertEquals;
20  
21  import org.apache.commons.lang3.AbstractLangTest;
22  import org.junit.jupiter.api.Test;
23  
24  /**
25   * Test case for ToStringStyle.
26   */
27  public class ToStringStyleTest extends AbstractLangTest {
28  
29      /**
30       * An object used to test {@link ToStringStyle}.
31       *
32       */
33      static class Person {
34          /**
35           * Test String field.
36           */
37          String name;
38  
39          /**
40           * Test integer field.
41           */
42          int age;
43  
44          /**
45           * Test boolean field.
46           */
47          boolean smoker;
48      }
49  
50      private static final class ToStringStyleImpl extends ToStringStyle {
51          private static final long serialVersionUID = 1L;
52  
53      }
54  
55      @Test
56      public void testSetArrayEnd() {
57          final ToStringStyle style = new ToStringStyleImpl();
58          style.setArrayEnd(null);
59          assertEquals("", style.getArrayEnd());
60      }
61  
62      @Test
63      public void testSetArraySeparator() {
64          final ToStringStyle style = new ToStringStyleImpl();
65          style.setArraySeparator(null);
66          assertEquals("", style.getArraySeparator());
67      }
68  
69      @Test
70      public void testSetArrayStart() {
71          final ToStringStyle style = new ToStringStyleImpl();
72          style.setArrayStart(null);
73          assertEquals("", style.getArrayStart());
74      }
75  
76      @Test
77      public void testSetContentEnd() {
78          final ToStringStyle style = new ToStringStyleImpl();
79          style.setContentEnd(null);
80          assertEquals("", style.getContentEnd());
81      }
82  
83      @Test
84      public void testSetContentStart() {
85          final ToStringStyle style = new ToStringStyleImpl();
86          style.setContentStart(null);
87          assertEquals("", style.getContentStart());
88      }
89  
90      @Test
91      public void testSetFieldNameValueSeparator() {
92          final ToStringStyle style = new ToStringStyleImpl();
93          style.setFieldNameValueSeparator(null);
94          assertEquals("", style.getFieldNameValueSeparator());
95      }
96  
97      @Test
98      public void testSetFieldSeparator() {
99          final ToStringStyle style = new ToStringStyleImpl();
100         style.setFieldSeparator(null);
101         assertEquals("", style.getFieldSeparator());
102     }
103 
104     @Test
105     public void testSetNullText() {
106         final ToStringStyle style = new ToStringStyleImpl();
107         style.setNullText(null);
108         assertEquals("", style.getNullText());
109     }
110 
111     @Test
112     public void testSetSizeEndText() {
113         final ToStringStyle style = new ToStringStyleImpl();
114         style.setSizeEndText(null);
115         assertEquals("", style.getSizeEndText());
116     }
117 
118     @Test
119     public void testSetSizeStartText() {
120         final ToStringStyle style = new ToStringStyleImpl();
121         style.setSizeStartText(null);
122         assertEquals("", style.getSizeStartText());
123     }
124 
125     @Test
126     public void testSetSummaryObjectEndText() {
127         final ToStringStyle style = new ToStringStyleImpl();
128         style.setSummaryObjectEndText(null);
129         assertEquals("", style.getSummaryObjectEndText());
130     }
131 
132     @Test
133     public void testSetSummaryObjectStartText() {
134         final ToStringStyle style = new ToStringStyleImpl();
135         style.setSummaryObjectStartText(null);
136         assertEquals("", style.getSummaryObjectStartText());
137     }
138 }