Search in sources :

Example 1 with CloudSpannerStatement

use of nl.topicus.jdbc.statement.CloudSpannerStatement in project spanner-jdbc by olavloite.

the class CloudSpannerResultSetMetaDataTest method setup.

@Before
public void setup() throws SQLException {
    connection = mock(CloudSpannerConnection.class);
    CloudSpannerStatement statement = mock(CloudSpannerStatement.class);
    CloudSpannerResultSet resultSet = getFooTestResultSet(statement);
    CloudSpannerDatabaseMetaData metadata = mock(CloudSpannerDatabaseMetaData.class);
    when(metadata.getColumns(eq(""), eq(""), eq("FOO"), any())).then(new Answer<CloudSpannerResultSet>() {

        @Override
        public CloudSpannerResultSet answer(InvocationOnMock invocation) throws Throwable {
            return createFooColumnsResultSet(statement, invocation.getArgument(3));
        }
    });
    when(metadata.getPrimaryKeys("", "", "FOO")).then(new Answer<CloudSpannerResultSet>() {

        @Override
        public CloudSpannerResultSet answer(InvocationOnMock invocation) throws Throwable {
            return createFooPrimaryKeysResultSet(statement);
        }
    });
    when(connection.getMetaData()).then(new Returns(metadata));
    when(connection.isReportDefaultSchemaAsNull()).thenCallRealMethod();
    when(connection.setReportDefaultSchemaAsNull(anyBoolean())).thenCallRealMethod();
    when(connection.getSchema()).thenCallRealMethod();
    when(connection.getCatalog()).thenCallRealMethod();
    when(statement.getConnection()).then(new Returns(connection));
    subject = resultSet.getMetaData();
}
Also used : CloudSpannerStatement(nl.topicus.jdbc.statement.CloudSpannerStatement) CloudSpannerDatabaseMetaData(nl.topicus.jdbc.CloudSpannerDatabaseMetaData) Returns(org.mockito.internal.stubbing.answers.Returns) InvocationOnMock(org.mockito.invocation.InvocationOnMock) CloudSpannerConnection(nl.topicus.jdbc.CloudSpannerConnection) Before(org.junit.Before)

Aggregations

CloudSpannerConnection (nl.topicus.jdbc.CloudSpannerConnection)1 CloudSpannerDatabaseMetaData (nl.topicus.jdbc.CloudSpannerDatabaseMetaData)1 CloudSpannerStatement (nl.topicus.jdbc.statement.CloudSpannerStatement)1 Before (org.junit.Before)1 Returns (org.mockito.internal.stubbing.answers.Returns)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1