Debian Codegraph @

src/test/java/ezvcard/parameter/VCardParameterCaseClassesTest.java

raw symbols SCIP
1 package ezvcard.parameter;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNull;
5 import static org.junit.Assert.assertSame;
6
7 import org.junit.Before;
8 import org.junit.Test;
9
10 /*
11 Copyright (c) 2012-2023, Michael Angstadt
12 All rights reserved.
13
14 Redistribution and use in source and binary forms, with or without
15 modification, are permitted provided that the following conditions are met:
16
17 1. Redistributions of source code must retain the above copyright notice, this
18 list of conditions and the following disclaimer.
19 2. Redistributions in binary form must reproduce the above copyright notice,
20 this list of conditions and the following disclaimer in the documentation
21 and/or other materials provided with the distribution.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
27 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 /**
36 * @author Michael Angstadt
37 */
38 public class VCardParameterCaseClassesTest {
39 private VCardParameterCaseClasses<Pet> caseClasses;
40
41 @Before
42 public void before() {
43 caseClasses = new VCardParameterCaseClasses<>(Pet.class);
44 }
45
46 @Test
47 public void get() {
48 assertSame(Pet.CAT, caseClasses.get("cAt"));
49
50 Pet gerbil = caseClasses.get("gerbil");
51 Pet gerbil2 = caseClasses.get("gERbil");
52 assertEquals("gerbil", gerbil2.getValue());
53 assertSame(gerbil, gerbil2);
54 }
55
56 @Test
57 public void find() {
58 assertSame(Pet.CAT, caseClasses.find("cAt"));
59 assertNull(caseClasses.find("gerbil"));
60 }
61
62 public static class Pet extends VCardParameter {
63 public static final Pet CAT = new Pet("cat");
64 public static final Pet DOG = new Pet("dog");
65 public static final Pet FISH = new Pet("fish");
66
67 private Pet(String value) {
68 super(value);
69 }
70 }
71 }