Revize cf12d561
Přidáno uživatelem Jakub Šmíd před asi 2 roky(ů)
backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplFilterTest.java | ||
---|---|---|
1 | 1 |
package cz.zcu.kiv.backendapi.catalog; |
2 | 2 |
|
3 |
import cz.zcu.kiv.backendapi.alternativename.AlternativeName;
|
|
3 |
import cz.zcu.kiv.backendapi.alternativename.CatalogItemName;
|
|
4 | 4 |
import cz.zcu.kiv.backendapi.country.Country; |
5 | 5 |
import cz.zcu.kiv.backendapi.type.Type; |
6 | 6 |
import cz.zcu.kiv.backendapi.type.TypeServiceImpl; |
... | ... | |
11 | 11 |
import org.mockito.Mock; |
12 | 12 |
import org.mockito.junit.jupiter.MockitoExtension; |
13 | 13 |
|
14 |
import java.util.Collections;
|
|
14 |
import java.util.LinkedHashSet;
|
|
15 | 15 |
import java.util.List; |
16 |
import java.util.Set; |
|
17 | 16 |
import java.util.UUID; |
17 |
import java.util.stream.Collectors; |
|
18 |
import java.util.stream.Stream; |
|
18 | 19 |
|
19 | 20 |
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
20 | 21 |
import static org.junit.jupiter.api.Assertions.assertTrue; |
... | ... | |
92 | 93 |
catalogItem5.setId(catalogItemId5); |
93 | 94 |
|
94 | 95 |
catalogItem1.setName(nameFirst); |
95 |
catalogItem1.setTypes(Set.of(typeCountry, typeCity));
|
|
96 |
catalogItem1.setCountries(Set.of(new Country(countryAaa, catalogItem1), new Country(countryDcd, catalogItem1)));
|
|
97 |
catalogItem1.setWrittenForms(Set.of(new WrittenForm(writtenForm, catalogItem1)));
|
|
96 |
catalogItem1.setTypes(Stream.of(typeCountry, typeCity).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
97 |
catalogItem1.setCountries(Stream.of(new Country(countryAaa, catalogItem1, 1), new Country(countryDcd, catalogItem1, 2)).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
98 |
catalogItem1.setWrittenForms(Stream.of(new WrittenForm(writtenForm, catalogItem1, 1)).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
98 | 99 |
|
99 |
catalogItemDto1 = new CatalogItemDto(catalogItemId1, nameFirst, Collections.emptySet(), Set.of(writtenForm), Set.of(country, city), Set.of(countryAaa, countryDcd), Collections.emptySet(), null, null, null, ""); |
|
100 |
catalogItemDto1 = new CatalogItemDto(catalogItemId1, nameFirst, new LinkedHashSet<>(), Stream.of(writtenForm).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
101 |
Stream.of(country, city).collect(Collectors.toCollection(LinkedHashSet::new)), Stream.of(countryAaa, countryDcd).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
102 |
new LinkedHashSet<>(), null, null, null, ""); |
|
100 | 103 |
|
101 | 104 |
catalogItem2.setName(nameSecond); |
102 |
catalogItem2.setAlternativeNames(Set.of(new AlternativeName(nameTwelve, catalogItem2), new AlternativeName(nameThird, catalogItem2)));
|
|
103 |
catalogItem2.setTypes(Set.of(typeCountry, typeCityUpper));
|
|
104 |
catalogItem2.setCountries(Set.of(new Country(countryAaa, catalogItem2), new Country(countryBbb, catalogItem2)));
|
|
105 |
catalogItem2.setWrittenForms(Set.of(new WrittenForm(writtenFormUpper, catalogItem2)));
|
|
105 |
catalogItem2.setAllNames(Stream.of(new CatalogItemName(nameTwelve, catalogItem2, 1), new CatalogItemName(nameThird, catalogItem2, 2)).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
106 |
catalogItem2.setTypes(Stream.of(typeCountry, typeCityUpper).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
107 |
catalogItem2.setCountries(Stream.of(new Country(countryAaa, catalogItem2, 1), new Country(countryBbb, catalogItem2, 2)).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
108 |
catalogItem2.setWrittenForms(Stream.of(new WrittenForm(writtenFormUpper, catalogItem2, 1)).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
106 | 109 |
|
107 |
catalogItemDto2 = new CatalogItemDto(catalogItemId2, nameSecond, Set.of(nameTwelve, nameThird), Set.of(writtenFormUpper), Set.of(country, cityUpper), Set.of(countryAaa, countryBbb), Collections.emptySet(), null, null, null, ""); |
|
110 |
catalogItemDto2 = new CatalogItemDto(catalogItemId2, nameSecond, Stream.of(nameTwelve, nameThird).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
111 |
Stream.of(writtenFormUpper).collect(Collectors.toCollection(LinkedHashSet::new)), Stream.of(country, cityUpper).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
112 |
Stream.of(countryAaa, countryBbb).collect(Collectors.toCollection(LinkedHashSet::new)), new LinkedHashSet<>(), |
|
113 |
null, null, null, ""); |
|
108 | 114 |
|
109 | 115 |
catalogItem3.setName(nameThird); |
110 |
catalogItem3.setAlternativeNames(Set.of(new AlternativeName(nameTwentyUpper, catalogItem3), new AlternativeName(nameSedond, catalogItem3))); |
|
111 |
catalogItem3.setTypes(Set.of(typeCountri, typeCapitalCity)); |
|
112 |
catalogItem3.setCountries(Set.of(new Country(countryAaaUpper, catalogItem3), new Country(countryCcc, catalogItem3))); |
|
113 |
catalogItem3.setWrittenForms(Set.of(new WrittenForm(writtenFormForOr, catalogItem3))); |
|
114 |
|
|
115 |
catalogItemDto3 = new CatalogItemDto(catalogItemId3, nameThird, Set.of(nameTwentyUpper, nameSedond), Set.of(writtenFormForOr), Set.of(countri, capitalCityNew), Set.of(countryAaaUpper, countryCcc), Collections.emptySet(), null, null, null, ""); |
|
116 |
|
|
117 |
catalogItem4.setAlternativeNames(Set.of(new AlternativeName(nameTwelve, catalogItem4), new AlternativeName(nameFirstUpper, catalogItem4))); |
|
118 |
catalogItem4.setTypes(Set.of(typeCountri, typeCountry)); |
|
119 |
catalogItem4.setCountries(Set.of(new Country(countryBccb, catalogItem4), new Country(countryDdd, catalogItem4))); |
|
120 |
catalogItem4.setWrittenForms(Set.of(new WrittenForm(writtenForm, catalogItem4), new WrittenForm(writtenFormForOr, catalogItem4))); |
|
121 |
|
|
122 |
catalogItemDto4 = new CatalogItemDto(catalogItemId4, "", Set.of(nameTwelve, nameFirstUpper), Set.of(writtenForm, writtenFormForOr), Set.of(countri, country), Set.of(countryBccb, countryDdd), Collections.emptySet(), null, null, null, ""); |
|
116 |
catalogItem3.setAllNames(Stream.of(new CatalogItemName(nameTwentyUpper, catalogItem3, 1), new CatalogItemName(nameSedond, catalogItem3, 2)).collect(Collectors.toCollection(LinkedHashSet::new))); |
|
117 |
catalogItem3.setTypes(Stream.of(typeCountri, typeCapitalCity).collect(Collectors.toCollection(LinkedHashSet::new))); |
|
118 |
catalogItem3.setCountries(Stream.of(new Country(countryAaaUpper, catalogItem3, 1), new Country(countryCcc, catalogItem3, 2)).collect(Collectors.toCollection(LinkedHashSet::new))); |
|
119 |
catalogItem3.setWrittenForms(Stream.of(new WrittenForm(writtenFormForOr, catalogItem3, 1)).collect(Collectors.toCollection(LinkedHashSet::new))); |
|
120 |
|
|
121 |
catalogItemDto3 = new CatalogItemDto(catalogItemId3, nameThird, Stream.of(nameTwentyUpper, nameSedond).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
122 |
Stream.of(writtenFormForOr).collect(Collectors.toCollection(LinkedHashSet::new)), Stream.of(countri, capitalCityNew).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
123 |
Stream.of(countryAaaUpper, countryCcc).collect(Collectors.toCollection(LinkedHashSet::new)), new LinkedHashSet<>(), |
|
124 |
null, null, null, ""); |
|
125 |
|
|
126 |
catalogItem4.setAllNames(Stream.of(new CatalogItemName(nameTwelve, catalogItem4, 1), new CatalogItemName(nameFirstUpper, catalogItem4, 2)).collect(Collectors.toCollection(LinkedHashSet::new))); |
|
127 |
catalogItem4.setTypes(Stream.of(typeCountri, typeCountry).collect(Collectors.toCollection(LinkedHashSet::new))); |
|
128 |
catalogItem4.setCountries(Stream.of(new Country(countryBccb, catalogItem4, 1), new Country(countryDdd, catalogItem4, 2)).collect(Collectors.toCollection(LinkedHashSet::new))); |
|
129 |
catalogItem4.setWrittenForms(Stream.of(new WrittenForm(writtenForm, catalogItem4, 1), new WrittenForm(writtenFormForOr, catalogItem4, 2)).collect(Collectors.toCollection(LinkedHashSet::new))); |
|
130 |
|
|
131 |
catalogItemDto4 = new CatalogItemDto(catalogItemId4, "", Stream.of(nameTwelve, nameFirstUpper).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
132 |
Stream.of(writtenForm, writtenFormForOr).collect(Collectors.toCollection(LinkedHashSet::new)), Stream.of(countri, country).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
133 |
Stream.of(countryBccb, countryDdd).collect(Collectors.toCollection(LinkedHashSet::new)), new LinkedHashSet<>(), |
|
134 |
null, null, null, ""); |
|
123 | 135 |
|
124 | 136 |
catalogItem5.setName(nameSedond); |
125 |
catalogItem5.setAlternativeNames(Set.of(new AlternativeName(nameThird, catalogItem5)));
|
|
126 |
catalogItem5.setTypes(Set.of(typeCountri));
|
|
137 |
catalogItem5.setAllNames(Stream.of(new CatalogItemName(nameThird, catalogItem5, 1)).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
138 |
catalogItem5.setTypes(Stream.of(typeCountri).collect(Collectors.toCollection(LinkedHashSet::new)));
|
|
127 | 139 |
|
128 |
catalogItemDto5 = new CatalogItemDto(catalogItemId5, nameSedond, Set.of(nameThird), Collections.emptySet(), Set.of(countri), Collections.emptySet(), Collections.emptySet(), null, null, null, ""); |
|
140 |
catalogItemDto5 = new CatalogItemDto(catalogItemId5, nameSedond, Stream.of(nameThird).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
141 |
new LinkedHashSet<>(), Stream.of(countri).collect(Collectors.toCollection(LinkedHashSet::new)), |
|
142 |
new LinkedHashSet<>(), new LinkedHashSet<>(), |
|
143 |
null, null, null, ""); |
|
129 | 144 |
|
130 | 145 |
given(catalogItemRepository.findAll()).willReturn(List.of(catalogItem1, catalogItem2, catalogItem3, catalogItem4, catalogItem5)); |
131 | 146 |
} |
Také k dispozici: Unified diff
Catalog change
- one-to-many associations now persist order
- text for search persists separators
re #9751
re #9754