commit a8335530daf4b3c540250c026a91c2766fc66769
Author: Jakub Smid <jaksmid@seznam.cz>
Date:   Sat Apr 23 09:15:47 2022 +0200

    Test cases added
    
    re #9492

diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/alternativename/AlternativeNameRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/alternativename/AlternativeNameRepository.java
deleted file mode 100644
index bbb7cf3..0000000
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/alternativename/AlternativeNameRepository.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cz.zcu.kiv.backendapi.alternativename;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * Alternative name repository
- */
-@Repository
-public interface AlternativeNameRepository extends JpaRepository<AlternativeName, AlternativeName> {
-}
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/BibliographyRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/BibliographyRepository.java
deleted file mode 100644
index cebbae0..0000000
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/BibliographyRepository.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cz.zcu.kiv.backendapi.bibliography;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * Bibliography repository
- */
-@Repository
-public interface BibliographyRepository extends JpaRepository<Bibliography, Bibliography> {
-}
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
index 8e1ea01..6056c13 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
@@ -28,16 +28,16 @@ import java.util.stream.Collectors;
 @EqualsAndHashCode(onlyExplicitlyIncluded = true)
 @NoArgsConstructor
 @Entity
-@Table(name = "catalog_item")
+@Table(name = "catalog_items")
 public class CatalogItem {
     private static final String INTEGER_PATTERN = "\\d+";
     private static final String DOUBLE_PATTERN = "(\\d+[.]\\d+)|(\\d+)";
     private static final String EMPTY_ENTRY = "–";
+
     /**
      * Catalog item id
      */
     @Id
-//    @GeneratedValue
     @EqualsAndHashCode.Include
     private UUID id = UUID.randomUUID();
 
@@ -70,7 +70,7 @@ public class CatalogItem {
     /**
      * Bibliography
      */
-    @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL)
+    @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true)
     @LazyCollection(LazyCollectionOption.FALSE)
     @Fetch(FetchMode.SUBSELECT)
     private Set<Bibliography> bibliography = new HashSet<>();
@@ -78,7 +78,7 @@ public class CatalogItem {
     /**
      * Countries
      */
-    @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL)
+    @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true)
     @LazyCollection(LazyCollectionOption.FALSE)
     @Fetch(FetchMode.SUBSELECT)
     private Set<Country> countries = new HashSet<>();
@@ -86,7 +86,7 @@ public class CatalogItem {
     /**
      * Written forms
      */
-    @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL)
+    @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true)
     @LazyCollection(LazyCollectionOption.FALSE)
     @Fetch(FetchMode.SUBSELECT)
     private Set<WrittenForm> writtenForms = new HashSet<>();
@@ -94,7 +94,7 @@ public class CatalogItem {
     /**
      * Alternative names
      */
-    @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL)
+    @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true)
     @LazyCollection(LazyCollectionOption.FALSE)
     @Fetch(FetchMode.SUBSELECT)
     private Set<AlternativeName> alternativeNames = new HashSet<>();
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/country/CountryRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/country/CountryRepository.java
deleted file mode 100644
index 408b381..0000000
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/country/CountryRepository.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cz.zcu.kiv.backendapi.country;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * Country repository
- */
-@Repository
-public interface CountryRepository extends JpaRepository<Country, Country> {
-}
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/security/jwt/JwtUsernameAndPasswordAuthenticationFilter.java b/backend/src/main/java/cz/zcu/kiv/backendapi/security/jwt/JwtUsernameAndPasswordAuthenticationFilter.java
index b294492..bdb9b36 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/security/jwt/JwtUsernameAndPasswordAuthenticationFilter.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/security/jwt/JwtUsernameAndPasswordAuthenticationFilter.java
@@ -53,8 +53,6 @@ public class JwtUsernameAndPasswordAuthenticationFilter extends UsernamePassword
         try {
             UsernameAndPasswordAuthenticationRequest authenticationRequest = new ObjectMapper()
                     .readValue(request.getInputStream(), UsernameAndPasswordAuthenticationRequest.class);
-            log.info("Username is: " + authenticationRequest.getUsername());
-            log.info("Password is: " + authenticationRequest.getPassword());
             Authentication authentication = new UsernamePasswordAuthenticationToken(
                     authenticationRequest.getUsername(),
                     authenticationRequest.getPassword()
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenFormRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenFormRepository.java
deleted file mode 100644
index 6089d08..0000000
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenFormRepository.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cz.zcu.kiv.backendapi.writtenform;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * Written form repository
- */
-@Repository
-public interface WrittenFormRepository extends JpaRepository<WrittenForm, WrittenForm> {
-}
diff --git a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemRepositoryTest.java b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemRepositoryTest.java
index 3ed4930..e3c7f20 100644
--- a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemRepositoryTest.java
+++ b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemRepositoryTest.java
@@ -1,8 +1,6 @@
 package cz.zcu.kiv.backendapi.catalog;
 
 import cz.zcu.kiv.backendapi.alternativename.AlternativeName;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
@@ -19,14 +17,9 @@ class CatalogItemRepositoryTest {
     @Autowired
     private CatalogItemRepository underTest;
 
-    private CatalogItem catalogItem1;
-    private CatalogItem catalogItem2;
-    private CatalogItem catalogItem3;
-    private CatalogItem catalogItem4;
-    private CatalogItem catalogItem5;
-
-    @BeforeEach
-    void setUp() {
+    @Test
+    void testItemsByName() {
+        // given
         String nameFirst = "first";
         String nameFirstUpper = "First";
         String nameSecond = "second";
@@ -35,11 +28,11 @@ class CatalogItemRepositoryTest {
         String nameTwelve = "twelve";
         String nameTwentyUpper = "TWENTY";
 
-        catalogItem1 = new CatalogItem();
-        catalogItem2 = new CatalogItem();
-        catalogItem3 = new CatalogItem();
-        catalogItem4 = new CatalogItem();
-        catalogItem5 = new CatalogItem();
+        CatalogItem catalogItem1 = new CatalogItem();
+        CatalogItem catalogItem2 = new CatalogItem();
+        CatalogItem catalogItem3 = new CatalogItem();
+        CatalogItem catalogItem4 = new CatalogItem();
+        CatalogItem catalogItem5 = new CatalogItem();
 
         catalogItem1.setName(nameFirst);
 
@@ -57,16 +50,6 @@ class CatalogItemRepositoryTest {
         underTest.saveAll(List.of(catalogItem1, catalogItem2, catalogItem3, catalogItem4, catalogItem5));
 
 
-    }
-
-    @AfterEach
-    void tearDown() {
-        underTest.deleteAll();
-    }
-
-    @Test
-    void testItemsByName() {
-        // given
         String name = "twelve";
 
         // when
diff --git a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplFilterTest.java b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplFilterTest.java
new file mode 100644
index 0000000..fcda0bc
--- /dev/null
+++ b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplFilterTest.java
@@ -0,0 +1,474 @@
+package cz.zcu.kiv.backendapi.catalog;
+
+import cz.zcu.kiv.backendapi.alternativename.AlternativeName;
+import cz.zcu.kiv.backendapi.country.Country;
+import cz.zcu.kiv.backendapi.type.Type;
+import cz.zcu.kiv.backendapi.type.TypeServiceImpl;
+import cz.zcu.kiv.backendapi.writtenform.WrittenForm;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.verify;
+
+@ExtendWith(MockitoExtension.class)
+class CatalogItemServiceImplFilterTest {
+    @Mock
+    private CatalogItemRepository catalogItemRepository;
+
+    @Mock
+    private TypeServiceImpl typeService;
+
+    private CatalogItemServiceImpl underTest;
+
+    private CatalogItemDto catalogItemDto1;
+    private CatalogItemDto catalogItemDto2;
+    private CatalogItemDto catalogItemDto3;
+    private CatalogItemDto catalogItemDto4;
+    private CatalogItemDto catalogItemDto5;
+
+    @BeforeEach
+    void setUp() {
+        underTest = new CatalogItemServiceImpl(catalogItemRepository, typeService);
+        // given
+        String country = "country";
+        String city = "city";
+        String capitalCityNew = "capital city new";
+        String cityUpper = "City";
+        String countri = "countri";
+
+        Type typeCountry = new Type(country);
+        Type typeCity = new Type(city);
+        Type typeCapitalCity = new Type(capitalCityNew);
+        Type typeCityUpper = new Type(cityUpper);
+        Type typeCountri = new Type(countri);
+
+        String nameFirst = "first";
+        String nameFirstUpper = "First";
+        String nameSecond = "second";
+        String nameSedond = "sedond";
+        String nameThird = "third";
+        String nameTwelve = "twelve";
+        String nameTwentyUpper = "TWENTY";
+
+        String countryAaa = "aaa";
+        String countryAaaUpper = "AAA";
+        String countryBbb = "bbb";
+        String countryBccb = "bccb";
+        String countryCcc = "ccc";
+        String countryDdd = "ddd";
+        String countryDcd = "dcd";
+
+        String writtenForm = "written";
+        String writtenFormUpper = "WRITTEN";
+        String writtenFormForOr = "wratten";
+
+        CatalogItem catalogItem1 = new CatalogItem();
+        CatalogItem catalogItem2 = new CatalogItem();
+        CatalogItem catalogItem3 = new CatalogItem();
+        CatalogItem catalogItem4 = new CatalogItem();
+        CatalogItem catalogItem5 = new CatalogItem();
+
+        UUID catalogItemId1 = UUID.randomUUID();
+        UUID catalogItemId2 = UUID.randomUUID();
+        UUID catalogItemId3 = UUID.randomUUID();
+        UUID catalogItemId4 = UUID.randomUUID();
+        UUID catalogItemId5 = UUID.randomUUID();
+
+        catalogItem1.setId(catalogItemId1);
+        catalogItem2.setId(catalogItemId2);
+        catalogItem3.setId(catalogItemId3);
+        catalogItem4.setId(catalogItemId4);
+        catalogItem5.setId(catalogItemId5);
+
+        catalogItem1.setName(nameFirst);
+        catalogItem1.setTypes(Set.of(typeCountry, typeCity));
+        catalogItem1.setCountries(Set.of(new Country(countryAaa, catalogItem1), new Country(countryDcd, catalogItem1)));
+        catalogItem1.setWrittenForms(Set.of(new WrittenForm(writtenForm, catalogItem1)));
+
+        catalogItemDto1 = new CatalogItemDto(catalogItemId1, nameFirst, Collections.emptySet(), Set.of(writtenForm), Set.of(country, city), Set.of(countryAaa, countryDcd), Collections.emptySet(), 0.0, 0.0, 0, "");
+
+        catalogItem2.setName(nameSecond);
+        catalogItem2.setAlternativeNames(Set.of(new AlternativeName(nameTwelve, catalogItem2), new AlternativeName(nameThird, catalogItem2)));
+        catalogItem2.setTypes(Set.of(typeCountry, typeCityUpper));
+        catalogItem2.setCountries(Set.of(new Country(countryAaa, catalogItem2), new Country(countryBbb, catalogItem2)));
+        catalogItem2.setWrittenForms(Set.of(new WrittenForm(writtenFormUpper, catalogItem2)));
+
+        catalogItemDto2 = new CatalogItemDto(catalogItemId2, nameSecond, Set.of(nameTwelve, nameThird), Set.of(writtenFormUpper), Set.of(country, cityUpper), Set.of(countryAaa, countryBbb), Collections.emptySet(), 0.0, 0.0, 0, "");
+
+        catalogItem3.setName(nameThird);
+        catalogItem3.setAlternativeNames(Set.of(new AlternativeName(nameTwentyUpper, catalogItem3), new AlternativeName(nameSedond, catalogItem3)));
+        catalogItem3.setTypes(Set.of(typeCountri, typeCapitalCity));
+        catalogItem3.setCountries(Set.of(new Country(countryAaaUpper, catalogItem3), new Country(countryCcc, catalogItem3)));
+        catalogItem3.setWrittenForms(Set.of(new WrittenForm(writtenFormForOr, catalogItem3)));
+
+        catalogItemDto3 = new CatalogItemDto(catalogItemId3, nameThird, Set.of(nameTwentyUpper, nameSedond), Set.of(writtenFormForOr), Set.of(countri, capitalCityNew), Set.of(countryAaaUpper, countryCcc), Collections.emptySet(), 0.0, 0.0, 0, "");
+
+        catalogItem4.setAlternativeNames(Set.of(new AlternativeName(nameTwelve, catalogItem4), new AlternativeName(nameFirstUpper, catalogItem4)));
+        catalogItem4.setTypes(Set.of(typeCountri, typeCountry));
+        catalogItem4.setCountries(Set.of(new Country(countryBccb, catalogItem4), new Country(countryDdd, catalogItem4)));
+        catalogItem4.setWrittenForms(Set.of(new WrittenForm(writtenForm, catalogItem4), new WrittenForm(writtenFormForOr, catalogItem4)));
+
+        catalogItemDto4 = new CatalogItemDto(catalogItemId4, "", Set.of(nameTwelve, nameFirstUpper), Set.of(writtenForm, writtenFormForOr), Set.of(countri, country), Set.of(countryBccb, countryDdd), Collections.emptySet(), 0.0, 0.0, 0, "");
+
+        catalogItem5.setName(nameSedond);
+        catalogItem5.setAlternativeNames(Set.of(new AlternativeName(nameThird, catalogItem5)));
+        catalogItem5.setTypes(Set.of(typeCountri));
+
+        catalogItemDto5 = new CatalogItemDto(catalogItemId5, nameSedond, Set.of(nameThird), Collections.emptySet(), Set.of(countri), Collections.emptySet(), Collections.emptySet(), 0.0, 0.0, 0, "");
+
+        given(catalogItemRepository.findAll()).willReturn(List.of(catalogItem1, catalogItem2, catalogItem3, catalogItem4, catalogItem5));
+    }
+
+    @Test
+    void itShouldReturnAll() {
+        // given
+        String name = "";
+        String country = "";
+        String type = "";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> results = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(results.size()).isEqualTo(5);
+        assertTrue(results.contains(catalogItemDto1));
+        assertTrue(results.contains(catalogItemDto2));
+        assertTrue(results.contains(catalogItemDto3));
+        assertTrue(results.contains(catalogItemDto4));
+        assertTrue(results.contains(catalogItemDto5));
+
+        verify(catalogItemRepository).findAll();
+    }
+
+    @Test
+    void testName() {
+        // given
+        String name = "first";
+        String country = "";
+        String type = "";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(2);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testWildcardCharacterName() {
+        // given
+        String name = "se?ond";
+        String country = "";
+        String type = "";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(3);
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto3));
+        assertTrue(filterResult.contains(catalogItemDto5));
+    }
+
+    @Test
+    void testWildcardCharactersName() {
+        // given
+        String name = "twe*";
+        String country = "";
+        String type = "";
+        String writtenForm = "";
+
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(3);
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto3));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testCountry() {
+        // given
+        String name = "";
+        String country = "aaa";
+        String type = "";
+        String writtenForm = "";
+
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(3);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto3));
+    }
+
+    @Test
+    void testWildcardCharacterCountry() {
+        // given
+        String name = "";
+        String country = "d?d";
+        String type = "";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(2);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testWildcardCharactersCountry() {
+        // given
+        String name = "";
+        String country = "b*b";
+        String type = "";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(2);
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+
+    @Test
+    void testType() {
+        // given
+        String name = "";
+        String country = "";
+        String type = "city";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(2);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto2));
+    }
+
+    @Test
+    void testWildcardCharacterType() {
+        // given
+        String name = "";
+        String country = "";
+        String type = "countr?";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(5);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto3));
+        assertTrue(filterResult.contains(catalogItemDto4));
+        assertTrue(filterResult.contains(catalogItemDto5));
+    }
+
+    @Test
+    void testWildcardCharactersType() {
+        // given
+        String name = "";
+        String country = "";
+        String type = "*city*";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(3);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto3));
+    }
+
+    @Test
+    void testWrittenForm() {
+        // given
+        String name = "";
+        String country = "";
+        String type = "";
+        String writtenForm = "written";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(3);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testWrittenFormWildcardCharacter() {
+        // given
+        String name = "";
+        String country = "";
+        String type = "";
+        String writtenForm = "wr?tten";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(4);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto3));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testWrittenFormWildcardCharacters() {
+        // given
+        String name = "";
+        String country = "";
+        String type = "";
+        String writtenForm = "wri*tten";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(3);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testWrittenFormOr() {
+        // given
+        String name = "";
+        String country = "";
+        String type = "";
+        String writtenForm = "wr(i|a)tten";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(4);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto3));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testNameAndCountry() {
+        // given
+        String name = "third";
+        String country = "aaa";
+        String type = "";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(2);
+        assertTrue(filterResult.contains(catalogItemDto2));
+        assertTrue(filterResult.contains(catalogItemDto3));
+    }
+
+    @Test
+    void testNameAndType() {
+        // given
+        String name = "third";
+        String country = "";
+        String type = "countri";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(2);
+        assertTrue(filterResult.contains(catalogItemDto3));
+        assertTrue(filterResult.contains(catalogItemDto5));
+    }
+
+    @Test
+    void testNameAndWrittenForm() {
+        // given
+        String name = "first";
+        String country = "";
+        String type = "";
+        String writtenForm = "written";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(2);
+        assertTrue(filterResult.contains(catalogItemDto1));
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testCountryAndType() {
+        // given
+        String name = "";
+        String country = "ddd";
+        String type = "country";
+        String writtenForm = "";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(1);
+        assertTrue(filterResult.contains(catalogItemDto4));
+    }
+
+    @Test
+    void testAll() {
+        // given
+        String name = "third";
+        String country = "AAA";
+        String type = "countri";
+        String writtenForm = "wratten";
+
+        // when
+        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
+
+        // then
+        assertThat(filterResult.size()).isEqualTo(1);
+        assertTrue(filterResult.contains(catalogItemDto3));
+    }
+}
\ No newline at end of file
diff --git a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplTest2.java b/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplTest2.java
deleted file mode 100644
index 8e32a25..0000000
--- a/backend/src/test/java/cz/zcu/kiv/backendapi/catalog/CatalogItemServiceImplTest2.java
+++ /dev/null
@@ -1,474 +0,0 @@
-package cz.zcu.kiv.backendapi.catalog;
-
-import cz.zcu.kiv.backendapi.alternativename.AlternativeName;
-import cz.zcu.kiv.backendapi.country.Country;
-import cz.zcu.kiv.backendapi.type.Type;
-import cz.zcu.kiv.backendapi.type.TypeServiceImpl;
-import cz.zcu.kiv.backendapi.writtenform.WrittenForm;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.verify;
-
-@ExtendWith(MockitoExtension.class)
-class CatalogItemServiceImplTest2 {
-    @Mock
-    private CatalogItemRepository catalogItemRepository;
-
-    @Mock
-    private TypeServiceImpl typeService;
-
-    private CatalogItemServiceImpl underTest;
-
-    private CatalogItemDto catalogItemDto1;
-    private CatalogItemDto catalogItemDto2;
-    private CatalogItemDto catalogItemDto3;
-    private CatalogItemDto catalogItemDto4;
-    private CatalogItemDto catalogItemDto5;
-
-    @BeforeEach
-    void setUp() {
-        underTest = new CatalogItemServiceImpl(catalogItemRepository, typeService);
-        // given
-        String country = "country";
-        String city = "city";
-        String capitalCityNew = "capital city new";
-        String cityUpper = "City";
-        String countri = "countri";
-
-        Type typeCountry = new Type(country);
-        Type typeCity = new Type(city);
-        Type typeCapitalCity = new Type(capitalCityNew);
-        Type typeCityUpper = new Type(cityUpper);
-        Type typeCountri = new Type(countri);
-
-        String nameFirst = "first";
-        String nameFirstUpper = "First";
-        String nameSecond = "second";
-        String nameSedond = "sedond";
-        String nameThird = "third";
-        String nameTwelve = "twelve";
-        String nameTwentyUpper = "TWENTY";
-
-        String countryAaa = "aaa";
-        String countryAaaUpper = "AAA";
-        String countryBbb = "bbb";
-        String countryBccb = "bccb";
-        String countryCcc = "ccc";
-        String countryDdd = "ddd";
-        String countryDcd = "dcd";
-
-        String writtenForm = "written";
-        String writtenFormUpper = "WRITTEN";
-        String writtenFormForOr = "wratten";
-
-        CatalogItem catalogItem1 = new CatalogItem();
-        CatalogItem catalogItem2 = new CatalogItem();
-        CatalogItem catalogItem3 = new CatalogItem();
-        CatalogItem catalogItem4 = new CatalogItem();
-        CatalogItem catalogItem5 = new CatalogItem();
-
-        UUID catalogItemId1 = UUID.randomUUID();
-        UUID catalogItemId2 = UUID.randomUUID();
-        UUID catalogItemId3 = UUID.randomUUID();
-        UUID catalogItemId4 = UUID.randomUUID();
-        UUID catalogItemId5 = UUID.randomUUID();
-
-        catalogItem1.setId(catalogItemId1);
-        catalogItem2.setId(catalogItemId2);
-        catalogItem3.setId(catalogItemId3);
-        catalogItem4.setId(catalogItemId4);
-        catalogItem5.setId(catalogItemId5);
-
-        catalogItem1.setName(nameFirst);
-        catalogItem1.setTypes(Set.of(typeCountry, typeCity));
-        catalogItem1.setCountries(Set.of(new Country(countryAaa, catalogItem1), new Country(countryDcd, catalogItem1)));
-        catalogItem1.setWrittenForms(Set.of(new WrittenForm(writtenForm, catalogItem1)));
-
-        catalogItemDto1 = new CatalogItemDto(catalogItemId1, nameFirst, Collections.emptySet(), Set.of(writtenForm), Set.of(country, city), Set.of(countryAaa, countryDcd), Collections.emptySet(), 0.0, 0.0, 0, "");
-
-        catalogItem2.setName(nameSecond);
-        catalogItem2.setAlternativeNames(Set.of(new AlternativeName(nameTwelve, catalogItem2), new AlternativeName(nameThird, catalogItem2)));
-        catalogItem2.setTypes(Set.of(typeCountry, typeCityUpper));
-        catalogItem2.setCountries(Set.of(new Country(countryAaa, catalogItem2), new Country(countryBbb, catalogItem2)));
-        catalogItem2.setWrittenForms(Set.of(new WrittenForm(writtenFormUpper, catalogItem2)));
-
-        catalogItemDto2 = new CatalogItemDto(catalogItemId2, nameSecond, Set.of(nameTwelve, nameThird), Set.of(writtenFormUpper), Set.of(country, cityUpper), Set.of(countryAaa, countryBbb), Collections.emptySet(), 0.0, 0.0, 0, "");
-
-        catalogItem3.setName(nameThird);
-        catalogItem3.setAlternativeNames(Set.of(new AlternativeName(nameTwentyUpper, catalogItem3), new AlternativeName(nameSedond, catalogItem3)));
-        catalogItem3.setTypes(Set.of(typeCountri, typeCapitalCity));
-        catalogItem3.setCountries(Set.of(new Country(countryAaaUpper, catalogItem3), new Country(countryCcc, catalogItem3)));
-        catalogItem3.setWrittenForms(Set.of(new WrittenForm(writtenFormForOr, catalogItem3)));
-
-        catalogItemDto3 = new CatalogItemDto(catalogItemId3, nameThird, Set.of(nameTwentyUpper, nameSedond), Set.of(writtenFormForOr), Set.of(countri, capitalCityNew), Set.of(countryAaaUpper, countryCcc), Collections.emptySet(), 0.0, 0.0, 0, "");
-
-        catalogItem4.setAlternativeNames(Set.of(new AlternativeName(nameTwelve, catalogItem4), new AlternativeName(nameFirstUpper, catalogItem4)));
-        catalogItem4.setTypes(Set.of(typeCountri, typeCountry));
-        catalogItem4.setCountries(Set.of(new Country(countryBccb, catalogItem4), new Country(countryDdd, catalogItem4)));
-        catalogItem4.setWrittenForms(Set.of(new WrittenForm(writtenForm, catalogItem4), new WrittenForm(writtenFormForOr, catalogItem4)));
-
-        catalogItemDto4 = new CatalogItemDto(catalogItemId4, "", Set.of(nameTwelve, nameFirstUpper), Set.of(writtenForm, writtenFormForOr), Set.of(countri, country), Set.of(countryBccb, countryDdd), Collections.emptySet(), 0.0, 0.0, 0, "");
-
-        catalogItem5.setName(nameSedond);
-        catalogItem5.setAlternativeNames(Set.of(new AlternativeName(nameThird, catalogItem5)));
-        catalogItem5.setTypes(Set.of(typeCountri));
-
-        catalogItemDto5 = new CatalogItemDto(catalogItemId5, nameSedond, Set.of(nameThird), Collections.emptySet(), Set.of(countri), Collections.emptySet(), Collections.emptySet(), 0.0, 0.0, 0, "");
-
-        given(catalogItemRepository.findAll()).willReturn(List.of(catalogItem1, catalogItem2, catalogItem3, catalogItem4, catalogItem5));
-    }
-
-    @Test
-    void itShouldReturnAll() {
-        // given
-        String name = "";
-        String country = "";
-        String type = "";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> results = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(results.size()).isEqualTo(5);
-        assertTrue(results.contains(catalogItemDto1));
-        assertTrue(results.contains(catalogItemDto2));
-        assertTrue(results.contains(catalogItemDto3));
-        assertTrue(results.contains(catalogItemDto4));
-        assertTrue(results.contains(catalogItemDto5));
-
-        verify(catalogItemRepository).findAll();
-    }
-
-    @Test
-    void testName() {
-        // given
-        String name = "first";
-        String country = "";
-        String type = "";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(2);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testWildcardCharacterName() {
-        // given
-        String name = "se?ond";
-        String country = "";
-        String type = "";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(3);
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto3));
-        assertTrue(filterResult.contains(catalogItemDto5));
-    }
-
-    @Test
-    void testWildcardCharactersName() {
-        // given
-        String name = "twe*";
-        String country = "";
-        String type = "";
-        String writtenForm = "";
-
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(3);
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto3));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testCountry() {
-        // given
-        String name = "";
-        String country = "aaa";
-        String type = "";
-        String writtenForm = "";
-
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(3);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto3));
-    }
-
-    @Test
-    void testWildcardCharacterCountry() {
-        // given
-        String name = "";
-        String country = "d?d";
-        String type = "";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(2);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testWildcardCharactersCountry() {
-        // given
-        String name = "";
-        String country = "b*b";
-        String type = "";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(2);
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-
-    @Test
-    void testType() {
-        // given
-        String name = "";
-        String country = "";
-        String type = "city";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(2);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto2));
-    }
-
-    @Test
-    void testWildcardCharacterType() {
-        // given
-        String name = "";
-        String country = "";
-        String type = "countr?";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(5);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto3));
-        assertTrue(filterResult.contains(catalogItemDto4));
-        assertTrue(filterResult.contains(catalogItemDto5));
-    }
-
-    @Test
-    void testWildcardCharactersType() {
-        // given
-        String name = "";
-        String country = "";
-        String type = "*city*";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(3);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto3));
-    }
-
-    @Test
-    void testWrittenForm() {
-        // given
-        String name = "";
-        String country = "";
-        String type = "";
-        String writtenForm = "written";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(3);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testWrittenFormWildcardCharacter() {
-        // given
-        String name = "";
-        String country = "";
-        String type = "";
-        String writtenForm = "wr?tten";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(4);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto3));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testWrittenFormWildcardCharacters() {
-        // given
-        String name = "";
-        String country = "";
-        String type = "";
-        String writtenForm = "wri*tten";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(3);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testWrittenFormOr() {
-        // given
-        String name = "";
-        String country = "";
-        String type = "";
-        String writtenForm = "wr(i|a)tten";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(4);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto3));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testNameAndCountry() {
-        // given
-        String name = "third";
-        String country = "aaa";
-        String type = "";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(2);
-        assertTrue(filterResult.contains(catalogItemDto2));
-        assertTrue(filterResult.contains(catalogItemDto3));
-    }
-
-    @Test
-    void testNameAndType() {
-        // given
-        String name = "third";
-        String country = "";
-        String type = "countri";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(2);
-        assertTrue(filterResult.contains(catalogItemDto3));
-        assertTrue(filterResult.contains(catalogItemDto5));
-    }
-
-    @Test
-    void testNameAndWrittenForm() {
-        // given
-        String name = "first";
-        String country = "";
-        String type = "";
-        String writtenForm = "written";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(2);
-        assertTrue(filterResult.contains(catalogItemDto1));
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testCountryAndType() {
-        // given
-        String name = "";
-        String country = "ddd";
-        String type = "country";
-        String writtenForm = "";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(1);
-        assertTrue(filterResult.contains(catalogItemDto4));
-    }
-
-    @Test
-    void testAll() {
-        // given
-        String name = "third";
-        String country = "AAA";
-        String type = "countri";
-        String writtenForm = "wratten";
-
-        // when
-        List<CatalogItemDto> filterResult = underTest.getCatalog(name, country, type, writtenForm);
-
-        // then
-        assertThat(filterResult.size()).isEqualTo(1);
-        assertTrue(filterResult.contains(catalogItemDto3));
-    }
-}
\ No newline at end of file
