Skip to content

Commit

Permalink
fix(java): add overload for browseObjects (#3351)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Jul 12, 2024
1 parent 42f10f9 commit f1b1866
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 14 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,17 @@ jobs:
path: tests/output/javascript/node_modules
key: node-modules-tests-${{ hashFiles('tests/output/javascript/yarn.lock') }}

- name: Run CTS
id: cts
- name: Run unit CTS
run: yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --exclude-e2e

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

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

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

- name: Run CTS
id: cts
- name: Run unit CTS
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-e2e

- name: Run e2e CTS
id: cts-e2e
continue-on-error: true
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} ${{ github.event.pull_request.head.repo.fork && '--exclude-e2e' || '' }}
if: ${{ !github.event.pull_request.head.repo.fork }}
run: yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --exclude-unit

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

- name: Generate code snippets for documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void main(String[] args) throws Exception {

var options = new ClientOptions.Builder()
.addAlgoliaAgentSegment("Playground", "1.0.0")
.setLogLevel(LogLevel.BODY)
//.setLogLevel(LogLevel.BODY)
.build();

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

var browse = client.browseObjects(indexName, new BrowseParamsObject().setQuery("tom"), Actor.class);
System.out.println("-> Browse Objects:");
for (var hit : browse) {
System.out.println("> " + hit.name);
}

singleSearch(client, indexName, query);
multiSearch(indexName, query, client);
client.close();
Expand Down
4 changes: 2 additions & 2 deletions scripts/cts/runCts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ async function runCtsOne(
);
break;
case 'ruby':
await run(`bundle install && bundle exec rake test --trace`, {
await run(`bundle install && bundle exec rake ${filter((f) => `test:${f}`)} --trace`, {
cwd,
language,
});
break;
case 'scala':
await run(`sbt test`, {
await run(`sbt 'testOnly ${filter((f) => `algoliasearch.${f}.*`)}'`, {
cwd,
language,
});
Expand Down
10 changes: 10 additions & 0 deletions templates/java/api_helpers.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ public <T> Iterable<T> browseObjects(String indexName, BrowseParamsObject params
return browseObjects(indexName, params, innerType, null);
}
/**
* Helper: Returns an iterator on top of the `browse` method.
*
* @param indexName The index in which to perform the request.
* @param innerType The class held by the index, could be your custom class or {@link Object}.
*/
public <T> Iterable<T> browseObjects(String indexName, Class<T> innerType) {
return browseObjects(indexName, new BrowseParamsObject(), innerType, null);
}
/**
* Helper: Returns an iterator on top of the `searchSynonyms` method.
*
Expand Down
20 changes: 17 additions & 3 deletions tests/output/ruby/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@

require 'rake/testtask'

task test: 'test:unit'
task test: %w[test:client test:requests test:e2e]

namespace :test do
Rake::TestTask.new(:unit) do |t|
Rake::TestTask.new(:client) do |t|
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb']
t.test_files = FileList['test/client/*_test.rb']
t.verbose = true
t.warning = false
end

Rake::TestTask.new(:requests) do |t|
t.libs << 'test'
t.test_files = FileList['test/requests/*_test.rb']
t.verbose = true
t.warning = false
end

Rake::TestTask.new(:e2e) do |t|
t.libs << 'test'
t.test_files = FileList['test/e2e/*_test.rb']
t.verbose = true
t.warning = false
end
Expand Down

0 comments on commit f1b1866

Please sign in to comment.