@Test public void startTransactionsResponseHasCorrectLeasedLock() { Lease lease = getLease(); when(timelock.startTransactions(any())).thenReturn(startTransactionsResponseWith(LOCK_TOKEN, lease)); StartTransactionResponseV4 clientResponse = lockLeaseService.startTransactions(2); verify(timelock).startTransactions(any()); LeasedLockToken leasedLock = (LeasedLockToken) clientResponse.immutableTimestamp().getLock(); assertThat(leasedLock.serverToken()).isEqualTo(LOCK_TOKEN); assertThat(leasedLock.getLease()).isEqualTo(lease); }
StartTransactionResponseV4 startTransactions(int batchSize) { ConjureStartTransactionsRequest request = ConjureStartTransactionsRequest.builder() .requestorId(clientId) .requestId(UUID.randomUUID()) .numTransactions(batchSize) .lastKnownVersion(Optional.empty()) .build(); ConjureStartTransactionsResponse conjureResponse = delegate.startTransactions(request); StartTransactionResponseV4 response = StartTransactionResponseV4.of( conjureResponse.getImmutableTimestamp(), conjureResponse.getTimestamps(), conjureResponse.getLease()); Lease lease = response.lease(); LeasedLockToken leasedLockToken = LeasedLockToken.of(ConjureLockToken.of(response.immutableTimestamp().getLock().getRequestId()), lease); long immutableTs = response.immutableTimestamp().getImmutableTimestamp(); return StartTransactionResponseV4.of( LockImmutableTimestampResponse.of(immutableTs, leasedLockToken), response.timestamps(), lease); }
LockLeaseService { StartTransactionResponseV4 startTransactions(int batchSize) { ConjureStartTransactionsRequest request = ConjureStartTransactionsRequest.builder() .requestorId(clientId) .requestId(UUID.randomUUID()) .numTransactions(batchSize) .lastKnownVersion(Optional.empty()) .build(); ConjureStartTransactionsResponse conjureResponse = delegate.startTransactions(request); StartTransactionResponseV4 response = StartTransactionResponseV4.of( conjureResponse.getImmutableTimestamp(), conjureResponse.getTimestamps(), conjureResponse.getLease()); Lease lease = response.lease(); LeasedLockToken leasedLockToken = LeasedLockToken.of(ConjureLockToken.of(response.immutableTimestamp().getLock().getRequestId()), lease); long immutableTs = response.immutableTimestamp().getImmutableTimestamp(); return StartTransactionResponseV4.of( LockImmutableTimestampResponse.of(immutableTs, leasedLockToken), response.timestamps(), lease); } }
LockLeaseService { StartTransactionResponseV4 startTransactions(int batchSize) { ConjureStartTransactionsRequest request = ConjureStartTransactionsRequest.builder() .requestorId(clientId) .requestId(UUID.randomUUID()) .numTransactions(batchSize) .lastKnownVersion(Optional.empty()) .build(); ConjureStartTransactionsResponse conjureResponse = delegate.startTransactions(request); StartTransactionResponseV4 response = StartTransactionResponseV4.of( conjureResponse.getImmutableTimestamp(), conjureResponse.getTimestamps(), conjureResponse.getLease()); Lease lease = response.lease(); LeasedLockToken leasedLockToken = LeasedLockToken.of(ConjureLockToken.of(response.immutableTimestamp().getLock().getRequestId()), lease); long immutableTs = response.immutableTimestamp().getImmutableTimestamp(); return StartTransactionResponseV4.of( LockImmutableTimestampResponse.of(immutableTs, leasedLockToken), response.timestamps(), lease); } @VisibleForTesting  LockLeaseService(
            NamespacedConjureTimelockService delegate,
            UUID clientId); }
LockLeaseService { StartTransactionResponseV4 startTransactions(int batchSize) { ConjureStartTransactionsRequest request = ConjureStartTransactionsRequest.builder() .requestorId(clientId) .requestId(UUID.randomUUID()) .numTransactions(batchSize) .lastKnownVersion(Optional.empty()) .build(); ConjureStartTransactionsResponse conjureResponse = delegate.startTransactions(request); StartTransactionResponseV4 response = StartTransactionResponseV4.of( conjureResponse.getImmutableTimestamp(), conjureResponse.getTimestamps(), conjureResponse.getLease()); Lease lease = response.lease(); LeasedLockToken leasedLockToken = LeasedLockToken.of(ConjureLockToken.of(response.immutableTimestamp().getLock().getRequestId()), lease); long immutableTs = response.immutableTimestamp().getImmutableTimestamp(); return StartTransactionResponseV4.of( LockImmutableTimestampResponse.of(immutableTs, leasedLockToken), response.timestamps(), lease); } @VisibleForTesting  LockLeaseService(
            NamespacedConjureTimelockService delegate,
            UUID clientId);  }
LockLeaseService { StartTransactionResponseV4 startTransactions(int batchSize) { ConjureStartTransactionsRequest request = ConjureStartTransactionsRequest.builder() .requestorId(clientId) .requestId(UUID.randomUUID()) .numTransactions(batchSize) .lastKnownVersion(Optional.empty()) .build(); ConjureStartTransactionsResponse conjureResponse = delegate.startTransactions(request); StartTransactionResponseV4 response = StartTransactionResponseV4.of( conjureResponse.getImmutableTimestamp(), conjureResponse.getTimestamps(), conjureResponse.getLease()); Lease lease = response.lease(); LeasedLockToken leasedLockToken = LeasedLockToken.of(ConjureLockToken.of(response.immutableTimestamp().getLock().getRequestId()), lease); long immutableTs = response.immutableTimestamp().getImmutableTimestamp(); return StartTransactionResponseV4.of( LockImmutableTimestampResponse.of(immutableTs, leasedLockToken), response.timestamps(), lease); } @VisibleForTesting  LockLeaseService(
            NamespacedConjureTimelockService delegate,
            UUID clientId);   }