Search in sources :

Example 1 with SpannerSchemaUtils

use of org.springframework.cloud.gcp.data.spanner.core.admin.SpannerSchemaUtils in project spring-cloud-gcp by spring-cloud.

the class SpannerTemplateTests method setUp.

@Before
public void setUp() {
    this.databaseClient = mock(DatabaseClient.class);
    this.mappingContext = new SpannerMappingContext();
    this.objectMapper = mock(SpannerEntityProcessor.class);
    this.mutationFactory = mock(SpannerMutationFactory.class);
    this.schemaUtils = new SpannerSchemaUtils(this.mappingContext, this.objectMapper, true);
    this.readContext = mock(ReadContext.class);
    when(this.databaseClient.singleUse()).thenReturn(this.readContext);
    when(this.objectMapper.getWriteConverter()).thenReturn(new SpannerWriteConverter());
    this.spannerTemplate = new SpannerTemplate(() -> this.databaseClient, this.mappingContext, this.objectMapper, this.mutationFactory, this.schemaUtils);
}
Also used : SpannerEntityProcessor(org.springframework.cloud.gcp.data.spanner.core.convert.SpannerEntityProcessor) DatabaseClient(com.google.cloud.spanner.DatabaseClient) SpannerMappingContext(org.springframework.cloud.gcp.data.spanner.core.mapping.SpannerMappingContext) ReadContext(com.google.cloud.spanner.ReadContext) SpannerSchemaUtils(org.springframework.cloud.gcp.data.spanner.core.admin.SpannerSchemaUtils) SpannerWriteConverter(org.springframework.cloud.gcp.data.spanner.core.convert.SpannerWriteConverter) Before(org.junit.Before)

Example 2 with SpannerSchemaUtils

use of org.springframework.cloud.gcp.data.spanner.core.admin.SpannerSchemaUtils in project spring-cloud-gcp by spring-cloud.

the class SpannerMutationFactoryImplTests method setUp.

@Before
public void setUp() {
    this.mappingContext = new SpannerMappingContext();
    this.objectMapper = mock(SpannerEntityProcessor.class);
    this.spannerSchemaUtils = new SpannerSchemaUtils(this.mappingContext, this.objectMapper, true);
    this.spannerMutationFactory = new SpannerMutationFactoryImpl(this.objectMapper, this.mappingContext, this.spannerSchemaUtils);
}
Also used : SpannerEntityProcessor(org.springframework.cloud.gcp.data.spanner.core.convert.SpannerEntityProcessor) SpannerMappingContext(org.springframework.cloud.gcp.data.spanner.core.mapping.SpannerMappingContext) SpannerSchemaUtils(org.springframework.cloud.gcp.data.spanner.core.admin.SpannerSchemaUtils) Before(org.junit.Before)

Example 3 with SpannerSchemaUtils

use of org.springframework.cloud.gcp.data.spanner.core.admin.SpannerSchemaUtils in project spring-cloud-gcp by spring-cloud.

the class SqlSpannerQueryTests method initMocks.

@Before
public void initMocks() throws NoSuchMethodException {
    this.queryMethod = mock(SpannerQueryMethod.class);
    // this is a dummy object. it is not mockable otherwise.
    Method method = Object.class.getMethod("toString");
    when(this.queryMethod.getMethod()).thenReturn(method);
    when(this.spannerEntityProcessor.getWriteConverter()).thenReturn(new SpannerWriteConverter());
    this.spannerTemplate = spy(new SpannerTemplate(() -> this.databaseClient, this.spannerMappingContext, this.spannerEntityProcessor, mock(SpannerMutationFactory.class), new SpannerSchemaUtils(this.spannerMappingContext, this.spannerEntityProcessor, true)));
    this.expressionParser = new SpelExpressionParser();
    this.evaluationContextProvider = mock(QueryMethodEvaluationContextProvider.class);
}
Also used : SpannerMutationFactory(org.springframework.cloud.gcp.data.spanner.core.SpannerMutationFactory) SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) QueryMethodEvaluationContextProvider(org.springframework.data.repository.query.QueryMethodEvaluationContextProvider) SpannerTemplate(org.springframework.cloud.gcp.data.spanner.core.SpannerTemplate) SpannerSchemaUtils(org.springframework.cloud.gcp.data.spanner.core.admin.SpannerSchemaUtils) Method(java.lang.reflect.Method) SpannerWriteConverter(org.springframework.cloud.gcp.data.spanner.core.convert.SpannerWriteConverter) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)3 SpannerSchemaUtils (org.springframework.cloud.gcp.data.spanner.core.admin.SpannerSchemaUtils)3 SpannerEntityProcessor (org.springframework.cloud.gcp.data.spanner.core.convert.SpannerEntityProcessor)2 SpannerWriteConverter (org.springframework.cloud.gcp.data.spanner.core.convert.SpannerWriteConverter)2 SpannerMappingContext (org.springframework.cloud.gcp.data.spanner.core.mapping.SpannerMappingContext)2 DatabaseClient (com.google.cloud.spanner.DatabaseClient)1 ReadContext (com.google.cloud.spanner.ReadContext)1 Method (java.lang.reflect.Method)1 SpannerMutationFactory (org.springframework.cloud.gcp.data.spanner.core.SpannerMutationFactory)1 SpannerTemplate (org.springframework.cloud.gcp.data.spanner.core.SpannerTemplate)1 QueryMethodEvaluationContextProvider (org.springframework.data.repository.query.QueryMethodEvaluationContextProvider)1 SpelExpressionParser (org.springframework.expression.spel.standard.SpelExpressionParser)1