@java.lang.Override public com.google.firestore.v1beta1.CommitRequest getDefaultInstanceForType() { return com.google.firestore.v1beta1.CommitRequest.getDefaultInstance(); }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + DATABASE_FIELD_NUMBER; hash = (53 * hash) + getDatabase().hashCode(); if (getWritesCount() > 0) { hash = (37 * hash) + WRITES_FIELD_NUMBER; hash = (53 * hash) + getWritesList().hashCode(); } hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; hash = (53 * hash) + getTransaction().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.firestore.v1beta1.CommitRequest)) { return super.equals(obj); } com.google.firestore.v1beta1.CommitRequest other = (com.google.firestore.v1beta1.CommitRequest) obj; boolean result = true; result = result && getDatabase().equals(other.getDatabase()); result = result && getWritesList().equals(other.getWritesList()); result = result && getTransaction().equals(other.getTransaction()); result = result && unknownFields.equals(other.unknownFields); return result; }
/** * * * <pre> * If set, applies all writes in this transaction, and commits it. * </pre> * * <code>bytes transaction = 3;</code> */ public Builder clearTransaction() { transaction_ = getDefaultInstance().getTransaction(); onChanged(); return this; }
public Builder mergeFrom(com.google.firestore.v1beta1.CommitRequest other) { if (other == com.google.firestore.v1beta1.CommitRequest.getDefaultInstance()) return this; if (!other.getDatabase().isEmpty()) { database_ = other.database_; onChanged(); if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { setTransaction(other.getTransaction());
/** * * * <pre> * The database name. In the format: * `projects/{project_id}/databases/{database_id}`. * </pre> * * <code>string database = 1;</code> */ public Builder clearDatabase() { database_ = getDefaultInstance().getDatabase(); onChanged(); return this; } /**
private void runCreateTest(CreateTest testCase) { doReturn(commitResponse(testCase.getRequest().getWritesCount(), 0)) .when(firestoreMock) .sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<Message, Message>>any()); try { ApiFuture<WriteResult> apiCall = document(testCase.getDocRefPath()).create(convertInput(testCase.getJsonData())); Assert.assertFalse(testCase.getIsError()); apiCall.get(); CommitRequest request = commitCapture.getValue(); Assert.assertEquals(testCase.getRequest(), request); } catch (Exception e) { Assert.assertTrue(testCase.getIsError()); } }
@Test @SuppressWarnings("all") public void commitTest() { CommitResponse expectedResponse = CommitResponse.newBuilder().build(); mockFirestore.addResponse(expectedResponse); String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]"); List<Write> writes = new ArrayList<>(); CommitResponse actualResponse = client.commit(formattedDatabase, writes); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); CommitRequest actualRequest = (CommitRequest) actualRequests.get(0); Assert.assertEquals(formattedDatabase, actualRequest.getDatabase()); Assert.assertEquals(writes, actualRequest.getWritesList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); }
public boolean matchesIgnoresName(CommitRequest o) { CommitRequest.Builder actual = o.toBuilder(); actual.getWritesBuilder(0).getUpdateBuilder().clearName().build(); CommitRequest.Builder expected = LocalFirestoreHelper.SINGLE_CREATE_COMMIT_REQUEST.toBuilder(); expected.getWritesBuilder(0).getUpdateBuilder().clearName().build(); return actual.build().equals(expected.build()); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.firestore.conformance.TestDefinition.CreateTest)) { return super.equals(obj); } com.google.cloud.firestore.conformance.TestDefinition.CreateTest other = (com.google.cloud.firestore.conformance.TestDefinition.CreateTest) obj; boolean result = true; result = result && getDocRefPath().equals(other.getDocRefPath()); result = result && getJsonData().equals(other.getJsonData()); result = result && (hasRequest() == other.hasRequest()); if (hasRequest()) { result = result && getRequest().equals(other.getRequest()); } result = result && (getIsError() == other.getIsError()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getDatabaseBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, database_); } for (int i = 0; i < writes_.size(); i++) { output.writeMessage(2, writes_.get(i)); } if (!transaction_.isEmpty()) { output.writeBytes(3, transaction_); } unknownFields.writeTo(output); }
@java.lang.Override public com.google.firestore.v1beta1.CommitRequest buildPartial() { com.google.firestore.v1beta1.CommitRequest result = new com.google.firestore.v1beta1.CommitRequest(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; result.database_ = database_; if (writesBuilder_ == null) { if (((bitField0_ & 0x00000002) == 0x00000002)) { writes_ = java.util.Collections.unmodifiableList(writes_); bitField0_ = (bitField0_ & ~0x00000002); } result.writes_ = writes_; } else { result.writes_ = writesBuilder_.build(); } result.transaction_ = transaction_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
private void runDeleteTest(DeleteTest testCase) throws ExecutionException, InterruptedException { doReturn(commitResponse(0, testCase.getRequest().getWritesCount())) .when(firestoreMock) .sendRequest(commitCapture.capture(), Matchers.<UnaryCallable<Message, Message>>any()); if (!testCase.hasPrecondition()) { document(testCase.getDocRefPath()).delete().get(); } else { document(testCase.getDocRefPath()) .delete(convertPrecondition(testCase.getPrecondition())) .get(); } CommitRequest request = commitCapture.getValue(); Assert.assertEquals(testCase.getRequest(), request); }
public static Builder newBuilder(com.google.firestore.v1beta1.CommitRequest prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.firestore.conformance.TestDefinition.UpdatePathsTest)) { return super.equals(obj); } com.google.cloud.firestore.conformance.TestDefinition.UpdatePathsTest other = (com.google.cloud.firestore.conformance.TestDefinition.UpdatePathsTest) obj; boolean result = true; result = result && getDocRefPath().equals(other.getDocRefPath()); result = result && (hasPrecondition() == other.hasPrecondition()); if (hasPrecondition()) { result = result && getPrecondition().equals(other.getPrecondition()); } result = result && getFieldPathsList().equals(other.getFieldPathsList()); result = result && getJsonValuesList().equals(other.getJsonValuesList()); result = result && (hasRequest() == other.hasRequest()); if (hasRequest()) { result = result && getRequest().equals(other.getRequest()); } result = result && (getIsError() == other.getIsError()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getDatabaseBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, database_); } for (int i = 0; i < writes_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, writes_.get(i)); } if (!transaction_.isEmpty()) { size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, transaction_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }