Skip to content

Commit c865a92

Browse files
committed
Add a test for key queries
1 parent 78052af commit c865a92

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

datastore/src/test/java/io/spine/server/storage/datastore/TransactionWrapperTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.google.cloud.datastore.KeyFactory;
2727
import com.google.cloud.datastore.PathElement;
2828
import com.google.cloud.datastore.Query;
29+
import com.google.cloud.datastore.StructuredQuery;
2930
import com.google.common.collect.ImmutableList;
3031
import com.google.protobuf.Empty;
3132
import io.spine.testing.SlowTest;
@@ -367,4 +368,23 @@ void lookupBulk() {
367368
.containsExactlyElementsIn(entities);
368369
}
369370
}
371+
372+
@Test
373+
@DisplayName("NOT execute a key query")
374+
void keyQuery() {
375+
int count = 2;
376+
List<Entity> entities = generate(() -> keyFactory.newKey(newUuid()))
377+
.limit(count)
378+
.map(key -> Entity.newBuilder(key).build())
379+
.collect(toList());
380+
datastore.createOrUpdate(entities);
381+
try (TransactionWrapper tx = datastore.newTransaction()) {
382+
StructuredQuery<Key> query = Query
383+
.newKeyQueryBuilder()
384+
.setKind(TEST_KIND.value())
385+
.build();
386+
assertThrows(DatastoreException.class, () -> tx.read(query));
387+
tx.commit();
388+
}
389+
}
370390
}

license-report.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@
650650
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
651651

652652

653-
This report was generated on **Tue Jan 28 17:05:29 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
653+
This report was generated on **Tue Jan 28 17:24:57 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
654654

655655

656656

@@ -1309,7 +1309,7 @@ This report was generated on **Tue Jan 28 17:05:29 EET 2020** using [Gradle-Lice
13091309
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
13101310

13111311

1312-
This report was generated on **Tue Jan 28 17:05:31 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1312+
This report was generated on **Tue Jan 28 17:24:59 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
13131313

13141314

13151315

@@ -1985,4 +1985,4 @@ This report was generated on **Tue Jan 28 17:05:31 EET 2020** using [Gradle-Lice
19851985
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
19861986

19871987

1988-
This report was generated on **Tue Jan 28 17:05:32 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1988+
This report was generated on **Tue Jan 28 17:25:01 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).

0 commit comments

Comments
 (0)