2727
2828import com .google .api .core .ApiFuture ;
2929import com .google .api .core .ApiFutures ;
30- import com .google .cloud .spanner .AsyncRunner .AsyncWork ;
3130import com .google .cloud .spanner .TransactionRunner .TransactionCallable ;
3231import java .util .concurrent .ExecutorService ;
3332import java .util .concurrent .Executors ;
@@ -57,14 +56,7 @@ public void testAsyncRunReturnsResultAndCommitResponse() {
5756
5857 AsyncRunnerImpl runner = new AsyncRunnerImpl (delegate );
5958 ApiFuture <Object > result =
60- runner .runAsync (
61- new AsyncWork <Object >() {
62- @ Override
63- public ApiFuture <Object > doWorkAsync (TransactionContext txn ) {
64- return ApiFutures .immediateFuture (expectedResult );
65- }
66- },
67- executor );
59+ runner .runAsync (txn -> ApiFutures .immediateFuture (expectedResult ), executor );
6860
6961 assertSame (expectedResult , get (result ));
7062 assertSame (expectedCommitResponse , get (runner .getCommitResponse ()));
@@ -105,14 +97,7 @@ public void testGetCommitResponseReturnsErrorIfRunFails() {
10597 when (delegate .getCommitResponse ()).thenThrow (expectedException );
10698
10799 AsyncRunnerImpl runner = new AsyncRunnerImpl (delegate );
108- runner .runAsync (
109- new AsyncWork <Void >() {
110- @ Override
111- public ApiFuture <Void > doWorkAsync (TransactionContext txn ) {
112- return ApiFutures .immediateFailedFuture (expectedException );
113- }
114- },
115- executor );
100+ runner .runAsync (txn -> ApiFutures .immediateFailedFuture (expectedException ), executor );
116101
117102 try {
118103 get (runner .getCommitResponse ());
@@ -130,24 +115,10 @@ public void testRunAyncFailsIfCalledMultipleTimes() {
130115 when (delegate .run (any (TransactionCallable .class ))).thenReturn (result );
131116
132117 AsyncRunnerImpl runner = new AsyncRunnerImpl (delegate );
133- runner .runAsync (
134- new AsyncWork <Object >() {
135- @ Override
136- public ApiFuture <Object > doWorkAsync (TransactionContext txn ) {
137- return ApiFutures .immediateFuture (result );
138- }
139- },
140- executor );
118+ runner .runAsync (txn -> ApiFutures .immediateFuture (result ), executor );
141119
142120 try {
143- runner .runAsync (
144- new AsyncWork <Object >() {
145- @ Override
146- public ApiFuture <Object > doWorkAsync (TransactionContext txn ) {
147- return ApiFutures .immediateFuture (null );
148- }
149- },
150- executor );
121+ runner .runAsync (txn -> ApiFutures .immediateFuture (null ), executor );
151122 fail ("missing expected exception" );
152123 } catch (IllegalStateException e ) {
153124 assertTrue (e .getMessage ().contains ("runAsync() can only be called once" ));
0 commit comments