1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.lang3.builder;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20 import static org.junit.jupiter.api.Assertions.assertThrows;
21
22 import org.apache.commons.lang3.AbstractLangTest;
23 import org.junit.jupiter.api.Test;
24
25
26
27
28 class DiffTest extends AbstractLangTest {
29
30 private static final class BooleanDiff extends Diff<Boolean> {
31 private static final long serialVersionUID = 1L;
32
33 protected BooleanDiff(final String fieldName) {
34 super(fieldName);
35 }
36
37 @Override
38 public Boolean getLeft() {
39 return Boolean.TRUE;
40 }
41
42 @Override
43 public Boolean getRight() {
44 return Boolean.FALSE;
45 }
46 }
47 private static final String FIELD_NAME = "field";
48
49 private static final Diff<Boolean> booleanDiff = new BooleanDiff(FIELD_NAME);
50
51 @Test
52 void testCannotModify() {
53 assertThrows(UnsupportedOperationException.class, () -> booleanDiff.setValue(Boolean.FALSE));
54 }
55
56 @Test
57 void testGetFieldName() {
58 assertEquals(FIELD_NAME, booleanDiff.getFieldName());
59 }
60
61 @Test
62 void testGetType() {
63 assertEquals(Boolean.class, booleanDiff.getType());
64 }
65
66 @Test
67 void testToString() {
68 assertEquals(String.format("[%s: %s, %s]", FIELD_NAME, booleanDiff.getLeft(),
69 booleanDiff.getRight()), booleanDiff.toString());
70 }
71 }