| 1 |
package ezvcard.parameter; |
| 2 |
|
| 3 |
import static org.junit.Assert.assertArrayEquals; |
| 4 |
import static org.junit.Assert.assertEquals; |
| 5 |
import static org.junit.Assert.assertFalse; |
| 6 |
import static org.junit.Assert.assertNull; |
| 7 |
import static org.junit.Assert.assertTrue; |
| 8 |
import nl.jqno.equalsverifier.EqualsVerifier; |
| 9 |
|
| 10 |
import org.junit.Test; |
| 11 |
|
| 12 |
import ezvcard.SupportedVersions; |
| 13 |
import ezvcard.VCardVersion; |
| 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 |
public class VCardParameterTest { |
| 44 |
@Test |
| 45 |
public void getSupportedVersions() { |
| 46 |
assertArrayEquals(new VCardVersion[] { VCardVersion.V2_1 }, VCardParameterImpl.ONE.getSupportedVersions()); |
| 47 |
assertArrayEquals(VCardVersion.values(), VCardParameterImpl.TWO.getSupportedVersions()); |
| 48 |
assertArrayEquals(VCardVersion.values(), new VCardParameterImpl("three").getSupportedVersions()); |
| 49 |
} |
| 50 |
|
| 51 |
@Test |
| 52 |
public void isSupportedBy() { |
| 53 |
assertTrue(VCardParameterImpl.ONE.isSupportedBy(VCardVersion.V2_1)); |
| 54 |
assertFalse(VCardParameterImpl.ONE.isSupportedBy(VCardVersion.V3_0)); |
| 55 |
assertFalse(VCardParameterImpl.ONE.isSupportedBy(VCardVersion.V4_0)); |
| 56 |
|
| 57 |
for (VCardVersion version : VCardVersion.values()) { |
| 58 |
assertTrue(VCardParameterImpl.TWO.isSupportedBy(version)); |
| 59 |
} |
| 60 |
|
| 61 |
VCardParameterImpl three = new VCardParameterImpl("three"); |
| 62 |
for (VCardVersion version : VCardVersion.values()) { |
| 63 |
assertTrue(three.isSupportedBy(version)); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
@Test |
| 68 |
public void value_to_lowercase() { |
| 69 |
VCardParameterImpl three = new VCardParameterImpl("THREE"); |
| 70 |
assertEquals("three", three.getValue()); |
| 71 |
} |
| 72 |
|
| 73 |
@Test |
| 74 |
public void value_null() { |
| 75 |
VCardParameterImpl parameter = new VCardParameterImpl(null); |
| 76 |
assertNull(parameter.getValue()); |
| 77 |
} |
| 78 |
|
| 79 |
@Test |
| 80 |
public void equals_contract() { |
| 81 |
EqualsVerifier.forClass(VCardParameter.class).usingGetClass().verify(); |
| 82 |
} |
| 83 |
|
| 84 |
private static class VCardParameterImpl extends VCardParameter { |
| 85 |
@SupportedVersions(VCardVersion.V2_1) |
| 86 |
public static VCardParameterImpl ONE = new VCardParameterImpl("one"); |
| 87 |
|
| 88 |
@SuppressWarnings("unused") |
| 89 |
public String instanceField = "value"; |
| 90 |
|
| 91 |
public static VCardParameterImpl TWO = new VCardParameterImpl("two"); |
| 92 |
|
| 93 |
public VCardParameterImpl() { |
| 94 |
super("value"); |
| 95 |
} |
| 96 |
|
| 97 |
public VCardParameterImpl(String value) { |
| 98 |
super(value); |
| 99 |
} |
| 100 |
} |
| 101 |
} |