5151
5252@ EnableAutoWeld
5353@ AddPackages (value = {Database .class , Converters .class , EntityConverter .class , DocumentTemplate .class })
54- @ AddPackages (Book .class )
54+ @ AddPackages (Magazine .class )
5555@ AddPackages (ElasticsearchTemplate .class )
5656@ AddExtensions ({EntityMetadataExtension .class ,
5757 DocumentExtension .class })
@@ -83,35 +83,35 @@ public void clearDatabase() {
8383 @ Test
8484 public void shouldInsert () {
8585 Author joshuaBloch = new Author ("Joshua Bloch" );
86- Book book = new Book (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
87- library .save (book );
86+ Magazine magazine = new Magazine (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
87+ library .save (magazine );
8888
89- AtomicReference <Book > reference = new AtomicReference <>();
89+ AtomicReference <Magazine > reference = new AtomicReference <>();
9090 await ().until (() -> {
91- Optional <Book > optional = library .findById (book .id ());
91+ Optional <Magazine > optional = library .findById (magazine .id ());
9292 optional .ifPresent (reference ::set );
9393 return optional .isPresent ();
9494 });
95- assertThat (reference .get ()).isNotNull ().isEqualTo (book );
95+ assertThat (reference .get ()).isNotNull ().isEqualTo (magazine );
9696 }
9797
9898 @ Test
9999 public void shouldUpdate () {
100100 Author joshuaBloch = new Author ("Joshua Bloch" );
101- Book book = new Book (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
102- assertThat (library .save (book ))
101+ Magazine magazine = new Magazine (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
102+ assertThat (library .save (magazine ))
103103 .isNotNull ()
104- .isEqualTo (book );
104+ .isEqualTo (magazine );
105105
106- Book updated = book .updateEdition (2 );
106+ Magazine updated = magazine .updateEdition (2 );
107107
108108 assertThat (library .save (updated ))
109109 .isNotNull ()
110- .isNotEqualTo (book );
110+ .isNotEqualTo (magazine );
111111
112- AtomicReference <Book > reference = new AtomicReference <>();
112+ AtomicReference <Magazine > reference = new AtomicReference <>();
113113 await ().until (() -> {
114- Optional <Book > optional = library .findById (book .id ());
114+ Optional <Magazine > optional = library .findById (magazine .id ());
115115 optional .ifPresent (reference ::set );
116116 return optional .isPresent ();
117117 });
@@ -122,82 +122,82 @@ public void shouldUpdate() {
122122 @ Test
123123 public void shouldFindById () {
124124 Author joshuaBloch = new Author ("Joshua Bloch" );
125- Book book = new Book (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
125+ Magazine magazine = new Magazine (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
126126
127- assertThat (library .save (book ))
127+ assertThat (library .save (magazine ))
128128 .isNotNull ()
129- .isEqualTo (book );
129+ .isEqualTo (magazine );
130130
131- AtomicReference <Book > reference = new AtomicReference <>();
131+ AtomicReference <Magazine > reference = new AtomicReference <>();
132132 await ().until (() -> {
133- Optional <Book > optional = library .findById (book .id ());
133+ Optional <Magazine > optional = library .findById (magazine .id ());
134134 optional .ifPresent (reference ::set );
135135 return optional .isPresent ();
136136 });
137137
138- assertThat (reference .get ()).isNotNull ().isEqualTo (book );
138+ assertThat (reference .get ()).isNotNull ().isEqualTo (magazine );
139139 }
140140
141141 @ Test
142142 public void shouldDelete () {
143143 Author joshuaBloch = new Author ("Joshua Bloch" );
144- Book book = new Book (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
145- assertThat (library .save (book ))
144+ Magazine magazine = new Magazine (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
145+ assertThat (library .save (magazine ))
146146 .isNotNull ()
147- .isEqualTo (book );
147+ .isEqualTo (magazine );
148148
149149
150- library .deleteById (book .id ());
150+ library .deleteById (magazine .id ());
151151
152- assertThat (library .findById (book .id ()))
152+ assertThat (library .findById (magazine .id ()))
153153 .isNotNull ().isEmpty ();
154154 }
155155
156156
157157 @ Test
158158 public void shouldFindByAuthorName () throws InterruptedException {
159159 Author joshuaBloch = new Author ("Joshua Bloch" );
160- Book book = new Book (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
160+ Magazine magazine = new Magazine (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
161161
162- List <Book > expectedBooks = List .of (book , book .newEdition (), book .newEdition ());
163- library .saveAll (expectedBooks );
162+ List <Magazine > expectedMagazines = List .of (magazine , magazine .newEdition (), magazine .newEdition ());
163+ library .saveAll (expectedMagazines );
164164
165165 await ().until (() ->
166- !library .findByAuthorName (book .author ().name ()).toList ().isEmpty ());
166+ !library .findByAuthorName (magazine .author ().name ()).toList ().isEmpty ());
167167
168- var books = library .findByAuthorName (book .author ().name ()).toList ();
168+ var books = library .findByAuthorName (magazine .author ().name ()).toList ();
169169 assertThat (books )
170170 .hasSize (3 );
171171
172172 assertThat (books )
173- .containsAll (expectedBooks );
173+ .containsAll (expectedMagazines );
174174 }
175175
176176 @ Test
177177 public void shouldFindByTitleLike () throws InterruptedException {
178178 Author joshuaBloch = new Author ("Joshua Bloch" );
179179
180- Book effectiveJava1stEdition = new Book (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
181- Book effectiveJava2ndEdition = effectiveJava1stEdition .newEdition ();
182- Book effectiveJava3rdEdition = effectiveJava2ndEdition .newEdition ();
180+ Magazine effectiveJava1stEdition = new Magazine (randomUUID ().toString (), "Effective Java" , 1 , joshuaBloch );
181+ Magazine effectiveJava2ndEdition = effectiveJava1stEdition .newEdition ();
182+ Magazine effectiveJava3rdEdition = effectiveJava2ndEdition .newEdition ();
183183
184184 Author elderMoraes = new Author ("Elder Moraes" );
185- Book jakartaEECookBook = new Book (randomUUID ().toString (), "Jakarta EE CookBook" , 1 , elderMoraes );
185+ Magazine jakartaEECookMagazine = new Magazine (randomUUID ().toString (), "Jakarta EE CookBook" , 1 , elderMoraes );
186186
187- List <Book > allBooks = List .of (jakartaEECookBook , effectiveJava1stEdition , effectiveJava2ndEdition , effectiveJava3rdEdition );
187+ List <Magazine > allMagazines = List .of (jakartaEECookMagazine , effectiveJava1stEdition , effectiveJava2ndEdition , effectiveJava3rdEdition );
188188
189- List <Book > effectiveBooks = List .of (effectiveJava1stEdition , effectiveJava2ndEdition , effectiveJava3rdEdition );
189+ List <Magazine > effectiveMagazines = List .of (effectiveJava1stEdition , effectiveJava2ndEdition , effectiveJava3rdEdition );
190190
191- library .saveAll (allBooks );
191+ library .saveAll (allMagazines );
192192
193- AtomicReference <List <Book >> booksWithEffective = new AtomicReference <>();
193+ AtomicReference <List <Magazine >> booksWithEffective = new AtomicReference <>();
194194 await ().until (() -> {
195195 var books = library .findByTitleLike ("Effective" ).toList ();
196196 booksWithEffective .set (books );
197197 return !books .isEmpty ();
198198 });
199199
200- AtomicReference <List <Book >> booksWithJa = new AtomicReference <>();
200+ AtomicReference <List <Magazine >> booksWithJa = new AtomicReference <>();
201201 await ().until (() -> {
202202 var books = library .findByTitleLike ("Ja*" ).toList ();
203203 booksWithJa .set (books );
@@ -206,12 +206,12 @@ public void shouldFindByTitleLike() throws InterruptedException {
206206
207207 assertSoftly (softly -> assertThat (booksWithEffective .get ())
208208 .as ("returned book list with 'Effective' is not equals to the expected items " )
209- .containsAll (effectiveBooks ));
209+ .containsAll (effectiveMagazines ));
210210
211211
212212 assertSoftly (softly -> assertThat (booksWithJa .get ())
213213 .as ("returned book list with 'Ja*' is not equals to the expected items " )
214- .containsAll (allBooks ));
214+ .containsAll (allMagazines ));
215215 }
216216
217217
0 commit comments