Skip to content

Commit

Permalink
Elevate access level to support mocking (#3562)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Aug 15, 2018
1 parent 5281f1b commit a879ecf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public class DocumentReference {
private final ResourcePath path;
private final FirestoreImpl firestore;

DocumentReference(FirestoreImpl firestore, ResourcePath path) {
protected DocumentReference(
FirestoreImpl firestore, ResourcePath path) { // Elevated access level for mocking.
this.path = path;
this.firestore = firestore;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public class DocumentSnapshot {
@Nullable private final Timestamp updateTime;
@Nullable private final Timestamp createTime;

DocumentSnapshot(
protected DocumentSnapshot(
FirestoreImpl firestore,
DocumentReference docRef,
@Nullable Map<String, Value> fields,
@Nullable Timestamp readTime,
@Nullable Timestamp updateTime,
@Nullable Timestamp createTime) {
@Nullable Timestamp createTime) { // Elevated access level for mocking.
this.firestore = firestore;
this.docRef = docRef;
this.fields = fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ public int hashCode() {
this(firestore, path, new QueryOptions());
}

private Query(FirestoreImpl firestore, ResourcePath path, QueryOptions queryOptions) {
protected Query(
FirestoreImpl firestore,
ResourcePath path,
QueryOptions queryOptions) { // Elevated access level for mocking.
Preconditions.checkArgument(
path.isCollection(), "Invalid path specified. Path should point to a collection");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
* that does so.
*/
public class QueryDocumentSnapshot extends DocumentSnapshot {
private QueryDocumentSnapshot(
protected QueryDocumentSnapshot(
FirestoreImpl firestore,
DocumentReference docRef,
Map<String, Value> fields,
Timestamp readTime,
Timestamp updateTime,
Timestamp createTime) {
Timestamp createTime) { // Elevated access level for mocking.
super(firestore, docRef, fields, readTime, updateTime, createTime);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class QuerySnapshot implements Iterable<QueryDocumentSnapshot> {
private final Query query;
private final Timestamp readTime;

private QuerySnapshot(Query query, Timestamp readTime) {
protected QuerySnapshot(Query query, Timestamp readTime) { // Elevated access level for mocking.
this.query = query;
this.readTime = readTime;
}
Expand Down

0 comments on commit a879ecf

Please sign in to comment.