Search in sources :

Example 21 with Query

use of com.google.cloud.firestore.Query in project java-docs-samples by GoogleCloudPlatform.

the class QueryDataSnippetsIT method testEndAtFieldQueryCursor.

@Test
public void testEndAtFieldQueryCursor() throws Exception {
    Query q = queryDataSnippets.createEndAtFieldQueryCursor();
    List<String> expectedResults = Arrays.asList("DC", "SF", "LA");
    List<String> result = getResults(q);
    assertEquals(result, expectedResults);
}
Also used : Query(com.google.cloud.firestore.Query) Test(org.junit.Test) BaseIntegrationTest(com.example.firestore.BaseIntegrationTest)

Example 22 with Query

use of com.google.cloud.firestore.Query in project java-docs-samples by GoogleCloudPlatform.

the class QueryDataSnippetsIT method testStartAtFieldQueryCursor.

@Test
public void testStartAtFieldQueryCursor() throws Exception {
    Query q = queryDataSnippets.createStartAtFieldQueryCursor();
    List<String> expectedResults = Arrays.asList("TOK", "BJ");
    List<String> result = getResults(q);
    assertTrue(Objects.equals(result, expectedResults));
}
Also used : Query(com.google.cloud.firestore.Query) Test(org.junit.Test) BaseIntegrationTest(com.example.firestore.BaseIntegrationTest)

Example 23 with Query

use of com.google.cloud.firestore.Query in project java-docs-samples by GoogleCloudPlatform.

the class QueryDataSnippetsIT method testChainedQuery.

@Test
public void testChainedQuery() throws Exception {
    Query q = queryDataSnippets.createChainedQuery();
    Set<String> result = getResultsAsSet(q);
    Set<String> expectedResults = new HashSet<>();
    assertTrue(Objects.equals(result, expectedResults));
}
Also used : Query(com.google.cloud.firestore.Query) HashSet(java.util.HashSet) Test(org.junit.Test) BaseIntegrationTest(com.example.firestore.BaseIntegrationTest)

Example 24 with Query

use of com.google.cloud.firestore.Query in project java-docs-samples by GoogleCloudPlatform.

the class QueryDataSnippetsIT method testInvalidRangeQueryThrowsException.

@Test(expected = Exception.class)
public void testInvalidRangeQueryThrowsException() throws Exception {
    Query q = queryDataSnippets.createInvalidRangeQuery();
    getResults(q);
}
Also used : Query(com.google.cloud.firestore.Query) Test(org.junit.Test) BaseIntegrationTest(com.example.firestore.BaseIntegrationTest)

Example 25 with Query

use of com.google.cloud.firestore.Query in project java-docs-samples by GoogleCloudPlatform.

the class QueryDataSnippetsIT method testCreateAQuery.

@Test
public void testCreateAQuery() throws Exception {
    Query q = queryDataSnippets.createAQuery();
    Set<String> result = getResultsAsSet(q);
    Set<String> expectedResults = new HashSet<>(Arrays.asList("DC", "TOK", "BJ"));
    assertTrue(Objects.equals(result, expectedResults));
}
Also used : Query(com.google.cloud.firestore.Query) HashSet(java.util.HashSet) Test(org.junit.Test) BaseIntegrationTest(com.example.firestore.BaseIntegrationTest)

Aggregations

Query (com.google.cloud.firestore.Query)31 CollectionReference (com.google.cloud.firestore.CollectionReference)15 BaseIntegrationTest (com.example.firestore.BaseIntegrationTest)12 Test (org.junit.Test)12 QuerySnapshot (com.google.cloud.firestore.QuerySnapshot)6 HashSet (java.util.HashSet)3 Book (com.example.getstarted.objects.Book)2 Result (com.example.getstarted.objects.Result)2 DocumentSnapshot (com.google.cloud.firestore.DocumentSnapshot)2 ExecutionException (java.util.concurrent.ExecutionException)2 FirestoreException (com.google.cloud.firestore.FirestoreException)1 ListenerRegistration (com.google.cloud.firestore.ListenerRegistration)1 QueryDocumentSnapshot (com.google.cloud.firestore.QueryDocumentSnapshot)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ArrayList (java.util.ArrayList)1