Debian Codegraph @

src/test/java/ezvcard/property/SimplePropertyTest.java

raw symbols SCIP
1 package ezvcard.property;
2
3 import static ezvcard.property.PropertySensei.assertCopy;
4 import static ezvcard.property.PropertySensei.assertEqualsMethod;
5 import static ezvcard.property.PropertySensei.assertNothingIsEqual;
6 import static ezvcard.property.PropertySensei.assertValidate;
7 import static org.junit.Assert.assertEquals;
8 import static org.junit.Assert.assertFalse;
9 import static org.junit.Assert.assertNull;
10
11 import org.junit.Test;
12
13 /*
14 Copyright (c) 2012-2023, Michael Angstadt
15 All rights reserved.
16
17 Redistribution and use in source and binary forms, with or without
18 modification, are permitted provided that the following conditions are met:
19
20 1. Redistributions of source code must retain the above copyright notice, this
21 list of conditions and the following disclaimer.
22 2. Redistributions in binary form must reproduce the above copyright notice,
23 this list of conditions and the following disclaimer in the documentation
24 and/or other materials provided with the distribution.
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
30 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
37 The views and conclusions contained in the software and documentation are those
38 of the authors and should not be interpreted as representing official policies,
39 either expressed or implied, of the FreeBSD Project.
40 */
41
42 /**
43 * @author Michael Angstadt
44 */
45 public class SimplePropertyTest {
46 @Test
47 public void constructors() throws Exception {
48 SimplePropertyImpl property = new SimplePropertyImpl((String) null);
49 assertNull(property.getValue());
50
51 property = new SimplePropertyImpl("value");
52 assertEquals("value", property.getValue());
53 }
54
55 @Test
56 public void set_value() {
57 SimplePropertyImpl property = new SimplePropertyImpl("value");
58
59 property.setValue("value2");
60 assertEquals("value2", property.getValue());
61 }
62
63 @Test
64 public void validate() {
65 SimplePropertyImpl empty = new SimplePropertyImpl((String) null);
66 assertValidate(empty).run(8);
67
68 SimplePropertyImpl withValue = new SimplePropertyImpl("text");
69 assertValidate(withValue).run();
70 }
71
72 @Test
73 public void toStringValues() {
74 SimplePropertyImpl property = new SimplePropertyImpl("value");
75 assertFalse(property.toStringValues().isEmpty());
76 }
77
78 @Test
79 public void copy() {
80 SimplePropertyImpl original = new SimplePropertyImpl((String) null);
81 assertCopy(original);
82
83 original = new SimplePropertyImpl("value");
84 assertCopy(original);
85 }
86
87 @Test
88 public void equals() {
89 //@formatter:off
90 assertNothingIsEqual(
91 new SimplePropertyImpl((String) null),
92 new SimplePropertyImpl("value"),
93 new SimplePropertyImpl("value2")
94 );
95
96 assertEqualsMethod(SimplePropertyImpl.class, "value")
97 .constructor(new Class<?>[]{String.class}, (String)null).test()
98 .constructor("value").test();
99 //@formatter:on
100 }
101
102 public static class SimplePropertyImpl extends SimpleProperty<String> {
103 public SimplePropertyImpl(String value) {
104 super(value);
105 }
106
107 public SimplePropertyImpl(SimplePropertyImpl original) {
108 super(original);
109 }
110 }
111 }