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.LocalTime;
25 import org.testng.annotations.Test;
26
27 import de.javanarior.vo.types.helper.JodaLocalTimeValue;
28 import de.javanarior.vo.types.helper.OtherJodaLocalTimeValue;
29
30 @Test
31 public class JodaLocalTimeWrapperTest {
32
33 private static final LocalTime ONE_VALUE = new LocalTime("12:13:14");
34 private static final JodaLocalTimeValue ONE = new JodaLocalTimeValue(new LocalTime("12:13:14"));
35 private static final JodaLocalTimeValue TWO = new JodaLocalTimeValue(new LocalTime("14:13:12"));
36 private static final JodaLocalTimeValue ANOTHER_ONE = new JodaLocalTimeValue(new LocalTime("12:13:14"));
37 private static final OtherJodaLocalTimeValue OTHER_TYPE_ONE = new OtherJodaLocalTimeValue(new LocalTime("12:13:14"));
38
39 public void testJodaDateTimeWrapperNullArgument() {
40 try {
41 new JodaLocalTimeValue(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 }