From 8187f19849b7ef8ee6d9aa214af7d23aae099dd7 Mon Sep 17 00:00:00 2001 From: kolea2 Date: Mon, 27 May 2024 19:16:17 -0400 Subject: [PATCH 1/2] test: add integration test for incomplete key --- .../cloud/datastore/it/ITDatastoreTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java index 09dcd2116..990eab246 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java @@ -144,6 +144,7 @@ public class ITDatastoreTest { private static Key KEY3; private static Key KEY4; private static Key KEY5; + private static Key KEY6; private static final String MARKS_KIND = "Marks"; private static FullEntity PARTIAL_ENTITY1; private static FullEntity PARTIAL_ENTITY2; @@ -193,6 +194,10 @@ public ITDatastoreTest( KEY3 = Key.newBuilder(KEY2).setName("bla").setNamespace(NAMESPACE).build(); KEY4 = Key.newBuilder(KEY2).setName("newName1").setNamespace(NAMESPACE).build(); KEY5 = Key.newBuilder(KEY2).setName("newName2").setNamespace(NAMESPACE).build(); + KEY6 = + Key.newBuilder(options.getProjectId(), KIND2, 100, options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build(); LIST_VALUE2 = ListValue.of(Collections.singletonList(KeyValue.of(KEY1))); @@ -1787,6 +1792,21 @@ public void testGet() { assertFalse(entity.contains("bla")); } + @Test + public void testIncompleteKey() { + Key parentKey = null; + try { + IncompleteKey incompleteKey = IncompleteKey.newBuilder(KEY6, KIND1).build(); + parentKey = incompleteKey.getParent(); + Entity entity = Entity.newBuilder(parentKey).set("name", "val").build(); + datastore.put(entity); + Entity retrievedEntity = datastore.get(parentKey); + assertThat(retrievedEntity).isEqualTo(entity); + } finally { + datastore.delete(parentKey); + } + } + @Test public void testGetWithReadTime() throws InterruptedException { Key key = From ef2967fa3d1478b0dceb863b8a6bceadfe5e959e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 27 May 2024 23:22:31 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../java/com/google/cloud/datastore/it/ITDatastoreTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java index 990eab246..c012d28c9 100644 --- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java +++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java @@ -195,9 +195,9 @@ public ITDatastoreTest( KEY4 = Key.newBuilder(KEY2).setName("newName1").setNamespace(NAMESPACE).build(); KEY5 = Key.newBuilder(KEY2).setName("newName2").setNamespace(NAMESPACE).build(); KEY6 = - Key.newBuilder(options.getProjectId(), KIND2, 100, options.getDatabaseId()) - .setNamespace(NAMESPACE) - .build(); + Key.newBuilder(options.getProjectId(), KIND2, 100, options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build(); LIST_VALUE2 = ListValue.of(Collections.singletonList(KeyValue.of(KEY1)));