-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. The fix is wrong, no need to allow global policy changes to affect…
… records exists action 2. Refactor and cleanup (use generics instead of Objects) 3. Add insert() method for both reactive and none-reactive flows and add integration tests
- Loading branch information
1 parent
4533700
commit fa903f9
Showing
8 changed files
with
227 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
src/test/java/com/aerospike/mapper/InsertOnlyModeTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.aerospike.mapper; | ||
|
||
import com.aerospike.client.AerospikeException; | ||
import com.aerospike.client.Key; | ||
import com.aerospike.client.Record; | ||
import com.aerospike.client.policy.WritePolicy; | ||
import com.aerospike.mapper.annotations.AerospikeKey; | ||
import com.aerospike.mapper.annotations.AerospikeRecord; | ||
import com.aerospike.mapper.tools.AeroMapper; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class InsertOnlyTest extends AeroMapperBaseTest { | ||
|
||
@AerospikeRecord(namespace = "test", set = "testSet") | ||
public static class DataClass { | ||
@AerospikeKey | ||
int a; | ||
int b; | ||
int c; | ||
int d; | ||
int e; | ||
} | ||
|
||
@BeforeEach | ||
public void setup() { | ||
client.delete(null, new Key("test", "testSet", 1)); | ||
} | ||
|
||
@Test | ||
public void testInsertOnly() { | ||
WritePolicy writePolicy = new WritePolicy(client.getWritePolicyDefault()); | ||
writePolicy.totalTimeout = 2000; | ||
writePolicy.socketTimeout = 100; | ||
AeroMapper mapper = new AeroMapper.Builder(client) | ||
.withWritePolicy(writePolicy).forClasses(DataClass.class) | ||
.build(); | ||
|
||
DataClass dataClass = new DataClass(); | ||
dataClass.a = 1; | ||
dataClass.b = 2; | ||
dataClass.c = 3; | ||
dataClass.d = 4; | ||
dataClass.e = 5; | ||
|
||
// Insert | ||
mapper.insert(dataClass); | ||
|
||
Key key = new Key("test", "testSet", 1); | ||
Record record = client.get(null, key); | ||
assertEquals(5, record.bins.size()); | ||
assertEquals(3, record.getInt("c")); | ||
|
||
// Try to insert again and get an exception | ||
dataClass.c = 9; | ||
dataClass.e = 11; | ||
assertThrows(AerospikeException.class, () -> mapper.insert(dataClass, "a", "c", "e")); | ||
} | ||
} |
Oops, something went wrong.