Projekt

Obecné

Profil

« Předchozí | Další » 

Revize abaa5f46

Přidáno uživatelem Jakub Šmíd před asi 2 roky(ů)

  • ID abaa5f461242c640ae1e7daaddb6bfc1b1419db9
  • Rodič c1df89f5

Experiment with database

Zobrazit rozdíly:

backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplTest.java
10 10
import org.junit.jupiter.api.BeforeEach;
11 11
import org.junit.jupiter.api.Test;
12 12
import org.junit.jupiter.api.extension.ExtendWith;
13
import org.mockito.*;
13
import org.mockito.ArgumentCaptor;
14
import org.mockito.Mock;
14 15
import org.mockito.junit.jupiter.MockitoExtension;
15 16

  
17
import java.util.ArrayList;
16 18
import java.util.List;
17 19
import java.util.Optional;
18
import java.util.Set;
19 20
import java.util.UUID;
21
import java.util.stream.Collectors;
22
import java.util.stream.Stream;
20 23

  
21 24
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
22 25
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
......
48 51
    void saveCatalog() {
49 52
        // given
50 53
        Type type = new Type("type");
54
        CatalogItemDto catalogItemDto = new CatalogItemDto();
55
        catalogItemDto.setName("aaacbbbbbbbaa");
56
        catalogItemDto.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
57
        catalogItemDto.setTypes(Stream.of("type").collect(Collectors.toSet()));
58
        catalogItemDto.setAlternativeNames(Stream.of("altName").collect(Collectors.toSet()));
59
        catalogItemDto.setCountries(Stream.of("aaaabbaa").collect(Collectors.toSet()));
60
        catalogItemDto.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
61
        catalogItemDto.setCertainty(0);
62
        catalogItemDto.setLatitude(0.1);
63
        catalogItemDto.setLongitude(0.2);
64

  
65
        CatalogItemDto catalogItemDto2 = new CatalogItemDto();
66
        catalogItemDto2.setName("name");
67
        catalogItemDto2.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
68
        catalogItemDto2.setTypes(Stream.of("type").collect(Collectors.toSet()));
69
        catalogItemDto2.setAlternativeNames(Stream.of("aaaabbbbbbaa").collect(Collectors.toSet()));
70
        catalogItemDto2.setCountries(Stream.of("aaaabbcccefaa").collect(Collectors.toSet()));
71
        catalogItemDto2.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
72
        catalogItemDto2.setCertainty(1);
73
        catalogItemDto2.setLatitude(1.1);
74
        catalogItemDto2.setLongitude(1.2);
51 75

  
52 76
        CatalogItem catalogItem = new CatalogItem();
53 77
        catalogItem.setName("aaacbbbbbbbaa");
54
        catalogItem.setBibliography(Set.of(new Bibliography("bibl", catalogItem)));
55
        catalogItem.setTypes(Set.of(type));
56
        catalogItem.setAlternativeNames(Set.of(new AlternativeName("altName", catalogItem)));
57
        catalogItem.setCountries(Set.of(new Country("aaaabbaa", catalogItem)));
58
        catalogItem.setWrittenForms(Set.of(new WrittenForm("written", catalogItem)));
78
        catalogItem.setBibliography(Stream.of(new Bibliography("bibl", catalogItem)).collect(Collectors.toSet()));
79
        catalogItem.setTypes(Stream.of(type).collect(Collectors.toSet()));
80
        catalogItem.setAlternativeNames(Stream.of(new AlternativeName("altName", catalogItem)).collect(Collectors.toSet()));
81
        catalogItem.setCountries(Stream.of(new Country("aaaabbaa", catalogItem)).collect(Collectors.toSet()));
82
        catalogItem.setWrittenForms(Stream.of(new WrittenForm("written", catalogItem)).collect(Collectors.toSet()));
59 83
        catalogItem.setCertainty(0);
60 84
        catalogItem.setLatitude(0.1);
61 85
        catalogItem.setLongitude(0.2);
62 86

  
63 87
        CatalogItem catalogItem2 = new CatalogItem();
64 88
        catalogItem2.setName("name");
65
        catalogItem2.setBibliography(Set.of(new Bibliography("bibl", catalogItem2)));
66
        catalogItem2.setTypes(Set.of(type));
67
        catalogItem2.setAlternativeNames(Set.of(new AlternativeName("aaaabbbbbbaa", catalogItem2)));
68
        catalogItem2.setCountries(Set.of(new Country("aaaabbcccefaa", catalogItem2)));
69
        catalogItem2.setWrittenForms(Set.of(new WrittenForm("written", catalogItem2)));
89
        catalogItem2.setBibliography(Stream.of(new Bibliography("bibl", catalogItem2)).collect(Collectors.toSet()));
90
        catalogItem2.setTypes(Stream.of(type).collect(Collectors.toSet()));
91
        catalogItem2.setAlternativeNames(Stream.of(new AlternativeName("aaaabbbbbbaa", catalogItem2)).collect(Collectors.toSet()));
92
        catalogItem2.setCountries(Stream.of(new Country("aaaabbcccefaa", catalogItem2)).collect(Collectors.toSet()));
93
        catalogItem2.setWrittenForms(Stream.of(new WrittenForm("written", catalogItem2)).collect(Collectors.toSet()));
70 94
        catalogItem2.setCertainty(1);
71 95
        catalogItem2.setLatitude(1.1);
72 96
        catalogItem2.setLongitude(1.2);
73 97

  
74
        List<CatalogItem> catalog = List.of(catalogItem, catalogItem2);
98
        List<CatalogItemDto> catalog = List.of(catalogItemDto, catalogItemDto2);
75 99

  
76 100
        given(typeService.getTypeByName(anyString())).willReturn(Optional.of(type));
77 101

  
......
79 103
        underTest.saveCatalog(catalog);
80 104

  
81 105
        // then
106

  
82 107
        verify(typeService, never()).saveType(type);
83
        verify(catalogItemRepository).save(catalogItem);
84
        verify(catalogItemRepository).save(catalogItem2);
85 108
    }
86 109

  
87 110
    @Test
......
89 112
        // given
90 113
        CatalogItemDto catalogItemDto = new CatalogItemDto();
91 114
        catalogItemDto.setName("name");
92
        catalogItemDto.setBibliography(Set.of("bibl"));
93
        catalogItemDto.setTypes(Set.of("type"));
94
        catalogItemDto.setAlternativeNames(Set.of("altName"));
95
        catalogItemDto.setCountries(Set.of("country"));
96
        catalogItemDto.setWrittenForms(Set.of("written"));
115
        catalogItemDto.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
116
        catalogItemDto.setTypes(Stream.of("type").collect(Collectors.toSet()));
117
        catalogItemDto.setAlternativeNames(Stream.of("altName").collect(Collectors.toSet()));
118
        catalogItemDto.setCountries(Stream.of("country").collect(Collectors.toSet()));
119
        catalogItemDto.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
97 120
        catalogItemDto.setCertainty(0);
98 121
        catalogItemDto.setLatitude(0.1);
99 122
        catalogItemDto.setLongitude(0.2);
......
102 125

  
103 126
        CatalogItem catalogItem = new CatalogItem();
104 127
        catalogItem.setName("name");
105
        catalogItem.setBibliography(Set.of(new Bibliography("bibl", catalogItem)));
106
        catalogItem.setTypes(Set.of(type));
107
        catalogItem.setAlternativeNames(Set.of(new AlternativeName("altName", catalogItem)));
108
        catalogItem.setCountries(Set.of(new Country("country", catalogItem)));
109
        catalogItem.setWrittenForms(Set.of(new WrittenForm("written", catalogItem)));
128
        catalogItem.setBibliography(Stream.of(new Bibliography("bibl", catalogItem)).collect(Collectors.toSet()));
129
        catalogItem.setTypes(Stream.of(type).collect(Collectors.toSet()));
130
        catalogItem.setAlternativeNames(Stream.of(new AlternativeName("altName", catalogItem)).collect(Collectors.toSet()));
131
        catalogItem.setCountries(Stream.of(new Country("country", catalogItem)).collect(Collectors.toSet()));
132
        catalogItem.setWrittenForms(Stream.of(new WrittenForm("written", catalogItem)).collect(Collectors.toSet()));
110 133
        catalogItem.setCertainty(0);
111 134
        catalogItem.setLatitude(0.1);
112 135
        catalogItem.setLongitude(0.2);
......
124 147

  
125 148
        CatalogItem capturedItem = argumentCaptor.getValue();
126 149

  
127
        assertThat(capturedItem).isEqualTo(catalogItem);
150
        assertThat(capturedItem.getName()).isEqualTo(catalogItem.getName());
151

  
152
        assertThat(capturedItem.getName()).isEqualTo(catalogItem.getName());
153
        assertThat(capturedItem.getCertainty()).isEqualTo(catalogItem.getCertainty());
154
        assertThat(capturedItem.getLatitude()).isEqualTo(catalogItem.getLatitude());
155
        assertThat(capturedItem.getLongitude()).isEqualTo(catalogItem.getLongitude());
156

  
157
        assertThat(capturedItem.getBibliography().size()).isEqualTo(1);
158
        assertThat(new ArrayList<>(capturedItem.getBibliography()).get(0).getSource()).isEqualTo("bibl");
159

  
160
        assertThat(capturedItem.getAlternativeNames().size()).isEqualTo(1);
161
        assertThat(new ArrayList<>(capturedItem.getAlternativeNames()).get(0).getName()).isEqualTo("altName");
162

  
163
        assertThat(capturedItem.getCountries().size()).isEqualTo(1);
164
        assertThat(new ArrayList<>(capturedItem.getCountries()).get(0).getName()).isEqualTo("country");
165
        assertThat(capturedItem.getWrittenForms().size()).isEqualTo(1);
166
        assertThat(new ArrayList<>(capturedItem.getWrittenForms()).get(0).getForm()).isEqualTo("written");
167

  
168
        assertThat(capturedItem.getTypes().size()).isEqualTo(1);
169
        assertThat(new ArrayList<>(capturedItem.getTypes()).get(0).getType()).isEqualTo("type");
128 170

  
129 171
    }
130 172

  
......
135 177

  
136 178
        CatalogItemDto catalogItemDto = new CatalogItemDto();
137 179
        catalogItemDto.setName("name");
138
        catalogItemDto.setBibliography(Set.of("bibl"));
139
        catalogItemDto.setTypes(Set.of("type"));
140
        catalogItemDto.setAlternativeNames(Set.of("altName"));
141
        catalogItemDto.setCountries(Set.of("country"));
142
        catalogItemDto.setWrittenForms(Set.of("written"));
180
        catalogItemDto.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
181
        catalogItemDto.setTypes(Stream.of("type").collect(Collectors.toSet()));
182
        catalogItemDto.setAlternativeNames(Stream.of("altName").collect(Collectors.toSet()));
183
        catalogItemDto.setCountries(Stream.of("country").collect(Collectors.toSet()));
184
        catalogItemDto.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
143 185
        catalogItemDto.setCertainty(0);
144 186
        catalogItemDto.setLatitude(0.1);
145 187
        catalogItemDto.setLongitude(0.2);
......
149 191

  
150 192
        CatalogItem catalogItem = new CatalogItem();
151 193
        catalogItem.setName("name");
152
        catalogItem.setBibliography(Set.of(new Bibliography("bibl", catalogItem)));
153
        catalogItem.setTypes(Set.of(type));
154
        catalogItem.setAlternativeNames(Set.of(new AlternativeName("altName", catalogItem)));
155
        catalogItem.setCountries(Set.of(new Country("country", catalogItem)));
156
        catalogItem.setWrittenForms(Set.of(new WrittenForm("written", catalogItem)));
194
        catalogItem.setBibliography(Stream.of(new Bibliography("bibl", catalogItem)).collect(Collectors.toSet()));
195
        catalogItem.setTypes(Stream.of(type).collect(Collectors.toSet()));
196
        catalogItem.setAlternativeNames(Stream.of(new AlternativeName("altName", catalogItem)).collect(Collectors.toSet()));
197
        catalogItem.setCountries(Stream.of(new Country("country", catalogItem)).collect(Collectors.toSet()));
198
        catalogItem.setWrittenForms(Stream.of(new WrittenForm("written", catalogItem)).collect(Collectors.toSet()));
157 199
        catalogItem.setCertainty(0);
158 200
        catalogItem.setLatitude(0.1);
159 201
        catalogItem.setLongitude(0.2);
160 202

  
161 203
        CatalogItem oldCatalogItem = new CatalogItem();
162 204
        oldCatalogItem.setName("old");
163
        oldCatalogItem.setBibliography(Set.of(new Bibliography("old", oldCatalogItem)));
164
        oldCatalogItem.setTypes(Set.of(typeOld));
165
        oldCatalogItem.setAlternativeNames(Set.of(new AlternativeName("old", oldCatalogItem)));
166
        oldCatalogItem.setCountries(Set.of(new Country("old", oldCatalogItem)));
167
        oldCatalogItem.setWrittenForms(Set.of(new WrittenForm("old", catalogItem)));
205
        oldCatalogItem.setBibliography(Stream.of(new Bibliography("old", oldCatalogItem)).collect(Collectors.toSet()));
206
        oldCatalogItem.setTypes(Stream.of(typeOld).collect(Collectors.toSet()));
207
        oldCatalogItem.setAlternativeNames(Stream.of(new AlternativeName("old", oldCatalogItem)).collect(Collectors.toSet()));
208
        oldCatalogItem.setCountries(Stream.of(new Country("old", oldCatalogItem)).collect(Collectors.toSet()));
209
        oldCatalogItem.setWrittenForms(Stream.of(new WrittenForm("old", catalogItem)).collect(Collectors.toSet()));
168 210
        oldCatalogItem.setCertainty(10);
169 211
        oldCatalogItem.setLatitude(10.1);
170 212
        oldCatalogItem.setLongitude(10.2);
......
185 227

  
186 228
        CatalogItem capturedCatalogItem = argumentCaptor.getValue();
187 229

  
188
        assertThat(capturedCatalogItem).isEqualTo(catalogItem);
230
        assertThat(capturedCatalogItem.getName()).isEqualTo(catalogItem.getName());
231
        assertThat(capturedCatalogItem.getCertainty()).isEqualTo(catalogItem.getCertainty());
232
        assertThat(capturedCatalogItem.getLatitude()).isEqualTo(catalogItem.getLatitude());
233
        assertThat(capturedCatalogItem.getLongitude()).isEqualTo(catalogItem.getLongitude());
234

  
235
        assertThat(capturedCatalogItem.getBibliography().size()).isEqualTo(1);
236
        assertThat(new ArrayList<>(capturedCatalogItem.getBibliography()).get(0).getSource()).isEqualTo("bibl");
237

  
238
        assertThat(capturedCatalogItem.getAlternativeNames().size()).isEqualTo(1);
239
        assertThat(new ArrayList<>(capturedCatalogItem.getAlternativeNames()).get(0).getName()).isEqualTo("altName");
240

  
241
        assertThat(capturedCatalogItem.getCountries().size()).isEqualTo(1);
242
        assertThat(new ArrayList<>(capturedCatalogItem.getCountries()).get(0).getName()).isEqualTo("country");
243
        assertThat(capturedCatalogItem.getWrittenForms().size()).isEqualTo(1);
244
        assertThat(new ArrayList<>(capturedCatalogItem.getWrittenForms()).get(0).getForm()).isEqualTo("written");
245

  
246
        assertThat(capturedCatalogItem.getTypes().size()).isEqualTo(1);
247
        assertThat(new ArrayList<>(capturedCatalogItem.getTypes()).get(0).getType()).isEqualTo("type");
248

  
189 249
    }
190 250

  
191 251
    @Test
......
195 255

  
196 256
        CatalogItemDto catalogItemDto = new CatalogItemDto();
197 257
        catalogItemDto.setName("name");
198
        catalogItemDto.setBibliography(Set.of("bibl"));
199
        catalogItemDto.setTypes(Set.of("type"));
200
        catalogItemDto.setAlternativeNames(Set.of("altName"));
201
        catalogItemDto.setCountries(Set.of("country"));
202
        catalogItemDto.setWrittenForms(Set.of("written"));
258
        catalogItemDto.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
259
        catalogItemDto.setTypes(Stream.of("type").collect(Collectors.toSet()));
260
        catalogItemDto.setAlternativeNames(Stream.of("altName").collect(Collectors.toSet()));
261
        catalogItemDto.setCountries(Stream.of("country").collect(Collectors.toSet()));
262
        catalogItemDto.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
203 263
        catalogItemDto.setCertainty(0);
204 264
        catalogItemDto.setLatitude(0.1);
205 265
        catalogItemDto.setLongitude(0.2);
......
243 303
    }
244 304

  
245 305
    @Test
246
    void getCatalog() {
306
    void getCatalogFiltered() {
247 307
        // given
248 308
        String name = "aaa?bb*aa";
249 309
        String country = "aaa?bb*aa";
......
256 316

  
257 317
        CatalogItem catalogItem = new CatalogItem();
258 318
        catalogItem.setName("aaacbbbbbbbaa");
259
        catalogItem.setBibliography(Set.of(new Bibliography("bibl", catalogItem)));
260
        catalogItem.setTypes(Set.of(typeEntity));
261
        catalogItem.setAlternativeNames(Set.of(new AlternativeName("altName", catalogItem)));
262
        catalogItem.setCountries(Set.of(new Country("aaaabbaa", catalogItem)));
263
        catalogItem.setWrittenForms(Set.of(new WrittenForm("written", catalogItem)));
319
        catalogItem.setBibliography(Stream.of(new Bibliography("bibl", catalogItem)).collect(Collectors.toSet()));
320
        catalogItem.setTypes(Stream.of(typeEntity).collect(Collectors.toSet()));
321
        catalogItem.setAlternativeNames(Stream.of(new AlternativeName("altName", catalogItem)).collect(Collectors.toSet()));
322
        catalogItem.setCountries(Stream.of(new Country("aaaabbaa", catalogItem)).collect(Collectors.toSet()));
323
        catalogItem.setWrittenForms(Stream.of(new WrittenForm("written", catalogItem)).collect(Collectors.toSet()));
264 324
        catalogItem.setCertainty(0);
265 325
        catalogItem.setLatitude(0.1);
266 326
        catalogItem.setLongitude(0.2);
267 327

  
268 328
        CatalogItem catalogItem2 = new CatalogItem();
269 329
        catalogItem2.setName("name");
270
        catalogItem2.setBibliography(Set.of(new Bibliography("bibl", catalogItem2)));
271
        catalogItem2.setTypes(Set.of(typeEntity));
272
        catalogItem2.setAlternativeNames(Set.of(new AlternativeName("aaaabbbbbbaa", catalogItem2)));
273
        catalogItem2.setCountries(Set.of(new Country("aaaabbcccefaa", catalogItem2)));
274
        catalogItem2.setWrittenForms(Set.of(new WrittenForm("written", catalogItem2)));
330
        catalogItem2.setBibliography(Stream.of(new Bibliography("bibl", catalogItem2)).collect(Collectors.toSet()));
331
        catalogItem2.setTypes(Stream.of(typeEntity).collect(Collectors.toSet()));
332
        catalogItem2.setAlternativeNames(Stream.of(new AlternativeName("aaaabbbbbbaa", catalogItem2)).collect(Collectors.toSet()));
333
        catalogItem2.setCountries(Stream.of(new Country("aaaabbcccefaa", catalogItem2)).collect(Collectors.toSet()));
334
        catalogItem2.setWrittenForms(Stream.of(new WrittenForm("written", catalogItem2)).collect(Collectors.toSet()));
275 335
        catalogItem2.setCertainty(1);
276 336
        catalogItem2.setLatitude(1.1);
277 337
        catalogItem2.setLongitude(1.2);
278 338

  
279 339
        CatalogItemDto catalogItemDto = new CatalogItemDto();
280 340
        catalogItemDto.setName("aaacbbbbbbbaa");
281
        catalogItemDto.setBibliography(Set.of("bibl"));
282
        catalogItemDto.setTypes(Set.of("aaa?bb*aa"));
283
        catalogItemDto.setAlternativeNames(Set.of("altName"));
284
        catalogItemDto.setCountries(Set.of("aaaabbaa"));
285
        catalogItemDto.setWrittenForms(Set.of("written"));
341
        catalogItemDto.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
342
        catalogItemDto.setTypes(Stream.of("aaa?bb*aa").collect(Collectors.toSet()));
343
        catalogItemDto.setAlternativeNames(Stream.of("altName").collect(Collectors.toSet()));
344
        catalogItemDto.setCountries(Stream.of("aaaabbaa").collect(Collectors.toSet()));
345
        catalogItemDto.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
286 346
        catalogItemDto.setCertainty(0);
287 347
        catalogItemDto.setLatitude(0.1);
288 348
        catalogItemDto.setLongitude(0.2);
289 349

  
290 350
        CatalogItemDto catalogItemDto2 = new CatalogItemDto();
291 351
        catalogItemDto2.setName("name");
292
        catalogItemDto2.setBibliography(Set.of("bibl"));
293
        catalogItemDto2.setTypes(Set.of("aaa?bb*aa"));
294
        catalogItemDto2.setAlternativeNames(Set.of("aaaabbbbbbaa"));
295
        catalogItemDto2.setCountries(Set.of("aaaabbcccefaa"));
296
        catalogItemDto2.setWrittenForms(Set.of("written"));
352
        catalogItemDto2.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
353
        catalogItemDto2.setTypes(Stream.of("aaa?bb*aa").collect(Collectors.toSet()));
354
        catalogItemDto2.setAlternativeNames(Stream.of("aaaabbbbbbaa").collect(Collectors.toSet()));
355
        catalogItemDto2.setCountries(Stream.of("aaaabbcccefaa").collect(Collectors.toSet()));
356
        catalogItemDto2.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
297 357
        catalogItemDto2.setCertainty(1);
298 358
        catalogItemDto2.setLatitude(1.1);
299 359
        catalogItemDto2.setLongitude(1.2);
300 360

  
301
        given(catalogItemRepository.filterCatalog(nameChanged, countryChanged, typeChanged)).willReturn(Set.of(catalogItem, catalogItem2));
361
        given(catalogItemRepository.filterCatalog(nameChanged, countryChanged, typeChanged)).willReturn(Stream.of(catalogItem, catalogItem2).collect(Collectors.toList()));
302 362

  
303 363
        // when
304 364
        List<CatalogItemDto> results = underTest.getCatalog(name, country, type);
......
309 369
        assertTrue(results.contains(catalogItemDto2));
310 370

  
311 371
        verify(catalogItemRepository).filterCatalog(nameChanged, countryChanged, typeChanged);
372
        verify(catalogItemRepository, never()).findAll();
373
    }
374

  
375
    @Test
376
    void getWholeCatalog() {
377
        // given
378
        String name = "";
379
        String country = "";
380
        String type = "";
381

  
382
        Type typeEntity = new Type("aaa?bb*aa");
383

  
384
        CatalogItem catalogItem = new CatalogItem();
385
        catalogItem.setName("aaacbbbbbbbaa");
386
        catalogItem.setBibliography(Stream.of(new Bibliography("bibl", catalogItem)).collect(Collectors.toSet()));
387
        catalogItem.setTypes(Stream.of(typeEntity).collect(Collectors.toSet()));
388
        catalogItem.setAlternativeNames(Stream.of(new AlternativeName("altName", catalogItem)).collect(Collectors.toSet()));
389
        catalogItem.setCountries(Stream.of(new Country("aaaabbaa", catalogItem)).collect(Collectors.toSet()));
390
        catalogItem.setWrittenForms(Stream.of(new WrittenForm("written", catalogItem)).collect(Collectors.toSet()));
391
        catalogItem.setCertainty(0);
392
        catalogItem.setLatitude(0.1);
393
        catalogItem.setLongitude(0.2);
394

  
395
        CatalogItem catalogItem2 = new CatalogItem();
396
        catalogItem2.setName("name");
397
        catalogItem2.setBibliography(Stream.of(new Bibliography("bibl", catalogItem2)).collect(Collectors.toSet()));
398
        catalogItem2.setTypes(Stream.of(typeEntity).collect(Collectors.toSet()));
399
        catalogItem2.setAlternativeNames(Stream.of(new AlternativeName("aaaabbbbbbaa", catalogItem2)).collect(Collectors.toSet()));
400
        catalogItem2.setCountries(Stream.of(new Country("aaaabbcccefaa", catalogItem2)).collect(Collectors.toSet()));
401
        catalogItem2.setWrittenForms(Stream.of(new WrittenForm("written", catalogItem2)).collect(Collectors.toSet()));
402
        catalogItem2.setCertainty(1);
403
        catalogItem2.setLatitude(1.1);
404
        catalogItem2.setLongitude(1.2);
405

  
406
        CatalogItemDto catalogItemDto = new CatalogItemDto();
407
        catalogItemDto.setName("aaacbbbbbbbaa");
408
        catalogItemDto.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
409
        catalogItemDto.setTypes(Stream.of("aaa?bb*aa").collect(Collectors.toSet()));
410
        catalogItemDto.setAlternativeNames(Stream.of("altName").collect(Collectors.toSet()));
411
        catalogItemDto.setCountries(Stream.of("aaaabbaa").collect(Collectors.toSet()));
412
        catalogItemDto.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
413
        catalogItemDto.setCertainty(0);
414
        catalogItemDto.setLatitude(0.1);
415
        catalogItemDto.setLongitude(0.2);
416

  
417
        CatalogItemDto catalogItemDto2 = new CatalogItemDto();
418
        catalogItemDto2.setName("name");
419
        catalogItemDto2.setBibliography(Stream.of("bibl").collect(Collectors.toSet()));
420
        catalogItemDto2.setTypes(Stream.of("aaa?bb*aa").collect(Collectors.toSet()));
421
        catalogItemDto2.setAlternativeNames(Stream.of("aaaabbbbbbaa").collect(Collectors.toSet()));
422
        catalogItemDto2.setCountries(Stream.of("aaaabbcccefaa").collect(Collectors.toSet()));
423
        catalogItemDto2.setWrittenForms(Stream.of("written").collect(Collectors.toSet()));
424
        catalogItemDto2.setCertainty(1);
425
        catalogItemDto2.setLatitude(1.1);
426
        catalogItemDto2.setLongitude(1.2);
427

  
428
        given(catalogItemRepository.findAll()).willReturn(Stream.of(catalogItem, catalogItem2).collect(Collectors.toList()));
429

  
430
        // when
431
        List<CatalogItemDto> results = underTest.getCatalog(name, country, type);
432

  
433
        // then
434
        assertThat(results.size()).isEqualTo(2);
435
        assertTrue(results.contains(catalogItemDto));
436
        assertTrue(results.contains(catalogItemDto2));
437

  
438
        verify(catalogItemRepository).findAll();
439
        verify(catalogItemRepository, never()).filterCatalog(anyString(), anyString(), anyString());
312 440
    }
313 441
}

Také k dispozici: Unified diff