1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.javanarior.vo.types;
17
18 import static org.testng.Assert.assertEquals;
19 import static org.testng.Assert.assertFalse;
20 import static org.testng.Assert.assertNotNull;
21 import static org.testng.Assert.assertTrue;
22 import static org.testng.Assert.fail;
23
24 import org.joda.time.LocalDate;
25 import org.testng.annotations.Test;
26
27 import de.javanarior.vo.types.helper.JodaLocalDateValue;
28 import de.javanarior.vo.types.helper.OtherJodaLocalDateValue;
29
30 @Test
31 public class JodaLocalDateWrapperTest {
32
33 private static final LocalDate ONE_VALUE = new LocalDate("2014-10-20");
34 private static final JodaLocalDateValue ONE = new JodaLocalDateValue(new LocalDate("2014-10-20"));
35 private static final JodaLocalDateValue TWO = new JodaLocalDateValue(new LocalDate("2014-10-21"));
36 private static final JodaLocalDateValue ANOTHER_ONE = new JodaLocalDateValue(new LocalDate("2014-10-20"));
37 private static final OtherJodaLocalDateValue OTHER_TYPE_ONE = new OtherJodaLocalDateValue(new LocalDate("2014-10-20"));
38
39 public void testJodaDateTimeWrapperNullArgument() {
40 try {
41 new JodaLocalDateValue(null);
42 fail("Null should not be allowed as value.");
43 } catch (IllegalArgumentException exception) {
44 assertNotNull(exception.getMessage());
45 assertFalse(exception.getMessage().isEmpty());
46 }
47 }
48
49 public void testEqualsForDifferentTypes() {
50 assertFalse(ONE.equals(OTHER_TYPE_ONE));
51 assertFalse(OTHER_TYPE_ONE.equals(ONE));
52 }
53
54 public void testAsString() {
55 assertEquals(ONE.asString(), ONE_VALUE.toString());
56 assertEquals(ONE_VALUE.toString(), ONE.asString());
57 }
58
59 public void testCompareTo() {
60 assertEquals(ONE.compareTo(ANOTHER_ONE), 0);
61 assertTrue(ONE.compareTo(TWO) < 0);
62 assertTrue(TWO.compareTo(ONE) > 0);
63 }
64
65 public void testGetValue() {
66 assertEquals(ONE.getValue(), ONE_VALUE);
67 }
68
69 }