|
15 | 15 | package org.eclipse.jnosql.databases.mongodb.integration; |
16 | 16 |
|
17 | 17 |
|
18 | | -import org.eclipse.jnosql.databases.mongodb.mapping.Music; |
| 18 | +import jakarta.annotation.Priority; |
| 19 | +import jakarta.enterprise.context.ApplicationScoped; |
| 20 | +import jakarta.enterprise.inject.Alternative; |
| 21 | +import jakarta.enterprise.inject.Produces; |
| 22 | +import jakarta.inject.Inject; |
| 23 | +import jakarta.nosql.Template; |
| 24 | +import jakarta.nosql.document.DocumentTemplate; |
| 25 | +import org.eclipse.jnosql.communication.document.DocumentManager; |
| 26 | +import org.eclipse.jnosql.databases.mongodb.communication.DocumentDatabase; |
| 27 | +import org.eclipse.jnosql.databases.mongodb.communication.MongoDBDocumentConfigurations; |
| 28 | +import org.eclipse.jnosql.databases.mongodb.communication.MongoDBDocumentManager; |
19 | 29 | import org.eclipse.jnosql.mapping.Convert; |
| 30 | +import org.eclipse.jnosql.mapping.config.MappingConfigurations; |
20 | 31 | import org.eclipse.jnosql.mapping.document.DocumentEntityConverter; |
21 | 32 | import org.eclipse.jnosql.mapping.document.spi.DocumentExtension; |
22 | 33 | import org.eclipse.jnosql.mapping.reflection.EntityMetadataExtension; |
| 34 | +import org.jboss.weld.junit5.auto.AddBeanClasses; |
23 | 35 | import org.jboss.weld.junit5.auto.AddExtensions; |
24 | 36 | import org.jboss.weld.junit5.auto.AddPackages; |
25 | 37 | import org.jboss.weld.junit5.auto.EnableAutoWeld; |
| 38 | +import org.jboss.weld.junit5.auto.ExcludeBean; |
| 39 | +import org.jboss.weld.junit5.auto.ExcludeBeanClasses; |
| 40 | +import org.junit.jupiter.api.Test; |
26 | 41 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; |
27 | 42 |
|
| 43 | +import java.util.Optional; |
| 44 | + |
| 45 | +import static java.util.UUID.randomUUID; |
| 46 | +import static org.assertj.core.api.Assertions.assertThat; |
28 | 47 | import static org.eclipse.jnosql.communication.driver.IntegrationTest.MATCHES; |
29 | 48 | import static org.eclipse.jnosql.communication.driver.IntegrationTest.NAMED; |
| 49 | +import static org.eclipse.jnosql.databases.mongodb.communication.DocumentDatabase.INSTANCE; |
30 | 50 |
|
31 | 51 | @EnableAutoWeld |
32 | 52 | @AddPackages(value = {Convert.class, DocumentEntityConverter.class}) |
33 | | -@AddPackages(Music.class) |
| 53 | +@AddPackages(Book.class) |
34 | 54 | @AddExtensions({EntityMetadataExtension.class, |
35 | 55 | DocumentExtension.class}) |
36 | 56 | @EnabledIfSystemProperty(named = NAMED, matches = MATCHES) |
37 | | -class MongoDBTemplateIntegrationTest { |
| 57 | +class TemplateIntegrationTest { |
| 58 | + |
| 59 | + @Inject |
| 60 | + private Template template; |
| 61 | + |
| 62 | + static { |
| 63 | + INSTANCE.get("library"); |
| 64 | + System.setProperty(MongoDBDocumentConfigurations.HOST.get() + ".1", INSTANCE.host()); |
| 65 | + System.setProperty(MappingConfigurations.DOCUMENT_DATABASE.get(), "library"); |
| 66 | + } |
| 67 | + |
| 68 | + @Test |
| 69 | + public void shouldInsert() { |
| 70 | + Book book = new Book(randomUUID().toString(), "Effective Java", 1); |
| 71 | + template.insert(book); |
| 72 | + Optional<Book> optional = template.find(Book.class, book.id()); |
| 73 | + assertThat(optional).isNotNull().isNotEmpty() |
| 74 | + .get().isEqualTo(book); |
| 75 | + } |
| 76 | + |
| 77 | + @Test |
| 78 | + public void shouldUpdate() { |
| 79 | + |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + public void shouldFindById() { |
| 84 | + |
| 85 | + } |
| 86 | + |
| 87 | + |
38 | 88 | } |
0 commit comments