Skip to content

Commit dfb012b

Browse files
committed
test: create CRUD operation to integration test
Signed-off-by: Otavio Santana <[email protected]>
1 parent b222635 commit dfb012b

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/integration/TemplateIntegrationTest.java

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,17 @@
1515
package org.eclipse.jnosql.databases.mongodb.integration;
1616

1717

18-
import jakarta.annotation.Priority;
19-
import jakarta.enterprise.context.ApplicationScoped;
20-
import jakarta.enterprise.inject.Alternative;
21-
import jakarta.enterprise.inject.Produces;
2218
import jakarta.inject.Inject;
23-
import jakarta.nosql.Template;
2419
import jakarta.nosql.document.DocumentTemplate;
25-
import org.eclipse.jnosql.communication.document.DocumentManager;
26-
import org.eclipse.jnosql.databases.mongodb.communication.DocumentDatabase;
2720
import org.eclipse.jnosql.databases.mongodb.communication.MongoDBDocumentConfigurations;
28-
import org.eclipse.jnosql.databases.mongodb.communication.MongoDBDocumentManager;
2921
import org.eclipse.jnosql.mapping.Convert;
3022
import org.eclipse.jnosql.mapping.config.MappingConfigurations;
3123
import org.eclipse.jnosql.mapping.document.DocumentEntityConverter;
3224
import org.eclipse.jnosql.mapping.document.spi.DocumentExtension;
3325
import org.eclipse.jnosql.mapping.reflection.EntityMetadataExtension;
34-
import org.jboss.weld.junit5.auto.AddBeanClasses;
3526
import org.jboss.weld.junit5.auto.AddExtensions;
3627
import org.jboss.weld.junit5.auto.AddPackages;
3728
import org.jboss.weld.junit5.auto.EnableAutoWeld;
38-
import org.jboss.weld.junit5.auto.ExcludeBean;
39-
import org.jboss.weld.junit5.auto.ExcludeBeanClasses;
4029
import org.junit.jupiter.api.Test;
4130
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
4231

@@ -57,7 +46,7 @@
5746
class TemplateIntegrationTest {
5847

5948
@Inject
60-
private Template template;
49+
private DocumentTemplate template;
6150

6251
static {
6352
INSTANCE.get("library");
@@ -76,12 +65,43 @@ public void shouldInsert() {
7665

7766
@Test
7867
public void shouldUpdate() {
68+
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
69+
assertThat(template.insert(book))
70+
.isNotNull()
71+
.isEqualTo(book);
72+
73+
Book updated = new Book(book.id(), book.title() + " updated", 2);
74+
75+
assertThat(template.update(updated))
76+
.isNotNull()
77+
.isNotEqualTo(book);
78+
79+
assertThat(template.find(Book.class, book.id()))
80+
.isNotNull().get().isEqualTo(updated);
7981

8082
}
8183

8284
@Test
8385
public void shouldFindById() {
86+
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
87+
assertThat(template.insert(book))
88+
.isNotNull()
89+
.isEqualTo(book);
90+
91+
assertThat(template.find(Book.class, book.id()))
92+
.isNotNull().get().isEqualTo(book);
93+
}
94+
95+
@Test
96+
public void shouldDelete() {
97+
Book book = new Book(randomUUID().toString(), "Effective Java", 1);
98+
assertThat(template.insert(book))
99+
.isNotNull()
100+
.isEqualTo(book);
84101

102+
template.delete(Book.class, book.id());
103+
assertThat(template.find(Book.class, book.id()))
104+
.isNotNull().isEmpty();
85105
}
86106

87107

0 commit comments

Comments
 (0)