-
Notifications
You must be signed in to change notification settings - Fork 129
Add tasks filters for v0.30 #544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alallema
merged 2 commits into
bump-meilisearch-v0.30.0
from
add_tasks_filters_for_v0.30
Feb 22, 2023
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| import com.meilisearch.sdk.model.TasksQuery; | ||
| import com.meilisearch.sdk.model.TasksResults; | ||
| import com.meilisearch.sdk.utils.Movie; | ||
| import java.util.Date; | ||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Tag; | ||
|
|
@@ -100,6 +101,43 @@ public void testClientGetTasksLimitAndFrom() throws Exception { | |
| assertNotNull(result.getResults().length); | ||
| } | ||
|
|
||
| /** Test Get Tasks with uid as filter */ | ||
| @Test | ||
| public void testClientGetTasksWithUidFilter() throws Exception { | ||
| TasksQuery query = new TasksQuery().setUids(new int[] {1}); | ||
| TasksResults result = client.getTasks(query); | ||
|
|
||
| assertNotNull(result.getLimit()); | ||
| assertNotNull(result.getFrom()); | ||
| assertNotNull(result.getNext()); | ||
| assertNotNull(result.getResults().length); | ||
| } | ||
|
|
||
| /** Test Get Tasks with beforeEnqueuedAt as filter */ | ||
| @Test | ||
| public void testClientGetTasksWithDateFilter() throws Exception { | ||
| Date date = new Date(); | ||
| TasksQuery query = new TasksQuery().setBeforeEnqueuedAt(date); | ||
| TasksResults result = client.getTasks(query); | ||
|
|
||
| assertNotNull(result.getLimit()); | ||
| assertNotNull(result.getFrom()); | ||
| assertNotNull(result.getNext()); | ||
| assertNotNull(result.getResults().length); | ||
| } | ||
|
|
||
| /** Test Get Tasks with canceledBy as filter */ | ||
| @Test | ||
| public void testClientGetTasksWithCanceledByFilter() throws Exception { | ||
| TasksQuery query = new TasksQuery().setCanceledBy(new int[] {1}); | ||
| TasksResults result = client.getTasks(query); | ||
|
|
||
| assertNotNull(result.getLimit()); | ||
| assertNotNull(result.getFrom()); | ||
| assertNotNull(result.getNext()); | ||
| assertNotNull(result.getResults().length); | ||
| } | ||
|
|
||
| /** Test Get Tasks with all query parameters */ | ||
| @Test | ||
| public void testClientGetTasksAllQueryParameters() throws Exception { | ||
|
|
@@ -109,14 +147,14 @@ public void testClientGetTasksAllQueryParameters() throws Exception { | |
| new TasksQuery() | ||
| .setLimit(limit) | ||
| .setFrom(from) | ||
| .setStatus(new String[] {"enqueued", "succeeded"}) | ||
| .setType(new String[] {"indexDeletion"}); | ||
| .setStatuses(new String[] {"enqueued", "succeeded"}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can create an issue to make this a enum :) |
||
| .setTypes(new String[] {"indexDeletion"}); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The types can also be an enum! |
||
| TasksResults result = client.getTasks(query); | ||
| Task[] tasks = result.getResults(); | ||
|
|
||
| assertEquals(limit, result.getLimit()); | ||
| assertNotNull(result.getFrom()); | ||
| assertNotNull(result.getNext()); | ||
| assertNotNull(result.getResults().length); | ||
| } | ||
|
|
||
| /** Test Cancel Task */ | ||
|
|
||
56 changes: 56 additions & 0 deletions
56
src/test/java/com/meilisearch/sdk/TaskHandlerUtilsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.meilisearch.sdk; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import com.meilisearch.sdk.model.TasksQuery; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class TasksHandlerUtilsTest { | ||
|
|
||
| @Test | ||
| void addIndexUidToQueryWithParamNull() { | ||
| final Config config = new Config("http://localhost:7700", "masterKey"); | ||
| TasksHandler classToTest = new TasksHandler(config); | ||
| TasksQuery param = null; | ||
| TasksQuery query = classToTest.addIndexUidToQuery("indexName", param); | ||
|
|
||
| assertEquals("?indexUids=indexName", query.toQuery().toString()); | ||
| } | ||
|
|
||
| @Test | ||
| void addIndexUidToQueryWithParam() { | ||
| final Config config = new Config("http://localhost:7700", "masterKey"); | ||
| TasksHandler classToTest = new TasksHandler(config); | ||
| TasksQuery param = new TasksQuery().setIndexUids(new String[] {}); | ||
| TasksQuery query = classToTest.addIndexUidToQuery("indexName", param); | ||
|
|
||
| assertEquals("?indexUids=indexName", query.toQuery().toString()); | ||
| } | ||
|
|
||
| @Test | ||
| void addIndexUidToQueryWithOneIndexUid() { | ||
| final Config config = new Config("http://localhost:7700", "masterKey"); | ||
| TasksHandler classToTest = new TasksHandler(config); | ||
| TasksQuery param = new TasksQuery().setIndexUids(new String[] {"indexName2"}); | ||
| TasksQuery query = classToTest.addIndexUidToQuery("indexName1", param); | ||
|
|
||
| assertEquals("?indexUids=indexName2,indexName1", query.toQuery().toString()); | ||
| } | ||
|
|
||
| @Test | ||
| void addIndexUidToQueryWithMultipleIndexUids() { | ||
| final Config config = new Config("http://localhost:7700", "masterKey"); | ||
| TasksHandler classToTest = new TasksHandler(config); | ||
| TasksQuery param = | ||
| new TasksQuery() | ||
| .setIndexUids( | ||
| new String[] { | ||
| "indexName2", "indexName3", "indexName4", "indexName5" | ||
| }); | ||
| TasksQuery query = classToTest.addIndexUidToQuery("indexName1", param); | ||
|
|
||
| assertEquals( | ||
| "?indexUids=indexName2,indexName3,indexName4,indexName5,indexName1", | ||
| query.toQuery().toString()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.