1
|
package cz.zcu.kiv.backendapi.catalog;
|
2
|
|
3
|
import cz.zcu.kiv.backendapi.alternativename.AlternativeName;
|
4
|
import cz.zcu.kiv.backendapi.bibliography.Bibliography;
|
5
|
import cz.zcu.kiv.backendapi.country.Country;
|
6
|
import cz.zcu.kiv.backendapi.exception.ApiRequestException;
|
7
|
import cz.zcu.kiv.backendapi.path.PathDto;
|
8
|
import cz.zcu.kiv.backendapi.type.Type;
|
9
|
import cz.zcu.kiv.backendapi.type.TypeServiceImpl;
|
10
|
import cz.zcu.kiv.backendapi.writtenform.WrittenForm;
|
11
|
import org.junit.jupiter.api.BeforeEach;
|
12
|
import org.junit.jupiter.api.Test;
|
13
|
import org.junit.jupiter.api.extension.ExtendWith;
|
14
|
import org.mockito.ArgumentCaptor;
|
15
|
import org.mockito.Mock;
|
16
|
import org.mockito.junit.jupiter.MockitoExtension;
|
17
|
|
18
|
import java.util.*;
|
19
|
import java.util.stream.Collectors;
|
20
|
import java.util.stream.Stream;
|
21
|
|
22
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
23
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
|
24
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
25
|
import static org.mockito.ArgumentMatchers.any;
|
26
|
import static org.mockito.ArgumentMatchers.anyString;
|
27
|
import static org.mockito.BDDMockito.given;
|
28
|
import static org.mockito.Mockito.never;
|
29
|
import static org.mockito.Mockito.verify;
|
30
|
|
31
|
@ExtendWith(MockitoExtension.class)
|
32
|
class CatalogItemServiceImplTest {
|
33
|
|
34
|
@Mock
|
35
|
private CatalogItemRepository catalogItemRepository;
|
36
|
|
37
|
@Mock
|
38
|
private TypeServiceImpl typeService;
|
39
|
|
40
|
|
41
|
private CatalogItemServiceImpl underTest;
|
42
|
|
43
|
@BeforeEach
|
44
|
void setUp() {
|
45
|
underTest = new CatalogItemServiceImpl(catalogItemRepository, typeService);
|
46
|
}
|
47
|
|
48
|
@Test
|
49
|
void saveCatalog() {
|
50
|
// given
|
51
|
Type type = new Type("type");
|
52
|
|
53
|
CatalogItem catalogItem = new CatalogItem();
|
54
|
catalogItem.setName("aaacbbbbbbbaa");
|
55
|
catalogItem.setBibliography(Set.of(new Bibliography("bibl", catalogItem)));
|
56
|
catalogItem.setTypes(Set.of(type));
|
57
|
catalogItem.setAlternativeNames(Set.of(new AlternativeName("altName", catalogItem)));
|
58
|
catalogItem.setCountries(Set.of(new Country("aaaabbaa", catalogItem)));
|
59
|
catalogItem.setWrittenForms(Set.of(new WrittenForm("written", catalogItem)));
|
60
|
catalogItem.setCertainty(0);
|
61
|
catalogItem.setLatitude(0.1);
|
62
|
catalogItem.setLongitude(0.2);
|
63
|
|
64
|
CatalogItem catalogItem2 = new CatalogItem();
|
65
|
catalogItem2.setName("name");
|
66
|
catalogItem2.setBibliography(Set.of(new Bibliography("bibl", catalogItem2)));
|
67
|
catalogItem2.setTypes(Set.of(type));
|
68
|
catalogItem2.setAlternativeNames(Set.of(new AlternativeName("aaaabbbbbbaa", catalogItem2)));
|
69
|
catalogItem2.setCountries(Set.of(new Country("aaaabbcccefaa", catalogItem2)));
|
70
|
catalogItem2.setWrittenForms(Set.of(new WrittenForm("written", catalogItem2)));
|
71
|
catalogItem2.setCertainty(1);
|
72
|
catalogItem2.setLatitude(1.1);
|
73
|
catalogItem2.setLongitude(1.2);
|
74
|
|
75
|
List<CatalogItem> catalog = List.of(catalogItem, catalogItem2);
|
76
|
|
77
|
given(typeService.getTypeByName(anyString())).willReturn(Optional.of(type));
|
78
|
|
79
|
// when
|
80
|
underTest.saveCatalog(catalog);
|
81
|
|
82
|
// then
|
83
|
verify(typeService, never()).saveType(type);
|
84
|
verify(catalogItemRepository).save(catalogItem);
|
85
|
verify(catalogItemRepository).save(catalogItem2);
|
86
|
}
|
87
|
|
88
|
@Test
|
89
|
void testSaveCatalogItem() {
|
90
|
// given
|
91
|
CatalogItemDto catalogItemDto = new CatalogItemDto();
|
92
|
catalogItemDto.setName("name");
|
93
|
catalogItemDto.setBibliography(Set.of("bibl"));
|
94
|
catalogItemDto.setTypes(Set.of("type"));
|
95
|
catalogItemDto.setAlternativeNames(Set.of("altName"));
|
96
|
catalogItemDto.setCountries(Set.of("country"));
|
97
|
catalogItemDto.setWrittenForms(Set.of("written"));
|
98
|
catalogItemDto.setCertainty(0);
|
99
|
catalogItemDto.setLatitude(0.1);
|
100
|
catalogItemDto.setLongitude(0.2);
|
101
|
|
102
|
Type type = new Type("type");
|
103
|
|
104
|
CatalogItem catalogItem = new CatalogItem();
|
105
|
catalogItem.setName("name");
|
106
|
catalogItem.setBibliography(Set.of(new Bibliography("bibl", catalogItem)));
|
107
|
catalogItem.setTypes(Set.of(type));
|
108
|
catalogItem.setAlternativeNames(Set.of(new AlternativeName("altName", catalogItem)));
|
109
|
catalogItem.setCountries(Set.of(new Country("country", catalogItem)));
|
110
|
catalogItem.setWrittenForms(Set.of(new WrittenForm("written", catalogItem)));
|
111
|
catalogItem.setCertainty(0);
|
112
|
catalogItem.setLatitude(0.1);
|
113
|
catalogItem.setLongitude(0.2);
|
114
|
|
115
|
given(typeService.getTypeByName(anyString())).willReturn(Optional.of(type));
|
116
|
|
117
|
// when
|
118
|
underTest.saveCatalogItem(catalogItemDto);
|
119
|
|
120
|
// then
|
121
|
ArgumentCaptor<CatalogItem> argumentCaptor = ArgumentCaptor.forClass(CatalogItem.class);
|
122
|
|
123
|
verify(catalogItemRepository).save(argumentCaptor.capture());
|
124
|
verify(typeService, never()).saveType(type);
|
125
|
|
126
|
CatalogItem capturedItem = argumentCaptor.getValue();
|
127
|
|
128
|
assertThat(capturedItem).isEqualTo(catalogItem);
|
129
|
|
130
|
}
|
131
|
|
132
|
@Test
|
133
|
void testCanGetCatalogItem() {
|
134
|
// given
|
135
|
UUID id = UUID.randomUUID();
|
136
|
CatalogItem catalogItem = new CatalogItem();
|
137
|
catalogItem.setId(id);
|
138
|
CatalogItemDto catalogItemDto = new CatalogItemDto();
|
139
|
catalogItemDto.setId(id);
|
140
|
given(catalogItemRepository.findById(id)).willReturn(Optional.of(catalogItem));
|
141
|
|
142
|
// when
|
143
|
CatalogItemDto retrievedItemDto = underTest.getCatalogItem(id);
|
144
|
|
145
|
// then
|
146
|
verify(catalogItemRepository).findById(id);
|
147
|
assertThat(retrievedItemDto).isEqualTo(catalogItemDto);
|
148
|
}
|
149
|
|
150
|
@Test
|
151
|
void testCanNotGetCatalogItem() {
|
152
|
// given
|
153
|
UUID id = UUID.randomUUID();
|
154
|
|
155
|
// when
|
156
|
// then
|
157
|
assertThatThrownBy(() -> underTest.getCatalogItem(id))
|
158
|
.isInstanceOf(ApiRequestException.class)
|
159
|
.hasMessageContaining("Catalog item not found");
|
160
|
|
161
|
verify(catalogItemRepository).findById(id);
|
162
|
}
|
163
|
|
164
|
@Test
|
165
|
void testCanUpdateCatalogItem() {
|
166
|
// given
|
167
|
UUID id = UUID.randomUUID();
|
168
|
|
169
|
CatalogItemDto catalogItemDto = new CatalogItemDto();
|
170
|
catalogItemDto.setName("name");
|
171
|
catalogItemDto.setBibliography(Set.of("bibl"));
|
172
|
catalogItemDto.setTypes(Set.of("type"));
|
173
|
catalogItemDto.setAlternativeNames(Set.of("altName"));
|
174
|
catalogItemDto.setCountries(Set.of("country"));
|
175
|
catalogItemDto.setWrittenForms(Set.of("written"));
|
176
|
catalogItemDto.setCertainty(0);
|
177
|
catalogItemDto.setLatitude(0.1);
|
178
|
catalogItemDto.setLongitude(0.2);
|
179
|
|
180
|
Type type = new Type("type");
|
181
|
Type typeOld = new Type("old");
|
182
|
|
183
|
CatalogItem catalogItem = new CatalogItem();
|
184
|
catalogItem.setName("name");
|
185
|
catalogItem.setBibliography(Set.of(new Bibliography("bibl", catalogItem)));
|
186
|
catalogItem.setTypes(Set.of(type));
|
187
|
catalogItem.setAlternativeNames(Set.of(new AlternativeName("altName", catalogItem)));
|
188
|
catalogItem.setCountries(Set.of(new Country("country", catalogItem)));
|
189
|
catalogItem.setWrittenForms(Set.of(new WrittenForm("written", catalogItem)));
|
190
|
catalogItem.setCertainty(0);
|
191
|
catalogItem.setLatitude(0.1);
|
192
|
catalogItem.setLongitude(0.2);
|
193
|
|
194
|
CatalogItem oldCatalogItem = new CatalogItem();
|
195
|
oldCatalogItem.setName("old");
|
196
|
oldCatalogItem.setBibliography(Set.of(new Bibliography("old", oldCatalogItem)));
|
197
|
oldCatalogItem.setTypes(Set.of(typeOld));
|
198
|
oldCatalogItem.setAlternativeNames(Set.of(new AlternativeName("old", oldCatalogItem)));
|
199
|
oldCatalogItem.setCountries(Set.of(new Country("old", oldCatalogItem)));
|
200
|
oldCatalogItem.setWrittenForms(Set.of(new WrittenForm("old", catalogItem)));
|
201
|
oldCatalogItem.setCertainty(10);
|
202
|
oldCatalogItem.setLatitude(10.1);
|
203
|
oldCatalogItem.setLongitude(10.2);
|
204
|
|
205
|
given(catalogItemRepository.findById(id)).willReturn(Optional.of(oldCatalogItem));
|
206
|
given(typeService.getTypeByName(anyString())).willReturn(Optional.empty());
|
207
|
|
208
|
// when
|
209
|
|
210
|
underTest.updateCatalogItem(id, catalogItemDto);
|
211
|
|
212
|
// then
|
213
|
verify(typeService).saveType(type);
|
214
|
|
215
|
ArgumentCaptor<CatalogItem> argumentCaptor = ArgumentCaptor.forClass(CatalogItem.class);
|
216
|
|
217
|
verify(catalogItemRepository).save(argumentCaptor.capture());
|
218
|
|
219
|
CatalogItem capturedCatalogItem = argumentCaptor.getValue();
|
220
|
|
221
|
assertThat(capturedCatalogItem).isEqualTo(catalogItem);
|
222
|
}
|
223
|
|
224
|
@Test
|
225
|
void testCanNotUpdateCatalogItem() {
|
226
|
// given
|
227
|
UUID id = UUID.randomUUID();
|
228
|
|
229
|
CatalogItemDto catalogItemDto = new CatalogItemDto();
|
230
|
catalogItemDto.setName("name");
|
231
|
catalogItemDto.setBibliography(Set.of("bibl"));
|
232
|
catalogItemDto.setTypes(Set.of("type"));
|
233
|
catalogItemDto.setAlternativeNames(Set.of("altName"));
|
234
|
catalogItemDto.setCountries(Set.of("country"));
|
235
|
catalogItemDto.setWrittenForms(Set.of("written"));
|
236
|
catalogItemDto.setCertainty(0);
|
237
|
catalogItemDto.setLatitude(0.1);
|
238
|
catalogItemDto.setLongitude(0.2);
|
239
|
|
240
|
// when
|
241
|
// then
|
242
|
assertThatThrownBy(() -> underTest.updateCatalogItem(id, catalogItemDto))
|
243
|
.isInstanceOf(ApiRequestException.class)
|
244
|
.hasMessageContaining("Catalog item not found");
|
245
|
|
246
|
verify(catalogItemRepository, never()).save(any());
|
247
|
verify(typeService, never()).saveType(any());
|
248
|
}
|
249
|
|
250
|
@Test
|
251
|
void testCanDeleteCatalogItem() {
|
252
|
// given
|
253
|
UUID id = UUID.randomUUID();
|
254
|
given(catalogItemRepository.existsById(id)).willReturn(true);
|
255
|
|
256
|
// when
|
257
|
underTest.deleteCatalogItem(id);
|
258
|
|
259
|
// then
|
260
|
verify(catalogItemRepository).deleteById(id);
|
261
|
}
|
262
|
|
263
|
@Test
|
264
|
void testCanNotDeleteCatalogItem() {
|
265
|
// given
|
266
|
UUID id = UUID.randomUUID();
|
267
|
given(catalogItemRepository.existsById(id)).willReturn(false);
|
268
|
|
269
|
// when
|
270
|
// then
|
271
|
assertThatThrownBy(() -> underTest.deleteCatalogItem(id))
|
272
|
.isInstanceOf(ApiRequestException.class)
|
273
|
.hasMessageContaining("Catalog item not found");
|
274
|
|
275
|
verify(catalogItemRepository, never()).deleteById(any());
|
276
|
}
|
277
|
|
278
|
@Test
|
279
|
void getCatalog() {
|
280
|
// given
|
281
|
String name = "aaa?bb*aa";
|
282
|
String country = "aaa?bb*aa";
|
283
|
String type = "aaa?bb*aa";
|
284
|
String nameChanged = "aaa_bb%aa";
|
285
|
String countryChanged = "aaa_bb%aa";
|
286
|
String typeChanged = "aaa_bb%aa";
|
287
|
|
288
|
Type typeEntity = new Type(type);
|
289
|
|
290
|
CatalogItem catalogItem = new CatalogItem();
|
291
|
catalogItem.setName("aaacbbbbbbbaa");
|
292
|
catalogItem.setBibliography(Set.of(new Bibliography("bibl", catalogItem)));
|
293
|
catalogItem.setTypes(Set.of(typeEntity));
|
294
|
catalogItem.setAlternativeNames(Set.of(new AlternativeName("altName", catalogItem)));
|
295
|
catalogItem.setCountries(Set.of(new Country("aaaabbaa", catalogItem)));
|
296
|
catalogItem.setWrittenForms(Set.of(new WrittenForm("written", catalogItem)));
|
297
|
catalogItem.setCertainty(0);
|
298
|
catalogItem.setLatitude(0.1);
|
299
|
catalogItem.setLongitude(0.2);
|
300
|
|
301
|
CatalogItem catalogItem2 = new CatalogItem();
|
302
|
catalogItem2.setName("name");
|
303
|
catalogItem2.setBibliography(Set.of(new Bibliography("bibl", catalogItem2)));
|
304
|
catalogItem2.setTypes(Set.of(typeEntity));
|
305
|
catalogItem2.setAlternativeNames(Set.of(new AlternativeName("aaaabbbbbbaa", catalogItem2)));
|
306
|
catalogItem2.setCountries(Set.of(new Country("aaaabbcccefaa", catalogItem2)));
|
307
|
catalogItem2.setWrittenForms(Set.of(new WrittenForm("written", catalogItem2)));
|
308
|
catalogItem2.setCertainty(1);
|
309
|
catalogItem2.setLatitude(1.1);
|
310
|
catalogItem2.setLongitude(1.2);
|
311
|
|
312
|
CatalogItemDto catalogItemDto = new CatalogItemDto();
|
313
|
catalogItemDto.setName("aaacbbbbbbbaa");
|
314
|
catalogItemDto.setBibliography(Set.of("bibl"));
|
315
|
catalogItemDto.setTypes(Set.of("aaa?bb*aa"));
|
316
|
catalogItemDto.setAlternativeNames(Set.of("altName"));
|
317
|
catalogItemDto.setCountries(Set.of("aaaabbaa"));
|
318
|
catalogItemDto.setWrittenForms(Set.of("written"));
|
319
|
catalogItemDto.setCertainty(0);
|
320
|
catalogItemDto.setLatitude(0.1);
|
321
|
catalogItemDto.setLongitude(0.2);
|
322
|
|
323
|
CatalogItemDto catalogItemDto2 = new CatalogItemDto();
|
324
|
catalogItemDto2.setName("name");
|
325
|
catalogItemDto2.setBibliography(Set.of("bibl"));
|
326
|
catalogItemDto2.setTypes(Set.of("aaa?bb*aa"));
|
327
|
catalogItemDto2.setAlternativeNames(Set.of("aaaabbbbbbaa"));
|
328
|
catalogItemDto2.setCountries(Set.of("aaaabbcccefaa"));
|
329
|
catalogItemDto2.setWrittenForms(Set.of("written"));
|
330
|
catalogItemDto2.setCertainty(1);
|
331
|
catalogItemDto2.setLatitude(1.1);
|
332
|
catalogItemDto2.setLongitude(1.2);
|
333
|
|
334
|
given(catalogItemRepository.filterCatalog(nameChanged, countryChanged, typeChanged)).willReturn(Set.of(catalogItem, catalogItem2));
|
335
|
|
336
|
// when
|
337
|
List<CatalogItemDto> results = underTest.getCatalog(name, country, type);
|
338
|
|
339
|
// then
|
340
|
assertThat(results.size()).isEqualTo(2);
|
341
|
assertTrue(results.contains(catalogItemDto));
|
342
|
assertTrue(results.contains(catalogItemDto2));
|
343
|
|
344
|
verify(catalogItemRepository).filterCatalog(nameChanged, countryChanged, typeChanged);
|
345
|
}
|
346
|
|
347
|
@Test
|
348
|
void testSearchedTest() {
|
349
|
// given
|
350
|
String text = "The city of Azbar was found in first century near the ocean. " +
|
351
|
"⌈U-re-me-re⌉, another town, was found " +
|
352
|
"in 1956. The location of Huga and Duga is not known, but it was probably near Puga.";
|
353
|
String highlightedText = "The <b>city</b> of <span style='color:green'>Azbar</span> was found in first century near the <b>ocean</b>. " +
|
354
|
"⌈<span style='color:green'>U-re-me-re</span>⌉, another town, was found " +
|
355
|
"in 1956. The location of <span style='color:red'>Huga</span> and <span style='color:red'>Duga</span> is not known, but it was probably near Puga.";
|
356
|
|
357
|
CatalogItem catalogItem1 = new CatalogItem();
|
358
|
catalogItem1.setAlternativeNames(Stream.of(new AlternativeName("Azbar", catalogItem1)).collect(Collectors.toSet()));
|
359
|
catalogItem1.setLatitude(5);
|
360
|
catalogItem1.setLongitude(5);
|
361
|
|
362
|
CatalogItem catalogItem2 = new CatalogItem();
|
363
|
catalogItem2.setAlternativeNames(Stream.of(new AlternativeName("Azbar", catalogItem2), new AlternativeName("Azbarasdf", catalogItem2)).collect(Collectors.toSet()));
|
364
|
catalogItem2.setLatitude(0.0);
|
365
|
catalogItem2.setLongitude(0.0);
|
366
|
|
367
|
CatalogItem catalogItem3 = new CatalogItem();
|
368
|
catalogItem3.setAlternativeNames(Stream.of(new AlternativeName("U-re-me-re", catalogItem3)).collect(Collectors.toSet()));
|
369
|
catalogItem3.setLatitude(55);
|
370
|
catalogItem3.setLongitude(68);
|
371
|
|
372
|
CatalogItem catalogItem4 = new CatalogItem();
|
373
|
catalogItem4.setAlternativeNames(Stream.of(new AlternativeName("Huga", catalogItem4)).collect(Collectors.toSet()));
|
374
|
catalogItem4.setLatitude(0.0);
|
375
|
catalogItem4.setLongitude(0.0);
|
376
|
|
377
|
CatalogItem catalogItem5 = new CatalogItem();
|
378
|
catalogItem5.setAlternativeNames(Stream.of(new AlternativeName("Huga", catalogItem5), new AlternativeName("Hugaa", catalogItem5)).collect(Collectors.toSet()));
|
379
|
catalogItem5.setLatitude(0.0);
|
380
|
catalogItem5.setLongitude(0.0);
|
381
|
|
382
|
CatalogItem catalogItem6 = new CatalogItem();
|
383
|
catalogItem6.setAlternativeNames(Stream.of(new AlternativeName("Duga", catalogItem6)).collect(Collectors.toSet()));
|
384
|
catalogItem6.setLatitude(0.0);
|
385
|
catalogItem6.setLongitude(0.0);
|
386
|
|
387
|
CatalogItemDto catalogItemDto1 = new CatalogItemDto();
|
388
|
catalogItemDto1.setAlternativeNames(Stream.of("Azbar").collect(Collectors.toSet()));
|
389
|
catalogItemDto1.setLatitude(5);
|
390
|
catalogItemDto1.setLongitude(5);
|
391
|
|
392
|
CatalogItemDto catalogItemDto2 = new CatalogItemDto();
|
393
|
catalogItemDto2.setAlternativeNames(Stream.of("Azbar", "Azbarasdf").collect(Collectors.toSet()));
|
394
|
catalogItemDto2.setLatitude(0.0);
|
395
|
catalogItemDto2.setLongitude(0.0);
|
396
|
|
397
|
CatalogItemDto catalogItemDto3 = new CatalogItemDto();
|
398
|
catalogItemDto3.setAlternativeNames(Stream.of("U-re-me-re").collect(Collectors.toSet()));
|
399
|
catalogItemDto3.setLatitude(55);
|
400
|
catalogItemDto3.setLongitude(68);
|
401
|
|
402
|
CatalogItemDto catalogItemDto4 = new CatalogItemDto();
|
403
|
catalogItemDto4.setAlternativeNames(Stream.of("Huga").collect(Collectors.toSet()));
|
404
|
catalogItemDto4.setLatitude(0.0);
|
405
|
catalogItemDto4.setLongitude(0.0);
|
406
|
|
407
|
CatalogItemDto catalogItemDto5 = new CatalogItemDto();
|
408
|
catalogItemDto5.setAlternativeNames(Stream.of("Huga", "Hugaa").collect(Collectors.toSet()));
|
409
|
catalogItemDto5.setLatitude(0.0);
|
410
|
catalogItemDto5.setLongitude(0.0);
|
411
|
|
412
|
CatalogItemDto catalogItemDto6 = new CatalogItemDto();
|
413
|
catalogItemDto6.setAlternativeNames(Stream.of("Duga").collect(Collectors.toSet()));
|
414
|
catalogItemDto6.setLatitude(0.0);
|
415
|
catalogItemDto6.setLongitude(0.0);
|
416
|
|
417
|
|
418
|
given(typeService.getAllTypesAsString()).willReturn(Stream.of("city", "ocean").collect(Collectors.toSet()));
|
419
|
given(catalogItemRepository.getItemsByName(anyString())).willReturn(Collections.emptyList());
|
420
|
given(catalogItemRepository.getItemsByName("Azbar")).willReturn(Stream.of(catalogItem1, catalogItem2).collect(Collectors.toList()));
|
421
|
given(catalogItemRepository.getItemsByName("U-re-me-re")).willReturn(Stream.of(catalogItem3).collect(Collectors.toList()));
|
422
|
given(catalogItemRepository.getItemsByName("Huga")).willReturn(Stream.of(catalogItem4, catalogItem5).collect(Collectors.toList()));
|
423
|
given(catalogItemRepository.getItemsByName("Duga")).willReturn(Stream.of(catalogItem6).collect(Collectors.toList()));
|
424
|
|
425
|
// when
|
426
|
PathDto pathDto = underTest.getPath(text);
|
427
|
|
428
|
// then
|
429
|
verify(catalogItemRepository).getItemsByName("Azbar");
|
430
|
verify(catalogItemRepository).getItemsByName("U-re-me-re");
|
431
|
verify(catalogItemRepository).getItemsByName("Huga");
|
432
|
verify(catalogItemRepository).getItemsByName("Duga");
|
433
|
verify(catalogItemRepository).getItemsByName("Puga");
|
434
|
|
435
|
assertThat(pathDto.getText()).isEqualTo(highlightedText);
|
436
|
|
437
|
assertThat(pathDto.getFoundCatalogItems().size()).isEqualTo(4);
|
438
|
|
439
|
assertThat(pathDto.getFoundCatalogItems().get(0).size()).isEqualTo(2);
|
440
|
assertThat(pathDto.getFoundCatalogItems().get(0).get(0)).isEqualTo(catalogItemDto1);
|
441
|
assertThat(pathDto.getFoundCatalogItems().get(0).get(1)).isEqualTo(catalogItemDto2);
|
442
|
|
443
|
assertThat(pathDto.getFoundCatalogItems().get(1).size()).isEqualTo(1);
|
444
|
assertThat(pathDto.getFoundCatalogItems().get(1).get(0)).isEqualTo(catalogItemDto3);
|
445
|
|
446
|
assertThat(pathDto.getFoundCatalogItems().get(2).size()).isEqualTo(2);
|
447
|
assertThat(pathDto.getFoundCatalogItems().get(2).get(0)).isEqualTo(catalogItemDto4);
|
448
|
assertThat(pathDto.getFoundCatalogItems().get(2).get(1)).isEqualTo(catalogItemDto5);
|
449
|
|
450
|
assertThat(pathDto.getFoundCatalogItems().get(3).size()).isEqualTo(1);
|
451
|
assertThat(pathDto.getFoundCatalogItems().get(3).get(0)).isEqualTo(catalogItemDto6);
|
452
|
}
|
453
|
}
|