| 1 |
package ezvcard.property; |
| 2 |
|
| 3 |
import static ezvcard.property.PropertySensei.assertCopy; |
| 4 |
import static ezvcard.property.PropertySensei.assertEqualsMethod; |
| 5 |
import static ezvcard.property.PropertySensei.assertNothingIsEqual; |
| 6 |
import static ezvcard.property.PropertySensei.assertValidate; |
| 7 |
import static org.junit.Assert.assertEquals; |
| 8 |
import static org.junit.Assert.assertFalse; |
| 9 |
import static org.junit.Assert.assertNull; |
| 10 |
|
| 11 |
import org.junit.Test; |
| 12 |
|
| 13 |
|
| 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 |
public class SimplePropertyTest { |
| 46 |
@Test |
| 47 |
public void constructors() throws Exception { |
| 48 |
SimplePropertyImpl property = new SimplePropertyImpl((String) null); |
| 49 |
assertNull(property.getValue()); |
| 50 |
|
| 51 |
property = new SimplePropertyImpl("value"); |
| 52 |
assertEquals("value", property.getValue()); |
| 53 |
} |
| 54 |
|
| 55 |
@Test |
| 56 |
public void set_value() { |
| 57 |
SimplePropertyImpl property = new SimplePropertyImpl("value"); |
| 58 |
|
| 59 |
property.setValue("value2"); |
| 60 |
assertEquals("value2", property.getValue()); |
| 61 |
} |
| 62 |
|
| 63 |
@Test |
| 64 |
public void validate() { |
| 65 |
SimplePropertyImpl empty = new SimplePropertyImpl((String) null); |
| 66 |
assertValidate(empty).run(8); |
| 67 |
|
| 68 |
SimplePropertyImpl withValue = new SimplePropertyImpl("text"); |
| 69 |
assertValidate(withValue).run(); |
| 70 |
} |
| 71 |
|
| 72 |
@Test |
| 73 |
public void toStringValues() { |
| 74 |
SimplePropertyImpl property = new SimplePropertyImpl("value"); |
| 75 |
assertFalse(property.toStringValues().isEmpty()); |
| 76 |
} |
| 77 |
|
| 78 |
@Test |
| 79 |
public void copy() { |
| 80 |
SimplePropertyImpl original = new SimplePropertyImpl((String) null); |
| 81 |
assertCopy(original); |
| 82 |
|
| 83 |
original = new SimplePropertyImpl("value"); |
| 84 |
assertCopy(original); |
| 85 |
} |
| 86 |
|
| 87 |
@Test |
| 88 |
public void equals() { |
| 89 |
|
| 90 |
assertNothingIsEqual( |
| 91 |
new SimplePropertyImpl((String) null), |
| 92 |
new SimplePropertyImpl("value"), |
| 93 |
new SimplePropertyImpl("value2") |
| 94 |
); |
| 95 |
|
| 96 |
assertEqualsMethod(SimplePropertyImpl.class, "value") |
| 97 |
.constructor(new Class<?>[]{String.class}, (String)null).test() |
| 98 |
.constructor("value").test(); |
| 99 |
|
| 100 |
} |
| 101 |
|
| 102 |
public static class SimplePropertyImpl extends SimpleProperty<String> { |
| 103 |
public SimplePropertyImpl(String value) { |
| 104 |
super(value); |
| 105 |
} |
| 106 |
|
| 107 |
public SimplePropertyImpl(SimplePropertyImpl original) { |
| 108 |
super(original); |
| 109 |
} |
| 110 |
} |
| 111 |
} |