| 1 |
package ezvcard.property; |
| 2 |
|
| 3 |
import static ezvcard.VCardVersion.V2_1; |
| 4 |
import static ezvcard.VCardVersion.V3_0; |
| 5 |
import static ezvcard.VCardVersion.V4_0; |
| 6 |
import static ezvcard.property.PropertySensei.assertCopy; |
| 7 |
import static ezvcard.property.PropertySensei.assertValidate; |
| 8 |
|
| 9 |
import java.util.ArrayList; |
| 10 |
import java.util.Arrays; |
| 11 |
import java.util.List; |
| 12 |
|
| 13 |
import org.junit.Test; |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public class StructuredNameTest { |
| 48 |
@Test |
| 49 |
public void validate() { |
| 50 |
|
| 51 |
assertValidate(new StructuredName()).versions().run(); |
| 52 |
|
| 53 |
|
| 54 |
List<StructuredName> properties = new ArrayList<>(); |
| 55 |
{ |
| 56 |
StructuredName property = new StructuredName(); |
| 57 |
property.getAdditionalNames().add("one"); |
| 58 |
properties.add(property); |
| 59 |
|
| 60 |
property = new StructuredName(); |
| 61 |
property.getPrefixes().add("one"); |
| 62 |
properties.add(property); |
| 63 |
|
| 64 |
property = new StructuredName(); |
| 65 |
property.getSuffixes().add("one"); |
| 66 |
properties.add(property); |
| 67 |
} |
| 68 |
for (StructuredName property : properties) { |
| 69 |
assertValidate(property).run(); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
properties = new ArrayList<>(); |
| 74 |
{ |
| 75 |
StructuredName property = new StructuredName(); |
| 76 |
property.getAdditionalNames().addAll(Arrays.asList("one", "two")); |
| 77 |
properties.add(property); |
| 78 |
|
| 79 |
property = new StructuredName(); |
| 80 |
property.getPrefixes().addAll(Arrays.asList("one", "two")); |
| 81 |
properties.add(property); |
| 82 |
|
| 83 |
property = new StructuredName(); |
| 84 |
property.getSuffixes().addAll(Arrays.asList("one", "two")); |
| 85 |
properties.add(property); |
| 86 |
} |
| 87 |
for (StructuredName property : properties) { |
| 88 |
assertValidate(property).versions(V2_1).run(34); |
| 89 |
assertValidate(property).versions(V3_0, V4_0).run(); |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
@Test |
| 94 |
public void copy() { |
| 95 |
StructuredName original = new StructuredName(); |
| 96 |
original.getAdditionalNames().add("one"); |
| 97 |
original.getPrefixes().add("two"); |
| 98 |
original.getSuffixes().add("three"); |
| 99 |
|
| 100 |
|
| 101 |
assertCopy(original) |
| 102 |
.notSame("getAdditionalNames") |
| 103 |
.notSame("getPrefixes") |
| 104 |
.notSame("getSuffixes"); |
| 105 |
|
| 106 |
} |
| 107 |
} |