1515package org .eclipse .jnosql .databases .mongodb .integration ;
1616
1717import jakarta .inject .Inject ;
18+ import org .assertj .core .api .SoftAssertions ;
1819import org .eclipse .jnosql .databases .mongodb .communication .MongoDBDocumentConfigurations ;
1920import org .eclipse .jnosql .databases .mongodb .mapping .MongoDBTemplate ;
2021import jakarta .nosql .Convert ;
3334import org .junit .jupiter .api .Test ;
3435import org .junit .jupiter .api .condition .EnabledIfSystemProperty ;
3536
37+ import java .util .List ;
38+
3639import static java .util .UUID .randomUUID ;
40+ import static org .assertj .core .api .Assertions .as ;
3741import static org .assertj .core .api .Assertions .assertThat ;
42+ import static org .assertj .core .api .SoftAssertions .assertSoftly ;
3843import static org .eclipse .jnosql .communication .driver .IntegrationTest .MATCHES ;
3944import static org .eclipse .jnosql .communication .driver .IntegrationTest .NAMED ;
4045import static org .eclipse .jnosql .databases .mongodb .communication .DocumentDatabase .INSTANCE ;
@@ -59,6 +64,11 @@ class RepositoryIntegrationTest {
5964 @ Database (DatabaseType .DOCUMENT )
6065 BookRepository repository ;
6166
67+
68+ @ Inject
69+ @ Database (DatabaseType .DOCUMENT )
70+ BookStore bookStore ;
71+
6272 @ Test
6373 void shouldSave () {
6474 Book book = new Book (randomUUID ().toString (), "Effective Java" , 1 );
@@ -75,6 +85,36 @@ void shouldSave() {
7585 assertThat (repository .findById (book .id ()))
7686 .isNotNull ().get ().isEqualTo (updated );
7787
88+ assertSoftly (softly -> {
89+
90+ BookOrder order = new BookOrder (
91+ randomUUID ().toString (),
92+ List .of (
93+ new BookOrderItem (new Book (randomUUID ().toString (), "Effective Java" , 3 ), 1 )
94+ ,new BookOrderItem (new Book (randomUUID ().toString (), "Java Persistence Layer" , 1 ), 10 )
95+ ,new BookOrderItem (new Book (randomUUID ().toString (), "Jakarta EE Cookbook" , 1 ), 5 )
96+ )
97+ );
98+
99+ bookStore .save (order );
100+
101+ softly .assertThat (bookStore .findById (order .id ()))
102+ .as ("cannot find the order persisted previously" )
103+ .isPresent ()
104+ .get ()
105+ .as ("the loaded the persisted BookOrder doesn't matches with the BookOrder origin" )
106+ .satisfies (persistedOrder ->{
107+ softly .assertThat (persistedOrder .id ())
108+ .as ("the loaded the persisted BookOrder id is not equals to the BookOrder origin id" )
109+ .isEqualTo (order .id ());
110+ softly .assertThat (persistedOrder .items ())
111+ .as ("the loaded the persisted BookOrder items is not equals to the BookOrder origin items" )
112+ .containsAll (order .items ());
113+ });
114+
115+
116+ });
117+
78118 }
79119
80120 @ Test
@@ -111,7 +151,9 @@ void shouldDeleteAll() {
111151 }
112152
113153 repository .deleteAll ();
114- assertThat (repository .findAll ()).isEmpty ();
154+ bookStore .deleteAll ();
155+ assertThat (repository .findAll ()).as ("the repository is not empty" ).isEmpty ();
156+ assertThat (bookStore .findAll ()).as ("the bookStore is not empty" ).isEmpty ();
115157 }
116158
117159}
0 commit comments