@Test public void createReturnsNewSpannerConnection() { Client mockClient = Mockito.mock(Client.class); Session session = Session.newBuilder().setName("jam session").build(); when(mockClient.createSession("projects/a-project/instances/an-instance/databases/db")) .thenReturn(Mono.just(session)); SpannerConnectionFactory factory = new SpannerConnectionFactory(mockClient, this.config); Mono<SpannerConnection> connection = Mono.from(factory.create()); StepVerifier.create(connection.map(con -> con.getSessionName())) .expectNext("jam session") .verifyComplete(); }
@Override public Mono<SpannerConnection> create() { return this.client.createSession(this.config.getFullyQualifiedDatabaseName()) .map(session -> { SpannerConnection connection = new SpannerConnection(this.client, session, this.config); return connection; }); }
SpannerConnectionFactory implements ConnectionFactory { @Override public Mono<SpannerConnection> create() { return this.client.createSession(this.config.getFullyQualifiedDatabaseName()) .map(session -> { SpannerConnection connection = new SpannerConnection(this.client, session, this.config); return connection; }); } }
SpannerConnectionFactory implements ConnectionFactory { @Override public Mono<SpannerConnection> create() { return this.client.createSession(this.config.getFullyQualifiedDatabaseName()) .map(session -> { SpannerConnection connection = new SpannerConnection(this.client, session, this.config); return connection; }); } SpannerConnectionFactory(Client client, SpannerConnectionConfiguration config); }
SpannerConnectionFactory implements ConnectionFactory { @Override public Mono<SpannerConnection> create() { return this.client.createSession(this.config.getFullyQualifiedDatabaseName()) .map(session -> { SpannerConnection connection = new SpannerConnection(this.client, session, this.config); return connection; }); } SpannerConnectionFactory(Client client, SpannerConnectionConfiguration config); @Override Mono<SpannerConnection> create(); @Override ConnectionFactoryMetadata getMetadata(); }
SpannerConnectionFactory implements ConnectionFactory { @Override public Mono<SpannerConnection> create() { return this.client.createSession(this.config.getFullyQualifiedDatabaseName()) .map(session -> { SpannerConnection connection = new SpannerConnection(this.client, session, this.config); return connection; }); } SpannerConnectionFactory(Client client, SpannerConnectionConfiguration config); @Override Mono<SpannerConnection> create(); @Override ConnectionFactoryMetadata getMetadata();  }