1
1
package com .aerospike .mapper ;
2
2
3
- import static org .junit .jupiter .api .Assertions .assertEquals ;
4
-
5
- import org .junit .jupiter .api .Test ;
6
-
7
3
import com .aerospike .mapper .annotations .AerospikeEnum ;
8
4
import com .aerospike .mapper .annotations .AerospikeKey ;
9
5
import com .aerospike .mapper .annotations .AerospikeRecord ;
10
6
import com .aerospike .mapper .tools .AeroMapper ;
7
+ import org .junit .jupiter .api .Test ;
8
+
9
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
11
10
12
11
public class AeroMapperEnumTest extends AeroMapperBaseTest {
13
12
13
+ @ Test
14
+ public void runTest () {
15
+ A a1 = new A (1 , "a" , 10 , Status .MARRIED , Country .ARGENTINA , Country .ARGENTINA );
16
+ A a2 = new A (2 , "b" , 20 , Status .SINGLE , Country .DENMARK , Country .DENMARK );
17
+ A a3 = new A (3 , "c" , 30 , Status .COMPLICATED , Country .UNITED_STATES , Country .UNITED_STATES );
18
+ A a4 = new A (4 , "d" , 40 , null , null , null );
19
+
20
+ AeroMapper mapper = new AeroMapper .Builder (client ).build ();
21
+ mapper .save (a1 );
22
+ mapper .save (a2 );
23
+ mapper .save (a3 );
24
+ mapper .save (a4 );
25
+
26
+ A a11 = mapper .read (A .class , 1 );
27
+ A a12 = mapper .read (A .class , 2 );
28
+ A a13 = mapper .read (A .class , 3 );
29
+ A a14 = mapper .read (A .class , 4 );
30
+
31
+ assertEquals (a1 .id , a11 .id );
32
+ assertEquals (a1 .status , a11 .status );
33
+ assertEquals (a1 .country , a11 .country );
34
+
35
+ assertEquals (a2 .name , a12 .name );
36
+ assertEquals (a2 .country , a12 .country );
37
+ assertEquals (a2 .countryAnno , a12 .countryAnno );
38
+
39
+ assertEquals (a3 .age , a13 .age );
40
+ assertEquals (a3 .country , a13 .country );
41
+ assertEquals (a3 .countryAnno , a13 .countryAnno );
42
+
43
+ assertEquals (a4 .age , a14 .age );
44
+ assertEquals (a4 .country , a14 .country );
45
+ assertEquals (a4 .countryAnno , a14 .countryAnno );
46
+ }
47
+
14
48
enum Status {
15
49
MARRIED ,
16
50
SINGLE ,
@@ -41,10 +75,9 @@ public static class A {
41
75
public String name ;
42
76
public int age ;
43
77
public Status status ;
44
- public Country country ;
45
78
@ AerospikeEnum (enumField = "countryCode" )
46
79
public Country countryAnno ;
47
-
80
+ private Country country ;
48
81
49
82
public A () {
50
83
}
@@ -59,29 +92,4 @@ public A(int id, String name, int age, Status status, Country country, Country c
59
92
this .countryAnno = countryAnno ;
60
93
}
61
94
}
62
-
63
- @ Test
64
- public void runTest () {
65
- A a1 = new A (1 , "a" , 10 , Status .MARRIED , Country .ARGENTINA , Country .ARGENTINA );
66
- A a2 = new A (2 , "b" , 20 , Status .SINGLE , Country .DENMARK , Country .DENMARK );
67
- A a3 = new A (3 , "c" , 30 , Status .COMPLICATED , Country .UNITED_STATES , Country .UNITED_STATES );
68
-
69
- AeroMapper mapper = new AeroMapper .Builder (client ).build ();
70
- mapper .save (a1 );
71
- mapper .save (a2 );
72
- mapper .save (a3 );
73
-
74
- A a11 = mapper .read (A .class , 1 );
75
- A a12 = mapper .read (A .class , 2 );
76
- A a13 = mapper .read (A .class , 3 );
77
-
78
- assertEquals (a1 .id , a11 .id );
79
- assertEquals (a1 .status , a11 .status );
80
- assertEquals (a1 .country , a11 .country );
81
- assertEquals (a2 .name , a12 .name );
82
- assertEquals (a2 .country , a12 .country );
83
- assertEquals (a2 .countryAnno , a12 .countryAnno );
84
- assertEquals (a3 .age , a13 .age );
85
- assertEquals (a3 .countryAnno , a13 .countryAnno );
86
- }
87
95
}
0 commit comments