// Path: cloud-spanner-r2dbc/src/main/java/com/google/cloud/spanner/r2dbc/BindingFailureException.java
// public class BindingFailureException extends R2dbcNonTransientException {
// 
//   public BindingFailureException(String message) {
//     super(message);
//   }
// }
// 
// Path: cloud-spanner-r2dbc/src/main/java/com/google/cloud/spanner/r2dbc/statement/TypedNull.java
// public class TypedNull {
// 
//   private final Class<?> type;
// 
//   public TypedNull(Class<?> type) {
//     this.type = type;
//   }
// 
//   public Class<?> getType() {
//     return this.type;
//   }
// }


import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.withPrecision;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import com.google.cloud.ByteArray;
import com.google.cloud.Date;
import com.google.cloud.Timestamp;
import com.google.cloud.spanner.Statement.Builder;
import com.google.cloud.spanner.Value;
import com.google.cloud.spanner.ValueBinder;
import com.google.cloud.spanner.r2dbc.BindingFailureException;
import com.google.cloud.spanner.r2dbc.statement.TypedNull;
import io.r2dbc.spi.Parameters;
import io.r2dbc.spi.R2dbcType;
import java.math.BigDecimal;
import java.util.Random;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
/*
 * Copyright 2019-2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.cloud.spanner.r2dbc.v2;



class ClientLibraryTypeBindersTest {
  ValueBinder valueBinder;

  ValueBinder nullBinder;

  Builder statementBuilder;

  @BeforeEach
  public void setUp() {
    this.valueBinder = Mockito.mock(ValueBinder.class);
    this.nullBinder = Mockito.mock(ValueBinder.class);

    this.statementBuilder = Mockito.mock(Builder.class);
    when(this.statementBuilder.bind("valueColumn")).thenReturn(this.valueBinder);
    when(this.statementBuilder.bind("nullColumn")).thenReturn(this.nullBinder);
  }

  @Test
  void unsupportedTypeThrowsException() {
    Random rand = new Random();
    assertThatThrownBy(() -> ClientLibraryBinder.bind(this.statementBuilder, "valueColumn", rand))
        .isInstanceOf(BindingFailureException.class)
        .hasMessageContaining("Can't find a binder for type: class java.util.Random");

// Path: cloud-spanner-r2dbc/src/main/java/com/google/cloud/spanner/r2dbc/BindingFailureException.java
// public class BindingFailureException extends R2dbcNonTransientException {
// 
//   public BindingFailureException(String message) {
//     super(message);
//   }
// }
// 
// Path: cloud-spanner-r2dbc/src/main/java/com/google/cloud/spanner/r2dbc/statement/TypedNull.java
// public class TypedNull {
// 
//   private final Class<?> type;
// 
//   public TypedNull(Class<?> type) {
//     this.type = type;
//   }
// 
//   public Class<?> getType() {
//     return this.type;
//   }
// }


// Path: cloud-spanner-r2dbc/src/test/java/com/google/cloud/spanner/r2dbc/v2/ClientLibraryTypeBindersTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.withPrecision;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import com.google.cloud.ByteArray;
import com.google.cloud.Date;
import com.google.cloud.Timestamp;
import com.google.cloud.spanner.Statement.Builder;
import com.google.cloud.spanner.Value;
import com.google.cloud.spanner.ValueBinder;
import com.google.cloud.spanner.r2dbc.BindingFailureException;
import com.google.cloud.spanner.r2dbc.statement.TypedNull;
import io.r2dbc.spi.Parameters;
import io.r2dbc.spi.R2dbcType;
import java.math.BigDecimal;
import java.util.Random;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;

/*
 * Copyright 2019-2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.cloud.spanner.r2dbc.v2;



class ClientLibraryTypeBindersTest {
  ValueBinder valueBinder;

  ValueBinder nullBinder;

  Builder statementBuilder;

  @BeforeEach
  public void setUp() {
    this.valueBinder = Mockito.mock(ValueBinder.class);
    this.nullBinder = Mockito.mock(ValueBinder.class);

    this.statementBuilder = Mockito.mock(Builder.class);
    when(this.statementBuilder.bind("valueColumn")).thenReturn(this.valueBinder);
    when(this.statementBuilder.bind("nullColumn")).thenReturn(this.nullBinder);
  }

  @Test
  void unsupportedTypeThrowsException() {
    Random rand = new Random();
    assertThatThrownBy(() -> ClientLibraryBinder.bind(this.statementBuilder, "valueColumn", rand))
        .isInstanceOf(BindingFailureException.class)
        .hasMessageContaining("Can't find a binder for type: class java.util.Random");

    TypedNull randNull = new TypedNull(Random.class);