1
1
package com .aerospike .mapper ;
2
2
3
+ import com .aerospike .client .Key ;
4
+ import com .aerospike .client .Record ;
3
5
import com .aerospike .client .policy .WritePolicy ;
4
6
import com .aerospike .mapper .annotations .AerospikeKey ;
5
7
import com .aerospike .mapper .annotations .AerospikeRecord ;
6
8
import com .aerospike .mapper .tools .AeroMapper ;
7
9
import org .junit .jupiter .api .Test ;
8
10
11
+ import static com .aerospike .client .Value .UseBoolBin ;
9
12
import static org .junit .jupiter .api .Assertions .*;
10
13
11
14
public class DefaultFieldValuesTest extends AeroMapperBaseTest {
@@ -38,7 +41,7 @@ public void testDefaultValues() {
38
41
writePolicy .totalTimeout = 2000 ;
39
42
writePolicy .socketTimeout = 100 ;
40
43
AeroMapper mapper = new AeroMapper .Builder (client )
41
- .withWritePolicy (writePolicy ).forClasses (PartialRecordsTest . DataClass .class )
44
+ .withWritePolicy (writePolicy ).forClasses (DefaultFieldsClass .class )
42
45
.build ();
43
46
44
47
DefaultFieldsClass obj = new DefaultFieldsClass ();
@@ -63,4 +66,30 @@ public void testDefaultValues() {
63
66
assertNull (dfc .bool );
64
67
assertFalse (dfc .bool2 );
65
68
}
69
+
70
+ @ Test
71
+ public void testBooleanValue () {
72
+ AeroMapper mapper = new AeroMapper .Builder (client ).build ();
73
+
74
+ DefaultFieldsClass obj = new DefaultFieldsClass ();
75
+ obj .key = "dfc" ;
76
+ mapper .save (obj );
77
+
78
+ Key key = new Key ("test" , "testSet" , "dfc" );
79
+
80
+ Record record = client .get (null , key );
81
+ assertTrue (record .bins .get ("bool2" ) instanceof Long );
82
+ assertEquals (0 , record .getLong ("bool2" ));
83
+ DefaultFieldsClass dfc = mapper .read (DefaultFieldsClass .class , "dfc" );
84
+ assertFalse (dfc .bool2 );
85
+
86
+ UseBoolBin = true ;
87
+ mapper .save (obj );
88
+ record = client .get (null , key );
89
+ assertTrue (record .bins .get ("bool2" ) instanceof Boolean );
90
+ assertFalse (record .getBoolean ("bool2" ));
91
+ dfc = mapper .read (DefaultFieldsClass .class , "dfc" );
92
+ assertFalse (dfc .bool2 );
93
+ UseBoolBin = false ;
94
+ }
66
95
}
0 commit comments