File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
tests/objectbox-java-test/src/test/java/io/objectbox Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -49,15 +49,20 @@ public void testPutAndGetEntity() {
49
49
transaction .abort ();
50
50
}
51
51
52
- @ Test ( expected = IllegalArgumentException . class )
52
+ @ Test
53
53
public void testPutEntityWithInvalidId () {
54
54
TestEntity entity = new TestEntity ();
55
55
entity .setId (777 );
56
56
Transaction transaction = store .beginTx ();
57
57
Cursor <TestEntity > cursor = transaction .createCursor (TestEntity .class );
58
+
58
59
try {
59
- cursor .put (entity );
60
+ IllegalArgumentException ex = assertThrows (IllegalArgumentException .class ,
61
+ () -> cursor .put (entity ));
62
+ assertEquals (ex .getMessage (), "ID is higher or equal to internal ID sequence: 777 (vs. 1)." +
63
+ " Use ID 0 (zero) to insert new entities." );
60
64
} finally {
65
+ // Always clean up, even if assertions fail, to avoid misleading clean-up errors.
61
66
cursor .close ();
62
67
transaction .close ();
63
68
}
You can’t perform that action at this time.
0 commit comments