diff --git a/codiki-infrastructure/src/main/java/org/codiki/infrastructure/publication/PublicationSearchCriteriaJpaAdapter.java b/codiki-infrastructure/src/main/java/org/codiki/infrastructure/publication/PublicationSearchCriteriaJpaAdapter.java index dec2777..f0e2bd1 100644 --- a/codiki-infrastructure/src/main/java/org/codiki/infrastructure/publication/PublicationSearchCriteriaJpaAdapter.java +++ b/codiki-infrastructure/src/main/java/org/codiki/infrastructure/publication/PublicationSearchCriteriaJpaAdapter.java @@ -3,7 +3,6 @@ package org.codiki.infrastructure.publication; import java.util.LinkedList; import java.util.List; -import org.apache.commons.lang3.StringUtils; import org.codiki.domain.publication.model.search.PublicationSearchCriterion; import org.springframework.stereotype.Component; @@ -16,11 +15,11 @@ public class PublicationSearchCriteriaJpaAdapter { boolean criterionAdaptationOccurred = false; if (criterion.value() instanceof String criterionValue) { - String unaccentedCriterionValue = StringUtils.stripAccents(criterionValue); + String unaccentedCriterionValue = criterionValue.replaceAll("[àáâãäåçèéêëìíîïñòóôõöùúûüýÿ]", "_"); result.add(new PublicationSearchCriterion( criterion.searchField(), criterion.searchType(), - unaccentedCriterionValue + unaccentedCriterionValue.toLowerCase() )); criterionAdaptationOccurred = true; } diff --git a/codiki-infrastructure/src/main/java/org/codiki/infrastructure/publication/repository/PublicationPredicateMapper.java b/codiki-infrastructure/src/main/java/org/codiki/infrastructure/publication/repository/PublicationPredicateMapper.java index 788ae5d..8d649ef 100644 --- a/codiki-infrastructure/src/main/java/org/codiki/infrastructure/publication/repository/PublicationPredicateMapper.java +++ b/codiki-infrastructure/src/main/java/org/codiki/infrastructure/publication/repository/PublicationPredicateMapper.java @@ -53,7 +53,9 @@ public class PublicationPredicateMapper { } return criteriaBuilder.equal( - from.get(attributeName), + criteriaBuilder.lower( + from.get(attributeName) + ), value ); } @@ -72,7 +74,9 @@ public class PublicationPredicateMapper { } return criteriaBuilder.like( - from.get(attributeName), + criteriaBuilder.lower( + from.get(attributeName) + ), String.format("%%%s%%", value) ); } diff --git a/codiki-infrastructure/src/test/java/org/codiki/infrastructure/publication/PublicationSearchCriteriaJpaAdapterTest.java b/codiki-infrastructure/src/test/java/org/codiki/infrastructure/publication/PublicationSearchCriteriaJpaAdapterTest.java index f0b448c..d1833ba 100644 --- a/codiki-infrastructure/src/test/java/org/codiki/infrastructure/publication/PublicationSearchCriteriaJpaAdapterTest.java +++ b/codiki-infrastructure/src/test/java/org/codiki/infrastructure/publication/PublicationSearchCriteriaJpaAdapterTest.java @@ -32,7 +32,7 @@ class PublicationSearchCriteriaJpaAdapterTest { // then List expectedResult = List.of( - new PublicationSearchCriterion(KEY, CONTAINS, "critere") + new PublicationSearchCriterion(KEY, CONTAINS, "crit_re") ); assertThat(result).isEqualTo(expectedResult); } diff --git a/rest-client-collection/Codiki/Category/Create a new category.bru b/rest-client-collection/Codiki/Category/Create a new category.bru new file mode 100644 index 0000000..98f32b4 --- /dev/null +++ b/rest-client-collection/Codiki/Category/Create a new category.bru @@ -0,0 +1,24 @@ +meta { + name: Create a new category + type: http + seq: 1 +} + +post { + url: {{url}}/api/categories + body: json + auth: bearer +} + +auth:bearer { + token: {{bearerToken}} +} + +body:json { + { + "name": "New category with sub-category", + "subCategoryIds": [ + "2d19d037-57a1-44a1-9a20-766b4e3628b6" + ] + } +} diff --git a/rest-client-collection/Codiki/Category/Delete an existing category.bru b/rest-client-collection/Codiki/Category/Delete an existing category.bru new file mode 100644 index 0000000..f619963 --- /dev/null +++ b/rest-client-collection/Codiki/Category/Delete an existing category.bru @@ -0,0 +1,15 @@ +meta { + name: Delete an existing category + type: http + seq: 3 +} + +delete { + url: {{url}}/api/categories/{{categoryId}} + body: none + auth: bearer +} + +auth:bearer { + token: {{bearerToken}} +} diff --git a/rest-client-collection/Codiki/Category/Get all categories.bru b/rest-client-collection/Codiki/Category/Get all categories.bru new file mode 100644 index 0000000..b15aaa6 --- /dev/null +++ b/rest-client-collection/Codiki/Category/Get all categories.bru @@ -0,0 +1,11 @@ +meta { + name: Get all categories + type: http + seq: 4 +} + +get { + url: {{url}}/api/categories + body: none + auth: none +} diff --git a/rest-client-collection/Codiki/Category/Update an existing category.bru b/rest-client-collection/Codiki/Category/Update an existing category.bru new file mode 100644 index 0000000..1f6b5a9 --- /dev/null +++ b/rest-client-collection/Codiki/Category/Update an existing category.bru @@ -0,0 +1,22 @@ +meta { + name: Update an existing category + type: http + seq: 2 +} + +put { + url: {{url}}/api/categories/{{categoryId}} + body: json + auth: bearer +} + +auth:bearer { + token: {{bearerToken}} +} + +body:json { + { + "name": "Another name of the category", + "subCategoryIds": [] + } +} diff --git a/rest-client-collection/Codiki/Pictures/Create a new picture.bru b/rest-client-collection/Codiki/Pictures/Create a new picture.bru new file mode 100644 index 0000000..86defae --- /dev/null +++ b/rest-client-collection/Codiki/Pictures/Create a new picture.bru @@ -0,0 +1,19 @@ +meta { + name: Create a new picture + type: http + seq: 1 +} + +post { + url: {{url}}/api/pictures + body: multipartForm + auth: bearer +} + +auth:bearer { + token: {{bearerToken}} +} + +body:multipart-form { + file: @file(/Users/florian_thierry/Pictures/applications_mac.jpeg) +} diff --git a/rest-client-collection/Codiki/Pictures/Load a picture.bru b/rest-client-collection/Codiki/Pictures/Load a picture.bru new file mode 100644 index 0000000..50a9980 --- /dev/null +++ b/rest-client-collection/Codiki/Pictures/Load a picture.bru @@ -0,0 +1,11 @@ +meta { + name: Load a picture + type: http + seq: 2 +} + +get { + url: {{url}}/api/pictures/{{pictureId}} + body: none + auth: none +} diff --git a/rest-client-collection/Codiki/Publication/Create a new publication.bru b/rest-client-collection/Codiki/Publication/Create a new publication.bru new file mode 100644 index 0000000..cdca2cc --- /dev/null +++ b/rest-client-collection/Codiki/Publication/Create a new publication.bru @@ -0,0 +1,25 @@ +meta { + name: Create a new publication + type: http + seq: 1 +} + +post { + url: {{url}}/api/publications + body: json + auth: bearer +} + +auth:bearer { + token: {{bearerToken}} +} + +body:json { + { + "title" : "Test", + "text" : "Test", + "description" : "Test", + "illustrationId" : "e2a5618e-ef83-4e83-b8ec-0aa129173f85", + "categoryId" : "3f4b4540-a901-92f3-1c15-8ec9172f820e" + } +} diff --git a/rest-client-collection/Codiki/Publication/Delete an existing publication.bru b/rest-client-collection/Codiki/Publication/Delete an existing publication.bru new file mode 100644 index 0000000..fad91e3 --- /dev/null +++ b/rest-client-collection/Codiki/Publication/Delete an existing publication.bru @@ -0,0 +1,15 @@ +meta { + name: Delete an existing publication + type: http + seq: 3 +} + +delete { + url: {{url}}/api/publications/{{publicationId}} + body: none + auth: bearer +} + +auth:bearer { + token: {{bearerToken}} +} diff --git a/rest-client-collection/Codiki/Publication/Get a publication by its id.bru b/rest-client-collection/Codiki/Publication/Get a publication by its id.bru new file mode 100644 index 0000000..cc3e6dd --- /dev/null +++ b/rest-client-collection/Codiki/Publication/Get a publication by its id.bru @@ -0,0 +1,15 @@ +meta { + name: Get a publication by its id + type: http + seq: 4 +} + +get { + url: {{url}}/api/publications/{{publicationId}} + body: none + auth: bearer +} + +auth:bearer { + token: {{bearerToken}} +} diff --git a/rest-client-collection/Codiki/Publication/Search publications.bru b/rest-client-collection/Codiki/Publication/Search publications.bru new file mode 100644 index 0000000..ffab779 --- /dev/null +++ b/rest-client-collection/Codiki/Publication/Search publications.bru @@ -0,0 +1,19 @@ +meta { + name: Search publications + type: http + seq: 5 +} + +get { + url: {{url}}/api/publications?query=test + body: none + auth: bearer +} + +query { + query: test +} + +auth:bearer { + token: {{bearerToken}} +} diff --git a/rest-client-collection/Codiki/Publication/Update an existing publication.bru b/rest-client-collection/Codiki/Publication/Update an existing publication.bru new file mode 100644 index 0000000..1b8e4bb --- /dev/null +++ b/rest-client-collection/Codiki/Publication/Update an existing publication.bru @@ -0,0 +1,25 @@ +meta { + name: Update an existing publication + type: http + seq: 2 +} + +put { + url: {{url}}/api/publications/{{publicationId}} + body: json + auth: bearer +} + +auth:bearer { + token: {{bearerToken}} +} + +body:json { + { + "title" : "Le titre de la publication.", + "text" : "Un autre contenu de la publication.", + "description" : "Une autre description de la publication", + "image" : "https://google.com/logos/doodles/2024/celebrating-the-flat-white-6753651837110463-s.png", + "categoryId" : "fd424c2f-6e58-4812-a179-00e50a0eab05" + } +} diff --git a/rest-client-collection/Codiki/Users/Login as admin user.bru b/rest-client-collection/Codiki/Users/Login as admin user.bru new file mode 100644 index 0000000..6874d2e --- /dev/null +++ b/rest-client-collection/Codiki/Users/Login as admin user.bru @@ -0,0 +1,18 @@ +meta { + name: Login as admin user + type: http + seq: 2 +} + +post { + url: {{url}}/api/users/login + body: json + auth: none +} + +body:json { + { + "id": "15a13dc7-029d-4eab-a63d-c1e96f90241d", + "password": "password" + } +} diff --git a/rest-client-collection/Codiki/Users/Login as standard user.bru b/rest-client-collection/Codiki/Users/Login as standard user.bru new file mode 100644 index 0000000..bac68b3 --- /dev/null +++ b/rest-client-collection/Codiki/Users/Login as standard user.bru @@ -0,0 +1,18 @@ +meta { + name: Login as standard user + type: http + seq: 1 +} + +post { + url: {{url}}/api/users/login + body: json + auth: none +} + +body:json { + { + "id": "5ad462b8-8f9e-4a26-bb86-c74fef5d11b6", + "password": "password" + } +} diff --git a/rest-client-collection/Codiki/Users/Sign in.bru b/rest-client-collection/Codiki/Users/Sign in.bru new file mode 100644 index 0000000..8fc65ab --- /dev/null +++ b/rest-client-collection/Codiki/Users/Sign in.bru @@ -0,0 +1,11 @@ +meta { + name: Sign in + type: http + seq: 3 +} + +post { + url: {{url}}/users + body: none + auth: none +} diff --git a/rest-client-collection/Codiki/environments/localhost.bru b/rest-client-collection/Codiki/environments/localhost.bru index 9ffb718..9b27e71 100644 --- a/rest-client-collection/Codiki/environments/localhost.bru +++ b/rest-client-collection/Codiki/environments/localhost.bru @@ -1,7 +1,7 @@ vars { url: http://localhost:8080 publicationId: e23831a6-9cc0-4f3d-9efa-7a1cae191cb1 - bearerToken: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWQ0NjJiOC04ZjllLTRhMjYtYmI4Ni1jNzRmZWY1ZDExYjYiLCJleHAiOjE3MTA0OTc2MTd9.xYfS-9CrJxCKUyvZ1ejMKErEttA1zysXxjlVzHFzXJ3ct9dt13xuiI7PHA-8_xY7HQjuIP1M5P2p0OGVsnxXsw + bearerToken: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWQ0NjJiOC04ZjllLTRhMjYtYmI4Ni1jNzRmZWY1ZDExYjYiLCJleHAiOjE3MTA1MjE5NzN9.KgYeDYNjgM4ndv_An0fAoOdx7qHRJDXuUPnBEcn6es5kn2g-HDjgt1n_s5CD3_F13alBdR18--9dZlWV8qQmHg categoryId: 172fa901-3f4b-4540-92f3-1c15820e8ec9 pictureId: 65b660b7-66bb-4e4a-a62c-fd0ca101f972 }