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() {
4949 transaction .abort ();
5050 }
5151
52- @ Test ( expected = IllegalArgumentException . class )
52+ @ Test
5353 public void testPutEntityWithInvalidId () {
5454 TestEntity entity = new TestEntity ();
5555 entity .setId (777 );
5656 Transaction transaction = store .beginTx ();
5757 Cursor <TestEntity > cursor = transaction .createCursor (TestEntity .class );
58+
5859 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." );
6064 } finally {
65+ // Always clean up, even if assertions fail, to avoid misleading clean-up errors.
6166 cursor .close ();
6267 transaction .close ();
6368 }
You can’t perform that action at this time.
0 commit comments