Debian Codegraph @

src/test/java/ezvcard/issue/Issue134.java

raw symbols SCIP
1 package ezvcard.issue;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNull;
5
6 import java.util.ArrayList;
7 import java.util.List;
8
9 import org.junit.Test;
10
11 import ezvcard.Ezvcard;
12 import ezvcard.VCard;
13 import ezvcard.io.ParseWarning;
14 import ezvcard.property.Birthday;
15 import ezvcard.property.RawProperty;
16
17 /**
18 * @author Michael Angstadt
19 * @see "https://github.com/mangstadt/ez-vcard/issues/134"
20 */
21 public class Issue134 {
22 @Test
23 public void test_2_1() throws Exception {
24 String vcardStr = //@formatter:off
25 "BEGIN:VCARD\r\n" +
26 "VERSION:2.1\r\n" +
27 "BDAY:19879215\r\n" +
28 "END:VCARD\r\n"; //@formatter:on
29
30 List<List<ParseWarning>> warnings = new ArrayList<>();
31
32 VCard vcard = Ezvcard.parse(vcardStr).warnings(warnings).first();
33
34 assertNull(vcard.getBirthday());
35
36 RawProperty bday = vcard.getExtendedProperty("BDAY");
37 assertEquals("19879215", bday.getValue());
38
39 assertEquals(1, warnings.get(0).size());
40 assertEquals(Integer.valueOf(5), warnings.get(0).get(0).getCode());
41 }
42
43 @Test
44 public void test_3_0() throws Exception {
45 String vcardStr = //@formatter:off
46 "BEGIN:VCARD\r\n" +
47 "VERSION:3.0\r\n" +
48 "BDAY:19879215\r\n" +
49 "END:VCARD\r\n"; //@formatter:on
50
51 List<List<ParseWarning>> warnings = new ArrayList<>();
52
53 VCard vcard = Ezvcard.parse(vcardStr).warnings(warnings).first();
54
55 assertNull(vcard.getBirthday());
56
57 RawProperty bday = vcard.getExtendedProperty("BDAY");
58 assertEquals("19879215", bday.getValue());
59
60 assertEquals(1, warnings.get(0).size());
61 assertEquals(Integer.valueOf(5), warnings.get(0).get(0).getCode());
62 }
63
64 @Test
65 public void test_4_0() throws Exception {
66 String vcardStr = //@formatter:off
67 "BEGIN:VCARD\r\n" +
68 "VERSION:4.0\r\n" +
69 "BDAY:19879215\r\n" +
70 "END:VCARD\r\n"; //@formatter:on
71
72 List<List<ParseWarning>> warnings = new ArrayList<>();
73
74 VCard vcard = Ezvcard.parse(vcardStr).warnings(warnings).first();
75
76 Birthday bday = vcard.getBirthday();
77 assertNull(bday.getDate());
78 assertEquals("19879215", bday.getText());
79
80 assertEquals(1, warnings.get(0).size());
81 assertEquals(Integer.valueOf(6), warnings.get(0).get(0).getCode());
82 }
83 }