1515package 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 ;
2218import jakarta .inject .Inject ;
23- import jakarta .nosql .Template ;
2419import jakarta .nosql .document .DocumentTemplate ;
25- import org .eclipse .jnosql .communication .document .DocumentManager ;
26- import org .eclipse .jnosql .databases .mongodb .communication .DocumentDatabase ;
2720import org .eclipse .jnosql .databases .mongodb .communication .MongoDBDocumentConfigurations ;
28- import org .eclipse .jnosql .databases .mongodb .communication .MongoDBDocumentManager ;
2921import org .eclipse .jnosql .mapping .Convert ;
3022import org .eclipse .jnosql .mapping .config .MappingConfigurations ;
3123import org .eclipse .jnosql .mapping .document .DocumentEntityConverter ;
3224import org .eclipse .jnosql .mapping .document .spi .DocumentExtension ;
3325import org .eclipse .jnosql .mapping .reflection .EntityMetadataExtension ;
34- import org .jboss .weld .junit5 .auto .AddBeanClasses ;
3526import org .jboss .weld .junit5 .auto .AddExtensions ;
3627import org .jboss .weld .junit5 .auto .AddPackages ;
3728import org .jboss .weld .junit5 .auto .EnableAutoWeld ;
38- import org .jboss .weld .junit5 .auto .ExcludeBean ;
39- import org .jboss .weld .junit5 .auto .ExcludeBeanClasses ;
4029import org .junit .jupiter .api .Test ;
4130import org .junit .jupiter .api .condition .EnabledIfSystemProperty ;
4231
5746class 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