/** * * * <pre> * Required. The session in which the transaction runs. * </pre> * * <code>string session = 1;</code> */ public Builder clearSession() { session_ = getDefaultInstance().getSession(); onChanged(); return this; } /**
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.spanner.v1.BeginTransactionRequest)) { return super.equals(obj); } com.google.spanner.v1.BeginTransactionRequest other = (com.google.spanner.v1.BeginTransactionRequest) obj; boolean result = true; result = result && getSession().equals(other.getSession()); result = result && (hasOptions() == other.hasOptions()); if (hasOptions()) { result = result && getOptions().equals(other.getOptions()); } result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + SESSION_FIELD_NUMBER; hash = (53 * hash) + getSession().hashCode(); if (hasOptions()) { hash = (37 * hash) + OPTIONS_FIELD_NUMBER; hash = (53 * hash) + getOptions().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Override public Transaction beginTransaction( BeginTransactionRequest request, @Nullable Map<Option, ?> options) throws SpannerException { GrpcCallContext context = newCallContext(options, request.getSession()); return get(spannerStub.beginTransactionCallable().futureCall(request, context)); }
public Builder mergeFrom(com.google.spanner.v1.BeginTransactionRequest other) { if (other == com.google.spanner.v1.BeginTransactionRequest.getDefaultInstance()) return this; if (!other.getSession().isEmpty()) { session_ = other.session_; onChanged(); } if (other.hasOptions()) { mergeOptions(other.getOptions()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@Test @SuppressWarnings("all") public void beginTransactionTest() { ByteString id = ByteString.copyFromUtf8("27"); Transaction expectedResponse = Transaction.newBuilder().setId(id).build(); mockSpanner.addResponse(expectedResponse); SessionName session = SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"); TransactionOptions options = TransactionOptions.newBuilder().build(); Transaction actualResponse = client.beginTransaction(session, options); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockSpanner.getRequests(); Assert.assertEquals(1, actualRequests.size()); BeginTransactionRequest actualRequest = (BeginTransactionRequest) actualRequests.get(0); Assert.assertEquals(session, SessionName.parse(actualRequest.getSession())); Assert.assertEquals(options, actualRequest.getOptions()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Override public Transaction beginTransaction( BeginTransactionRequest request, @Nullable Map<Option, ?> options) throws SpannerException { GrpcCallContext context = newCallContext(options, request.getSession()); return get(spannerStub.beginTransactionCallable().futureCall(request, context)); }