1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.christianschenk.beanmapping;
20
21 import org.christianschenk.beanmapping.beans.A;
22 import org.christianschenk.beanmapping.beans.B;
23 import org.junit.Test;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNull;
27
28 public abstract class AbstractJavaBeanTest {
29
30 protected abstract void copy(A a1, A a2);
31
32 protected abstract void fillBiggerWithSmallerBean(B b, A a);
33
34 protected abstract void fillSmallerWithBiggerBean(A a, B b);
35
36 @Test
37 public void copy() {
38 final A a1 = new A(1, 2);
39 final A a2 = new A();
40 this.copy(a2, a1);
41 assertEquals(a1.getI(), a2.getI());
42 assertEquals(a1.getJ(), a2.getJ());
43 }
44
45 @Test
46 public void fillBiggerWithSmallerBean() {
47 final A a = new A(1, 2);
48 final B b = new B();
49 this.fillBiggerWithSmallerBean(b, a);
50 assertEquals(a.getI(), b.getI());
51 assertEquals(a.getJ(), b.getJ());
52 assertNull(b.getStr());
53 }
54
55 @Test
56 public void fillSmallerWithBiggerBean() {
57 final A a = new A();
58 final B b = new B(1, 2);
59 this.fillSmallerWithBiggerBean(a, b);
60 assertEquals(a.getI(), b.getI());
61 assertEquals(a.getJ(), b.getJ());
62 assertNull(b.getStr());
63 }
64 }