Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 98c7674

Browse files
committed
fixed a search bug and increased test cov.
1 parent e54ebf0 commit 98c7674

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/main/java/de/filefighter/rest/domain/filesystem/business/FileSystemBusinessService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ public List<FileSystemItem> searchFileSystemEntity(String sanitizedSearch, User
272272

273273
if (userWithTheName.getUserId() != RestConfiguration.RUNTIME_USER_ID) {
274274
// there is a user with the name -> add the users root to list.
275-
foundEntities.add(fileSystemHelperService.getRootEntityForUser(userWithTheName));
275+
FileSystemEntity userRootEntity = fileSystemHelperService.getRootEntityForUser(userWithTheName);
276+
userRootEntity.setName(userWithTheName.getUsername());
277+
foundEntities.add(userRootEntity);
276278
}
277279
} catch (UserNotFoundException ignored) {
278280
log.debug("Searched for {}, was not a username.", sanitizedSearch);

src/test/resources/SearchFiles.feature

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ Feature: Search Files and Directories
2020
Then response status code is 200
2121
And the response contains a entity with the path "/richard/bla/wow.txt" that has key "name" with value "wow.txt"
2222

23+
Scenario: Successful interaction, searching for personal root folder
24+
When user with token "Richard" searches for "Richard"
25+
Then response status code is 200
26+
And the response contains a entity with the path "/richard" that has key "name" with value "Richard"
27+
2328
Scenario: Successful interaction, found file in personal folder, ignore case
2429
When user with token "Richard" searches for "WOW.TXT"
2530
Then response status code is 200
@@ -65,7 +70,6 @@ Feature: Search Files and Directories
6570
And the response contains a entity with the path "/richard/bla" that has key "fileSystemId" with value "42"
6671

6772

68-
6973
Scenario Outline: Search for <filename> with <search>
7074
Given fileSystemItem with the fileSystemId 73 exists, has owner with userId 1234 and name "<filename>"
7175
And fileSystemItem with the fileSystemId 42 is a folder and contains the fileSystemId 73
@@ -74,14 +78,14 @@ Feature: Search Files and Directories
7478
And the response contains the file with fileSystemId 73 and name "<filename>"
7579

7680
Examples:
77-
|filename |search |
78-
|HansWurst |st |
79-
|Esel.txt |.txt |
80-
|HinterhältigesWiesel.wav |Hältiges |
81-
|HilfeHilfe |hilfe |
82-
|DuDummeSau |du |
83-
|NichtDasNagetier |Tier |
84-
|DuBauer |auer |
85-
|DasIstWahreMacht |d |
86-
|DIesESMALWerdeICHEuchBesiegen |DiesesMalWerdeIchEuchBesiegen |
87-
|filename |filename |
81+
| filename | search |
82+
| HansWurst | st |
83+
| Esel.txt | .txt |
84+
| HinterhältigesWiesel.wav | Hältiges |
85+
| HilfeHilfe | hilfe |
86+
| DuDummeSau | du |
87+
| NichtDasNagetier | Tier |
88+
| DuBauer | auer |
89+
| DasIstWahreMacht | d |
90+
| DIesESMALWerdeICHEuchBesiegen | DiesesMalWerdeIchEuchBesiegen |
91+
| filename | filename |

0 commit comments

Comments
 (0)