Skip to content

Commit 6bd0cd0

Browse files
committed
test: create null id scenario
Signed-off-by: Otavio Santana <[email protected]>
1 parent 7c975df commit 6bd0cd0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/communication/MongoDBDocumentManagerTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ void shouldInsert() {
7979
assertTrue(documentEntity.elements().stream().map(Element::name).anyMatch(s -> s.equals("_id")));
8080
}
8181

82+
@Test
83+
void shouldInsertAndIgnoreIdNull() {
84+
var entity = getEntity();
85+
entity.add("_id", null);
86+
var documentEntity = entityManager.insert(entity);
87+
Element id = documentEntity.find("_id").orElseThrow();
88+
entityManager.delete(DeleteQuery.delete().from(COLLECTION_NAME).where("_id").eq(id.get()).build());
89+
}
90+
8291
@Test
8392
void shouldThrowExceptionWhenInsertWithTTL() {
8493
var entity = getEntity();

0 commit comments

Comments
 (0)