Debian Codegraph @

src/test/java/ezvcard/property/ListPropertyTest.java

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