Skip to content

Commit fe5b8fb

Browse files
Add missing package and imports for namespace filter IT
1 parent 71a39be commit fe5b8fb

File tree

1 file changed

+57
-35
lines changed

1 file changed

+57
-35
lines changed
Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,58 @@
1-
@Test
2-
void namespaceFilterMatchesOnlyExactNamespace() {
3-
4-
Extension vscode = new Extension();
5-
vscode.setNamespace("vscode");
6-
vscode.setName("python");
7-
repositoryService.save(vscode);
8-
9-
Extension msVscode = new Extension();
10-
msVscode.setNamespace("ms-vscode");
11-
msVscode.setName("cpptools");
12-
repositoryService.save(msVscode);
13-
14-
// Rebuild the index so both extensions are searchable
15-
elasticSearchService.updateSearchIndex(true);
16-
17-
// Search using an exact namespace filter
18-
Options options = new Options(
19-
null,
20-
"vscode",
21-
null,
22-
null,
23-
null,
24-
0,
25-
10,
26-
"desc",
27-
SortBy.RELEVANCE
28-
);
29-
30-
SearchResult result = elasticSearchService.search(options);
31-
32-
assertThat(result.extensions())
33-
.extracting(ExtensionSearch::getNamespace)
34-
.contains("vscode")
35-
.doesNotContain("ms-vscode");
1+
package org.eclipse.openvsx.search;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import java.util.List;
6+
7+
import org.eclipse.openvsx.entities.Extension;
8+
import org.eclipse.openvsx.repositories.RepositoryService;
9+
import org.junit.jupiter.api.Test;
10+
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.boot.test.context.SpringBootTest;
12+
import org.springframework.test.context.ActiveProfiles;
13+
14+
@SpringBootTest
15+
@ActiveProfiles("test")
16+
class ElasticSearchNamespaceFilterIT {
17+
18+
@Autowired
19+
private ElasticSearchService elasticSearchService;
20+
21+
@Autowired
22+
private RepositoryService repositoryService;
23+
24+
@Test
25+
void namespaceFilterMatchesOnlyExactNamespace() {
26+
Extension vscode = new Extension();
27+
vscode.setNamespace("vscode");
28+
vscode.setName("python");
29+
repositoryService.save(vscode);
30+
31+
Extension msVscode = new Extension();
32+
msVscode.setNamespace("ms-vscode");
33+
msVscode.setName("cpptools");
34+
repositoryService.save(msVscode);
35+
36+
elasticSearchService.updateSearchIndex(true);
37+
38+
Options options = new Options(
39+
null,
40+
"vscode",
41+
null,
42+
null,
43+
null,
44+
0,
45+
10,
46+
"desc",
47+
SortBy.RELEVANCE
48+
);
49+
50+
SearchResult result = elasticSearchService.search(options);
51+
List<ExtensionSearch> extensions = result.extensions();
52+
53+
assertThat(extensions)
54+
.extracting(ExtensionSearch::getNamespace)
55+
.contains("vscode")
56+
.doesNotContain("ms-vscode");
57+
}
3658
}

0 commit comments

Comments
 (0)