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    *      https://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  class ToStringStyleTest extends AbstractLangTest {
28  
29      /**
30       * An object used to test {@link ToStringStyle}.
31       */
32      static class Person {
33          /**
34           * Test String field.
35           */
36          String name;
37  
38          /**
39           * Test integer field.
40           */
41          int age;
42  
43          /**
44           * Test boolean field.
45           */
46          boolean smoker;
47      }
48  
49      private static final class ToStringStyleImpl extends ToStringStyle {
50          private static final long serialVersionUID = 1L;
51  
52      }
53  
54      @Test
55      void testSetArrayEnd() {
56          final ToStringStyle style = new ToStringStyleImpl();
57          style.setArrayEnd(null);
58          assertEquals("", style.getArrayEnd());
59      }
60  
61      @Test
62      void testSetArraySeparator() {
63          final ToStringStyle style = new ToStringStyleImpl();
64          style.setArraySeparator(null);
65          assertEquals("", style.getArraySeparator());
66      }
67  
68      @Test
69      void testSetArrayStart() {
70          final ToStringStyle style = new ToStringStyleImpl();
71          style.setArrayStart(null);
72          assertEquals("", style.getArrayStart());
73      }
74  
75      @Test
76      void testSetContentEnd() {
77          final ToStringStyle style = new ToStringStyleImpl();
78          style.setContentEnd(null);
79          assertEquals("", style.getContentEnd());
80      }
81  
82      @Test
83      void testSetContentStart() {
84          final ToStringStyle style = new ToStringStyleImpl();
85          style.setContentStart(null);
86          assertEquals("", style.getContentStart());
87      }
88  
89      @Test
90      void testSetFieldNameValueSeparator() {
91          final ToStringStyle style = new ToStringStyleImpl();
92          style.setFieldNameValueSeparator(null);
93          assertEquals("", style.getFieldNameValueSeparator());
94      }
95  
96      @Test
97      void testSetFieldSeparator() {
98          final ToStringStyle style = new ToStringStyleImpl();
99          style.setFieldSeparator(null);
100         assertEquals("", style.getFieldSeparator());
101     }
102 
103     @Test
104     void testSetNullText() {
105         final ToStringStyle style = new ToStringStyleImpl();
106         style.setNullText(null);
107         assertEquals("", style.getNullText());
108     }
109 
110     @Test
111     void testSetSizeEndText() {
112         final ToStringStyle style = new ToStringStyleImpl();
113         style.setSizeEndText(null);
114         assertEquals("", style.getSizeEndText());
115     }
116 
117     @Test
118     void testSetSizeStartText() {
119         final ToStringStyle style = new ToStringStyleImpl();
120         style.setSizeStartText(null);
121         assertEquals("", style.getSizeStartText());
122     }
123 
124     @Test
125     void testSetSummaryObjectEndText() {
126         final ToStringStyle style = new ToStringStyleImpl();
127         style.setSummaryObjectEndText(null);
128         assertEquals("", style.getSummaryObjectEndText());
129     }
130 
131     @Test
132     void testSetSummaryObjectStartText() {
133         final ToStringStyle style = new ToStringStyleImpl();
134         style.setSummaryObjectStartText(null);
135         assertEquals("", style.getSummaryObjectStartText());
136     }
137 }