Skip to content

Commit f1b1866

Browse files
authored
fix(java): add overload for browseObjects (#3351)
1 parent 42f10f9 commit f1b1866

File tree

5 files changed

+52
-14
lines changed

5 files changed

+52
-14
lines changed

.github/workflows/check.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,17 @@ jobs:
241241
path: tests/output/javascript/node_modules
242242
key: node-modules-tests-${{ hashFiles('tests/output/javascript/yarn.lock') }}
243243

244-
- name: Run CTS
245-
id: cts
244+
- name: Run unit CTS
245+
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-e2e
246+
247+
- name: Run e2e CTS
248+
id: cts-e2e
246249
continue-on-error: true
247-
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} ${{ github.event.pull_request.head.repo.fork && '--exclude-e2e' || '' }}
250+
if: ${{ !github.event.pull_request.head.repo.fork }}
251+
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-unit
248252

249253
- name: Retry e2e CTS
250-
if: ${{ !github.event.pull_request.head.repo.fork && github.event.number && steps.cts.outcome == 'failure' }}
254+
if: ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }}
251255
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-unit
252256

253257
- name: Generate code snippets for documentation
@@ -331,13 +335,17 @@ jobs:
331335
- name: Generate CTS
332336
run: yarn cli cts generate ${{ matrix.client.language }} ${{ matrix.client.toRun }}
333337

334-
- name: Run CTS
335-
id: cts
338+
- name: Run unit CTS
339+
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-e2e
340+
341+
- name: Run e2e CTS
342+
id: cts-e2e
336343
continue-on-error: true
337-
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} ${{ github.event.pull_request.head.repo.fork && '--exclude-e2e' || '' }}
344+
if: ${{ !github.event.pull_request.head.repo.fork }}
345+
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-unit
338346

339347
- name: Retry e2e CTS
340-
if: ${{ !github.event.pull_request.head.repo.fork && steps.cts.outcome == 'failure' }}
348+
if: ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }}
341349
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-unit
342350

343351
- name: Generate code snippets for documentation

playground/java/src/main/java/com/algolia/playground/Search.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static void main(String[] args) throws Exception {
3333

3434
var options = new ClientOptions.Builder()
3535
.addAlgoliaAgentSegment("Playground", "1.0.0")
36-
.setLogLevel(LogLevel.BODY)
36+
//.setLogLevel(LogLevel.BODY)
3737
.build();
3838

3939
var client = new SearchClient(appId, apiKey, options);
@@ -44,6 +44,12 @@ public static void main(String[] args) throws Exception {
4444
var response = client.batch(indexName, new BatchWriteParams().setRequests(batch));
4545
client.waitForTask(indexName, response.getTaskID());
4646

47+
var browse = client.browseObjects(indexName, new BrowseParamsObject().setQuery("tom"), Actor.class);
48+
System.out.println("-> Browse Objects:");
49+
for (var hit : browse) {
50+
System.out.println("> " + hit.name);
51+
}
52+
4753
singleSearch(client, indexName, query);
4854
multiSearch(indexName, query, client);
4955
client.close();

scripts/cts/runCts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ async function runCtsOne(
8989
);
9090
break;
9191
case 'ruby':
92-
await run(`bundle install && bundle exec rake test --trace`, {
92+
await run(`bundle install && bundle exec rake ${filter((f) => `test:${f}`)} --trace`, {
9393
cwd,
9494
language,
9595
});
9696
break;
9797
case 'scala':
98-
await run(`sbt test`, {
98+
await run(`sbt 'testOnly ${filter((f) => `algoliasearch.${f}.*`)}'`, {
9999
cwd,
100100
language,
101101
});

templates/java/api_helpers.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,16 @@ public <T> Iterable<T> browseObjects(String indexName, BrowseParamsObject params
289289
return browseObjects(indexName, params, innerType, null);
290290
}
291291
292+
/**
293+
* Helper: Returns an iterator on top of the `browse` method.
294+
*
295+
* @param indexName The index in which to perform the request.
296+
* @param innerType The class held by the index, could be your custom class or {@link Object}.
297+
*/
298+
public <T> Iterable<T> browseObjects(String indexName, Class<T> innerType) {
299+
return browseObjects(indexName, new BrowseParamsObject(), innerType, null);
300+
}
301+
292302
/**
293303
* Helper: Returns an iterator on top of the `searchSynonyms` method.
294304
*

tests/output/ruby/Rakefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22

33
require 'rake/testtask'
44

5-
task test: 'test:unit'
5+
task test: %w[test:client test:requests test:e2e]
66

77
namespace :test do
8-
Rake::TestTask.new(:unit) do |t|
8+
Rake::TestTask.new(:client) do |t|
99
t.libs << 'test'
10-
t.test_files = FileList['test/**/*_test.rb']
10+
t.test_files = FileList['test/client/*_test.rb']
11+
t.verbose = true
12+
t.warning = false
13+
end
14+
15+
Rake::TestTask.new(:requests) do |t|
16+
t.libs << 'test'
17+
t.test_files = FileList['test/requests/*_test.rb']
18+
t.verbose = true
19+
t.warning = false
20+
end
21+
22+
Rake::TestTask.new(:e2e) do |t|
23+
t.libs << 'test'
24+
t.test_files = FileList['test/e2e/*_test.rb']
1125
t.verbose = true
1226
t.warning = false
1327
end

0 commit comments

Comments
 (0)