diff --git a/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java b/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java index 37776a3d0e1..7cd34c998b9 100644 --- a/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java +++ b/firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java @@ -15,7 +15,7 @@ package com.google.firebase.firestore.testutil; import com.google.firebase.Timestamp; -import com.google.firebase.firestore.UserDataConverter; +import com.google.firebase.firestore.UserDataReader; import com.google.firebase.firestore.core.Query; import com.google.firebase.firestore.model.DatabaseId; import com.google.firebase.firestore.model.Document; @@ -33,10 +33,10 @@ public class TestUtil { public static FieldValue wrap(Object value) { DatabaseId databaseId = DatabaseId.forProject("project"); - UserDataConverter dataConverter = new UserDataConverter(databaseId); + UserDataReader dataReader = new UserDataReader(databaseId); // HACK: We use parseQueryValue() since it accepts scalars as well as arrays / objects, and // our tests currently use wrap() pretty generically so we don't know the intent. - return dataConverter.parseQueryValue(value); + return dataReader.parseQueryValue(value); } public static ObjectValue wrapObject(Map value) { diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/DocumentReference.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/DocumentReference.java index a43f1159e22..6bfc47b40a4 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/DocumentReference.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/DocumentReference.java @@ -162,8 +162,8 @@ public Task set(@NonNull Object data, @NonNull SetOptions options) { checkNotNull(options, "Provided options must not be null."); ParsedSetData parsed = options.isMerge() - ? firestore.getDataConverter().parseMergeData(data, options.getFieldMask()) - : firestore.getDataConverter().parseSetData(data); + ? firestore.getUserDataReader().parseMergeData(data, options.getFieldMask()) + : firestore.getUserDataReader().parseSetData(data); return firestore .getClient() .write(parsed.toMutationList(key, Precondition.NONE)) @@ -180,7 +180,7 @@ public Task set(@NonNull Object data, @NonNull SetOptions options) { */ @NonNull public Task update(@NonNull Map data) { - ParsedUpdateData parsedData = firestore.getDataConverter().parseUpdateData(data); + ParsedUpdateData parsedData = firestore.getUserDataReader().parseUpdateData(data); return update(parsedData); } @@ -199,7 +199,7 @@ public Task update( @NonNull String field, @Nullable Object value, Object... moreFieldsAndValues) { ParsedUpdateData parsedData = firestore - .getDataConverter() + .getUserDataReader() .parseUpdateData( Util.collectUpdateArguments( /* fieldPathOffset= */ 1, field, value, moreFieldsAndValues)); @@ -220,7 +220,7 @@ public Task update( @NonNull FieldPath fieldPath, @Nullable Object value, Object... moreFieldsAndValues) { ParsedUpdateData parsedData = firestore - .getDataConverter() + .getUserDataReader() .parseUpdateData( Util.collectUpdateArguments( /* fieldPathOffset= */ 1, fieldPath, value, moreFieldsAndValues)); diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/DocumentSnapshot.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/DocumentSnapshot.java index 55efc8f2271..73e2e891b7a 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/DocumentSnapshot.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/DocumentSnapshot.java @@ -19,21 +19,11 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.firebase.Timestamp; -import com.google.firebase.firestore.model.DatabaseId; import com.google.firebase.firestore.model.Document; import com.google.firebase.firestore.model.DocumentKey; -import com.google.firebase.firestore.model.value.ArrayValue; import com.google.firebase.firestore.model.value.FieldValue; -import com.google.firebase.firestore.model.value.ObjectValue; -import com.google.firebase.firestore.model.value.ReferenceValue; -import com.google.firebase.firestore.model.value.ServerTimestampValue; -import com.google.firebase.firestore.model.value.TimestampValue; import com.google.firebase.firestore.util.CustomClassMapper; -import com.google.firebase.firestore.util.Logger; -import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -78,18 +68,6 @@ public enum ServerTimestampBehavior { static final ServerTimestampBehavior DEFAULT = ServerTimestampBehavior.NONE; } - /** Holds settings that define field value deserialization options. */ - static class FieldValueOptions { - final ServerTimestampBehavior serverTimestampBehavior; - final boolean timestampsInSnapshotsEnabled; - - private FieldValueOptions( - ServerTimestampBehavior serverTimestampBehavior, boolean timestampsInSnapshotsEnabled) { - this.serverTimestampBehavior = serverTimestampBehavior; - this.timestampsInSnapshotsEnabled = timestampsInSnapshotsEnabled; - } - } - private final FirebaseFirestore firestore; private final DocumentKey key; @@ -166,13 +144,12 @@ public Map getData() { public Map getData(@NonNull ServerTimestampBehavior serverTimestampBehavior) { checkNotNull( serverTimestampBehavior, "Provided serverTimestampBehavior value must not be null."); - return doc == null - ? null - : convertObject( - doc.getData(), - new FieldValueOptions( - serverTimestampBehavior, - firestore.getFirestoreSettings().areTimestampsInSnapshotsEnabled())); + UserDataWriter userDataWriter = + new UserDataWriter( + firestore, + firestore.getFirestoreSettings().areTimestampsInSnapshotsEnabled(), + serverTimestampBehavior); + return doc == null ? null : userDataWriter.convertObject(doc.getData()); } /** @@ -285,9 +262,8 @@ public Object get( serverTimestampBehavior, "Provided serverTimestampBehavior value must not be null."); return getInternal( fieldPath.getInternalPath(), - new FieldValueOptions( - serverTimestampBehavior, - firestore.getFirestoreSettings().areTimestampsInSnapshotsEnabled())); + serverTimestampBehavior, + firestore.getFirestoreSettings().areTimestampsInSnapshotsEnabled()); } /** @@ -438,8 +414,8 @@ public Date getDate( Object maybeDate = getInternal( FieldPath.fromDotSeparatedPath(field).getInternalPath(), - new FieldValueOptions( - serverTimestampBehavior, /*timestampsInSnapshotsEnabled=*/ false)); + serverTimestampBehavior, + /* timestampsInSnapshots= */ false); return castTypedValue(maybeDate, field, Date.class); } @@ -479,7 +455,8 @@ public Timestamp getTimestamp( Object maybeTimestamp = getInternal( FieldPath.fromDotSeparatedPath(field).getInternalPath(), - new FieldValueOptions(serverTimestampBehavior, /*timestampsInSnapshotsEnabled=*/ true)); + serverTimestampBehavior, + /* timestampsInSnapshots= */ true); return castTypedValue(maybeTimestamp, field, Timestamp.class); } @@ -546,87 +523,17 @@ private T castTypedValue(Object value, String field, Class clazz) { return clazz.cast(value); } - @Nullable - private Object convertValue(FieldValue value, FieldValueOptions options) { - if (value instanceof ObjectValue) { - return convertObject((ObjectValue) value, options); - } else if (value instanceof ArrayValue) { - return convertArray((ArrayValue) value, options); - } else if (value instanceof ReferenceValue) { - return convertReference((ReferenceValue) value); - } else if (value instanceof TimestampValue) { - return convertTimestamp((TimestampValue) value, options); - } else if (value instanceof ServerTimestampValue) { - return convertServerTimestamp((ServerTimestampValue) value, options); - } else { - return value.value(); - } - } - - private Object convertServerTimestamp(ServerTimestampValue value, FieldValueOptions options) { - switch (options.serverTimestampBehavior) { - case PREVIOUS: - return value.getPreviousValue(); - case ESTIMATE: - return value.getLocalWriteTime(); - default: - return value.value(); - } - } - - private Object convertTimestamp(TimestampValue value, FieldValueOptions options) { - Timestamp timestamp = value.value(); - if (options.timestampsInSnapshotsEnabled) { - return timestamp; - } else { - return timestamp.toDate(); - } - } - - private Object convertReference(ReferenceValue value) { - DocumentKey key = value.value(); - DatabaseId refDatabase = value.getDatabaseId(); - DatabaseId database = this.firestore.getDatabaseId(); - if (!refDatabase.equals(database)) { - // TODO: Somehow support foreign references. - Logger.warn( - "DocumentSnapshot", - "Document %s contains a document reference within a different database " - + "(%s/%s) which is not supported. It will be treated as a reference in " - + "the current database (%s/%s) instead.", - key.getPath(), - refDatabase.getProjectId(), - refDatabase.getDatabaseId(), - database.getProjectId(), - database.getDatabaseId()); - } - return new DocumentReference(key, firestore); - } - - private Map convertObject(ObjectValue objectValue, FieldValueOptions options) { - Map result = new HashMap<>(); - for (Map.Entry entry : objectValue.getInternalValue()) { - result.put(entry.getKey(), convertValue(entry.getValue(), options)); - } - return result; - } - - private List convertArray(ArrayValue arrayValue, FieldValueOptions options) { - ArrayList result = new ArrayList<>(arrayValue.getInternalValue().size()); - for (FieldValue v : arrayValue.getInternalValue()) { - result.add(convertValue(v, options)); - } - return result; - } - @Nullable private Object getInternal( @NonNull com.google.firebase.firestore.model.FieldPath fieldPath, - @NonNull FieldValueOptions options) { + @NonNull ServerTimestampBehavior serverTimestampBehavior, + boolean timestampsInSnapshots) { if (doc != null) { FieldValue val = doc.getField(fieldPath); if (val != null) { - return convertValue(val, options); + UserDataWriter userDataWriter = + new UserDataWriter(firestore, timestampsInSnapshots, serverTimestampBehavior); + return userDataWriter.convertValue(val); } } return null; diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java index b780058cea7..1bc22b61619 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java @@ -74,7 +74,7 @@ public interface InstanceRegistry { private final CredentialsProvider credentialsProvider; private final AsyncQueue asyncQueue; private final FirebaseApp firebaseApp; - private final UserDataConverter dataConverter; + private final UserDataReader userDataReader; // When user requests to terminate, use this to notify `FirestoreMultiDbComponent` to deregister // this instance. private final InstanceRegistry instanceRegistry; @@ -160,7 +160,7 @@ static FirebaseFirestore newInstance( @Nullable GrpcMetadataProvider metadataProvider) { this.context = checkNotNull(context); this.databaseId = checkNotNull(checkNotNull(databaseId)); - this.dataConverter = new UserDataConverter(databaseId); + this.userDataReader = new UserDataReader(databaseId); this.persistenceKey = checkNotNull(persistenceKey); this.credentialsProvider = checkNotNull(credentialsProvider); this.asyncQueue = checkNotNull(asyncQueue); @@ -577,8 +577,8 @@ DatabaseId getDatabaseId() { return databaseId; } - UserDataConverter getDataConverter() { - return dataConverter; + UserDataReader getUserDataReader() { + return userDataReader; } /** diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/Query.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/Query.java index c9672ea7b58..e8c81958e09 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/Query.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/Query.java @@ -348,7 +348,7 @@ private Query whereHelper(@NonNull FieldPath fieldPath, Operator op, Object valu if (op == Operator.IN || op == Operator.ARRAY_CONTAINS_ANY) { validateDisjunctiveFilterElements(value, op); } - fieldValue = firestore.getDataConverter().parseQueryValue(value, op == Operator.IN); + fieldValue = firestore.getUserDataReader().parseQueryValue(value, op == Operator.IN); } Filter filter = FieldFilter.create(fieldPath.getInternalPath(), op, fieldValue); validateNewFilter(filter); @@ -821,7 +821,7 @@ private Bound boundFromFields(String methodName, Object[] values, boolean before DocumentKey key = DocumentKey.fromPath(path); components.add(ReferenceValue.valueOf(firestore.getDatabaseId(), key)); } else { - FieldValue wrapped = firestore.getDataConverter().parseQueryValue(rawValue); + FieldValue wrapped = firestore.getUserDataReader().parseQueryValue(rawValue); components.add(wrapped); } } diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/Transaction.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/Transaction.java index f7a0e04f760..7ec75300883 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/Transaction.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/Transaction.java @@ -86,8 +86,8 @@ public Transaction set( checkNotNull(options, "Provided options must not be null."); ParsedSetData parsed = options.isMerge() - ? firestore.getDataConverter().parseMergeData(data, options.getFieldMask()) - : firestore.getDataConverter().parseSetData(data); + ? firestore.getUserDataReader().parseMergeData(data, options.getFieldMask()) + : firestore.getUserDataReader().parseSetData(data); transaction.set(documentRef.getKey(), parsed); return this; } @@ -104,7 +104,7 @@ public Transaction set( @NonNull public Transaction update( @NonNull DocumentReference documentRef, @NonNull Map data) { - ParsedUpdateData parsedData = firestore.getDataConverter().parseUpdateData(data); + ParsedUpdateData parsedData = firestore.getUserDataReader().parseUpdateData(data); return update(documentRef, parsedData); } @@ -127,7 +127,7 @@ public Transaction update( Object... moreFieldsAndValues) { ParsedUpdateData parsedData = firestore - .getDataConverter() + .getUserDataReader() .parseUpdateData( Util.collectUpdateArguments( /* fieldPathOffset= */ 1, field, value, moreFieldsAndValues)); @@ -152,7 +152,7 @@ public Transaction update( Object... moreFieldsAndValues) { ParsedUpdateData parsedData = firestore - .getDataConverter() + .getUserDataReader() .parseUpdateData( Util.collectUpdateArguments( /* fieldPathOffset= */ 1, fieldPath, value, moreFieldsAndValues)); diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataConverter.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataReader.java similarity index 99% rename from firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataConverter.java rename to firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataReader.java index 62fd0987f0b..cdd7f4acdde 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataConverter.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataReader.java @@ -65,11 +65,11 @@ * @hide */ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) -public final class UserDataConverter { +public final class UserDataReader { private final DatabaseId databaseId; - public UserDataConverter(DatabaseId databaseId) { + public UserDataReader(DatabaseId databaseId) { this.databaseId = databaseId; } @@ -398,7 +398,6 @@ private void parseSentinelFieldValue( * @return The parsed value, or {@code null} if the value was a FieldValue sentinel that should * not be included in the resulting parsed data. */ - @Nullable private FieldValue parseScalarValue(Object input, ParseContext context) { if (input == null) { return NullValue.nullValue(); diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataWriter.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataWriter.java new file mode 100644 index 00000000000..e9dbaa351a5 --- /dev/null +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataWriter.java @@ -0,0 +1,126 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.firebase.firestore; + +import androidx.annotation.Nullable; +import androidx.annotation.RestrictTo; +import com.google.firebase.Timestamp; +import com.google.firebase.firestore.model.DatabaseId; +import com.google.firebase.firestore.model.DocumentKey; +import com.google.firebase.firestore.model.value.ArrayValue; +import com.google.firebase.firestore.model.value.FieldValue; +import com.google.firebase.firestore.model.value.ObjectValue; +import com.google.firebase.firestore.model.value.ReferenceValue; +import com.google.firebase.firestore.model.value.ServerTimestampValue; +import com.google.firebase.firestore.model.value.TimestampValue; +import com.google.firebase.firestore.util.Logger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Converts Firestore's internal types to the Java API types that we expose to the user. + * + * @hide + */ +@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) +public class UserDataWriter { + private final FirebaseFirestore firestore; + private final boolean timestampsInSnapshots; + private final DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior; + + UserDataWriter( + FirebaseFirestore firestore, + boolean timestampsInSnapshots, + DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior) { + this.firestore = firestore; + this.timestampsInSnapshots = timestampsInSnapshots; + this.serverTimestampBehavior = serverTimestampBehavior; + } + + @Nullable + Object convertValue(FieldValue value) { + if (value instanceof ObjectValue) { + return convertObject((ObjectValue) value); + } else if (value instanceof com.google.firebase.firestore.model.value.ArrayValue) { + return convertArray((com.google.firebase.firestore.model.value.ArrayValue) value); + } else if (value instanceof ReferenceValue) { + return convertReference((ReferenceValue) value); + } else if (value instanceof TimestampValue) { + return convertTimestamp((TimestampValue) value); + } else if (value instanceof ServerTimestampValue) { + return convertServerTimestamp((ServerTimestampValue) value); + } else { + return value.value(); + } + } + + Map convertObject(ObjectValue objectValue) { + Map result = new HashMap<>(); + for (Map.Entry entry : objectValue.getInternalValue()) { + result.put(entry.getKey(), convertValue(entry.getValue())); + } + return result; + } + + private Object convertServerTimestamp(ServerTimestampValue value) { + switch (serverTimestampBehavior) { + case PREVIOUS: + return value.getPreviousValue(); + case ESTIMATE: + return value.getLocalWriteTime(); + default: + return value.value(); + } + } + + private Object convertTimestamp(TimestampValue value) { + Timestamp timestamp = value.value(); + if (timestampsInSnapshots) { + return timestamp; + } else { + return timestamp.toDate(); + } + } + + private List convertArray(ArrayValue arrayValue) { + ArrayList result = new ArrayList<>(arrayValue.getInternalValue().size()); + for (FieldValue v : arrayValue.getInternalValue()) { + result.add(convertValue(v)); + } + return result; + } + + protected Object convertReference(ReferenceValue value) { + DocumentKey key = value.value(); + DatabaseId refDatabase = value.getDatabaseId(); + DatabaseId database = this.firestore.getDatabaseId(); + if (!refDatabase.equals(database)) { + // TODO: Somehow support foreign references. + Logger.warn( + "DocumentSnapshot", + "Document %s contains a document reference within a different database " + + "(%s/%s) which is not supported. It will be treated as a reference in " + + "the current database (%s/%s) instead.", + key.getPath(), + refDatabase.getProjectId(), + refDatabase.getDatabaseId(), + database.getProjectId(), + database.getDatabaseId()); + } + return new DocumentReference(key, firestore); + } +} diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/WriteBatch.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/WriteBatch.java index 9667c15a282..7611f84d0cb 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/WriteBatch.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/WriteBatch.java @@ -86,8 +86,8 @@ public WriteBatch set( verifyNotCommitted(); ParsedSetData parsed = options.isMerge() - ? firestore.getDataConverter().parseMergeData(data, options.getFieldMask()) - : firestore.getDataConverter().parseSetData(data); + ? firestore.getUserDataReader().parseMergeData(data, options.getFieldMask()) + : firestore.getUserDataReader().parseSetData(data); mutations.addAll(parsed.toMutationList(documentRef.getKey(), Precondition.NONE)); return this; } @@ -104,7 +104,7 @@ public WriteBatch set( @NonNull public WriteBatch update( @NonNull DocumentReference documentRef, @NonNull Map data) { - ParsedUpdateData parsedData = firestore.getDataConverter().parseUpdateData(data); + ParsedUpdateData parsedData = firestore.getUserDataReader().parseUpdateData(data); return update(documentRef, parsedData); } @@ -127,7 +127,7 @@ public WriteBatch update( Object... moreFieldsAndValues) { ParsedUpdateData parsedData = firestore - .getDataConverter() + .getUserDataReader() .parseUpdateData( Util.collectUpdateArguments( /* fieldPathOffset= */ 1, field, value, moreFieldsAndValues)); @@ -152,7 +152,7 @@ public WriteBatch update( Object... moreFieldsAndValues) { ParsedUpdateData parsedData = firestore - .getDataConverter() + .getUserDataReader() .parseUpdateData( Util.collectUpdateArguments( /* fieldPathOffset= */ 1, fieldPath, value, moreFieldsAndValues)); diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/UserDataConverterTest.java b/firebase-firestore/src/test/java/com/google/firebase/firestore/UserDataReaderTest.java similarity index 99% rename from firebase-firestore/src/test/java/com/google/firebase/firestore/UserDataConverterTest.java rename to firebase-firestore/src/test/java/com/google/firebase/firestore/UserDataReaderTest.java index e5898e763cd..3af2b7c732c 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/UserDataConverterTest.java +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/UserDataReaderTest.java @@ -51,7 +51,7 @@ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) -public class UserDataConverterTest { +public class UserDataReaderTest { @Test public void testConvertsNullValue() { diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/model/MutationTest.java b/firebase-firestore/src/test/java/com/google/firebase/firestore/model/MutationTest.java index 3e4ea899d15..363bbfbfdb8 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/model/MutationTest.java +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/model/MutationTest.java @@ -303,7 +303,7 @@ public void testAppliesIncrementWithoutUnderflow() { verifyTransform(baseDoc, transform, expected); } - // NOTE: This is more a test of UserDataConverter code than Mutation code but we don't have unit + // NOTE: This is more a test of UserDataReader code than Mutation code but we don't have unit // tests for it currently. We could consider removing this test once we have integration tests. @Test public void testCreateArrayUnionTransform() { @@ -330,7 +330,7 @@ public void testCreateArrayUnionTransform() { second.getOperation()); } - // NOTE: This is more a test of UserDataConverter code than Mutation code but + // NOTE: This is more a test of UserDataReader code than Mutation code but // we don't have unit tests for it currently. We could consider removing this // test once we have integration tests. @Test diff --git a/firebase-firestore/src/testUtil/java/com/google/firebase/firestore/testutil/TestUtil.java b/firebase-firestore/src/testUtil/java/com/google/firebase/firestore/testutil/TestUtil.java index 5ef8a589900..9badff4a44c 100644 --- a/firebase-firestore/src/testUtil/java/com/google/firebase/firestore/testutil/TestUtil.java +++ b/firebase-firestore/src/testUtil/java/com/google/firebase/firestore/testutil/TestUtil.java @@ -33,7 +33,7 @@ import com.google.firebase.firestore.Blob; import com.google.firebase.firestore.DocumentReference; import com.google.firebase.firestore.TestAccessHelper; -import com.google.firebase.firestore.UserDataConverter; +import com.google.firebase.firestore.UserDataReader; import com.google.firebase.firestore.core.FieldFilter; import com.google.firebase.firestore.core.Filter; import com.google.firebase.firestore.core.Filter.Operator; @@ -128,10 +128,10 @@ public static FieldMask fieldMask(String... fields) { public static FieldValue wrap(Object value) { DatabaseId databaseId = DatabaseId.forProject("project"); - UserDataConverter dataConverter = new UserDataConverter(databaseId); + UserDataReader dataReader = new UserDataReader(databaseId); // HACK: We use parseQueryValue() since it accepts scalars as well as arrays / objects, and // our tests currently use wrap() pretty generically so we don't know the intent. - return dataConverter.parseQueryValue(value); + return dataReader.parseQueryValue(value); } public static ObjectValue wrapObject(Map value) { @@ -517,8 +517,8 @@ public static VerifyMutation verifyMutation(String path, int micros) { * must not contain any non-sentinel data. */ public static TransformMutation transformMutation(String path, Map data) { - UserDataConverter dataConverter = new UserDataConverter(DatabaseId.forProject("project")); - ParsedUpdateData result = dataConverter.parseUpdateData(data); + UserDataReader dataReader = new UserDataReader(DatabaseId.forProject("project")); + ParsedUpdateData result = dataReader.parseUpdateData(data); // The order of the transforms doesn't matter, but we sort them so tests can assume a particular // order.