From f287462fd9edda07a34658be91f04421357f6519 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Tue, 26 Jan 2016 17:08:05 -0800 Subject: [PATCH] Minor refactoring and javadoc fixes --- .../google/gcloud/datastore/EntityQuery.java | 2 +- .../com/google/gcloud/datastore/KeyQuery.java | 2 +- .../datastore/ProjectionEntityQuery.java | 9 +++++++- .../gcloud/datastore/StructuredQueryTest.java | 21 +++++-------------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/EntityQuery.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/EntityQuery.java index cc2b978603ed..902168f20f48 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/EntityQuery.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/EntityQuery.java @@ -30,7 +30,7 @@ public final class EntityQuery extends StructuredQuery { private static final long serialVersionUID = 2990565454831019471L; /** - * A {@code EntityQuery} builder for queries that return Entity results. + * A {@code EntityQuery} builder for queries that return {@link Entity} results. */ public static final class Builder extends StructuredQuery.BuilderImpl { diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/KeyQuery.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/KeyQuery.java index 73ee9a4481aa..7afa0f5099d6 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/KeyQuery.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/KeyQuery.java @@ -30,7 +30,7 @@ public final class KeyQuery extends StructuredQuery { private static final long serialVersionUID = -746768461459070045L; /** - * A {@code KeyQuery} builder for queries that return Key results. + * A {@code KeyQuery} builder for queries that return {@link Key} results. */ public static final class Builder extends StructuredQuery.BuilderImpl { diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ProjectionEntityQuery.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ProjectionEntityQuery.java index c0f8617f9183..bad9fc5af2d0 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ProjectionEntityQuery.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ProjectionEntityQuery.java @@ -28,7 +28,8 @@ public final class ProjectionEntityQuery extends StructuredQuery { @@ -43,6 +44,7 @@ public static final class Builder extends StructuredQuery.BuilderImpl entityQuery = - Query.entityQueryBuilder().namespace("n1").kind("k1").build(); - Query entityQueryResult = entityQuery.toBuilder().build(); - StructuredQuery keyQuery = Query.keyQueryBuilder().namespace("n2").kind("k2").build(); - Query keyQueryResult = keyQuery.toBuilder().build(); - StructuredQuery projectionEntityQuery = Query.projectionEntityQueryBuilder() - .kind("k3") - .projection(Projection.property("p1"), Projection.property("p2")) - .build(); - Query projectionEntityQueryResult = projectionEntityQuery.toBuilder().build(); - assertEquals(entityQuery, entityQueryResult); - assertTrue(entityQueryResult instanceof EntityQuery); - assertEquals(keyQuery, keyQueryResult); - assertTrue(keyQueryResult instanceof KeyQuery); - assertEquals(projectionEntityQuery, projectionEntityQueryResult); - assertTrue(projectionEntityQueryResult instanceof ProjectionEntityQuery); + List> queries = + ImmutableList.>of(ENTITY_QUERY, KEY_QUERY, PROJECTION_QUERY); + for (StructuredQuery query : queries) { + assertEquals(query, query.toBuilder().build()); + } } @Test