From 8da41699cda080cda038ab724abc282bc89c2862 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Sun, 15 Dec 2024 16:21:40 +0000 Subject: [PATCH] feat: update mongodb template integration Signed-off-by: Otavio Santana --- .../MongoDBTemplateIntegrationTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/integration/MongoDBTemplateIntegrationTest.java b/jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/integration/MongoDBTemplateIntegrationTest.java index 9bc1def9f..1f12c983b 100644 --- a/jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/integration/MongoDBTemplateIntegrationTest.java +++ b/jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/integration/MongoDBTemplateIntegrationTest.java @@ -138,6 +138,34 @@ void shouldUpdateNullValues(){ }); } + @Test + void shouldCreateMongoDBBook() { + var id = randomUUID(); + var title = "Persistence with MongoDB"; + var author = "Otavio Santana"; + var book = template.insert(new MongoDBBook(id, title, author)); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(book).isNotNull(); + softly.assertThat(book.id()).isEqualTo(id); + softly.assertThat(book.title()).isEqualTo(title); + softly.assertThat(book.author()).isEqualTo(author); + }); + } + + @Test + void shouldFindByUUID() { + var id = randomUUID(); + var title = "Persistence with MongoDB"; + var author = "Otavio Santana"; + var book = template.insert(new MongoDBBook(id, title, author)); + + var optional = template.find(MongoDBBook.class, id); + assertThat(optional).isPresent(); + assertThat(optional.get().id()).isEqualTo(id); + assertThat(optional.get().title()).isEqualTo(title); + assertThat(optional.get().author()).isEqualTo(author); + } }