Skip to content

Commit

Permalink
data-cube-query-server: fix issue with searching for user query (#3334)
Browse files Browse the repository at this point in the history
  • Loading branch information
akphi authored Jan 3, 2025
1 parent bed9028 commit 09d0816
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ public List<DataCubeQuery> searchQueries(QuerySearchSpecification searchSpecific
filters.add(filter);
}
}
if (searchSpecification.showCurrentUserQueriesOnly != null && searchSpecification.showCurrentUserQueriesOnly)
{
filters.add(Filters.in("owner", currentUser, null));
}

List<DataCubeQuery> queries = new ArrayList<>();
List<Bson> aggregateLists = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,32 @@ public void testGetQueriesWithSearchText() throws Exception
Assert.assertEquals(3, store.searchQueries(new TestQuerySearchSpecificationBuilder().withSearchTerm("query").build(), currentUser).size());
}

@Test
public void testGetQueriesWithSearchTextSpec() throws Exception
{
String currentUser = "user1";
String user2 = "user2";
store.createQuery(TestQueryBuilder.create("1", "query1", currentUser).build(), currentUser);
store.createQuery(TestQueryBuilder.create("2", "query2", currentUser).build(), currentUser);
store.createQuery(TestQueryBuilder.create("3", "query3", user2).build(), user2);
Assert.assertEquals(1, store.searchQueries(new TestQueryStoreManager.TestQuerySearchSpecificationBuilder().withSearchTerm("user2").withIncludeOwner(true).build(), currentUser).size());
Assert.assertEquals(2, store.searchQueries(new TestQueryStoreManager.TestQuerySearchSpecificationBuilder().withSearchTerm("user1").withIncludeOwner(true).build(), currentUser).size());
Assert.assertEquals(3, store.searchQueries(new TestQueryStoreManager.TestQuerySearchSpecificationBuilder().withSearchTerm("user").withIncludeOwner(true).build(), currentUser).size());
Assert.assertEquals(0, store.searchQueries(new TestQueryStoreManager.TestQuerySearchSpecificationBuilder().withSearchTerm("user").withExactNameSearch(true).withIncludeOwner(true).build(), currentUser).size());
Assert.assertEquals(0, store.searchQueries(new TestQueryStoreManager.TestQuerySearchSpecificationBuilder().withSearchTerm("user").withIncludeOwner(false).build(), currentUser).size());
}

@Test
public void testGetQueriesForCurrentUser() throws Exception
{
String currentUser = "testUser";
store.createQuery(TestQueryBuilder.create("1", "query1", currentUser).build(), "testUser1");
store.createQuery(TestQueryBuilder.create("2", "query2", currentUser).build(), currentUser);
Assert.assertEquals(2, store.searchQueries(new TestQueryStoreManager.TestQuerySearchSpecificationBuilder().build(), currentUser).size());
Assert.assertEquals(2, store.searchQueries(new TestQueryStoreManager.TestQuerySearchSpecificationBuilder().withShowCurrentUserQueriesOnly(false).build(), currentUser).size());
Assert.assertEquals(1, store.searchQueries(new TestQueryStoreManager.TestQuerySearchSpecificationBuilder().withShowCurrentUserQueriesOnly(true).build(), currentUser).size());
}

@Test
public void testGetNotFoundQuery()
{
Expand Down

0 comments on commit 09d0816

Please sign in to comment.