use of com.couchbase.client.java.codec.JsonSerializer in project spring-boot by spring-projects.
the class CouchbaseAutoConfigurationTests method customizeJsonSerializer.
@Test
void customizeJsonSerializer() {
JsonSerializer customJsonSerializer = mock(JsonSerializer.class);
this.contextRunner.withUserConfiguration(CouchbaseTestConfiguration.class).withConfiguration(AutoConfigurations.of(JacksonAutoConfiguration.class)).withBean(ClusterEnvironmentBuilderCustomizer.class, () -> (builder) -> builder.jsonSerializer(customJsonSerializer)).withPropertyValues("spring.couchbase.connection-string=localhost").run((context) -> {
ClusterEnvironment env = context.getBean(ClusterEnvironment.class);
JsonSerializer serializer = env.jsonSerializer();
assertThat(serializer).extracting("wrapped").isSameAs(customJsonSerializer);
});
}
use of com.couchbase.client.java.codec.JsonSerializer in project spring-boot by spring-projects.
the class CouchbaseAutoConfigurationTests method whenObjectMapperBeanIsDefinedThenClusterEnvironmentObjectMapperIsDerivedFromIt.
@Test
void whenObjectMapperBeanIsDefinedThenClusterEnvironmentObjectMapperIsDerivedFromIt() {
this.contextRunner.withUserConfiguration(CouchbaseTestConfiguration.class).withConfiguration(AutoConfigurations.of(JacksonAutoConfiguration.class)).withPropertyValues("spring.couchbase.connection-string=localhost").run((context) -> {
ClusterEnvironment env = context.getBean(ClusterEnvironment.class);
Set<Object> expectedModuleIds = new HashSet<>(context.getBean(ObjectMapper.class).getRegisteredModuleIds());
expectedModuleIds.add(new JsonValueModule().getTypeId());
JsonSerializer serializer = env.jsonSerializer();
assertThat(serializer).extracting("wrapped").isInstanceOf(JacksonJsonSerializer.class).extracting("mapper", as(InstanceOfAssertFactories.type(ObjectMapper.class))).extracting(ObjectMapper::getRegisteredModuleIds).isEqualTo(expectedModuleIds);
});
}
use of com.couchbase.client.java.codec.JsonSerializer in project couchbase-jvm-clients by couchbase.
the class AsyncScope method analyticsQuery.
/**
* Performs an Analytics query with custom {@link AnalyticsOptions}.
*
* @param statement the Analytics query statement as a raw string.
* @param options the custom options for this analytics query.
* @return the {@link AnalyticsResult} once the response arrives successfully.
*/
public CompletableFuture<AnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
AnalyticsOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment.jsonSerializer() : opts.serializer();
return AnalyticsAccessor.analyticsQueryAsync(core, analyticsRequest(statement, opts), serializer);
}
use of com.couchbase.client.java.codec.JsonSerializer in project couchbase-jvm-clients by couchbase.
the class ReactiveCluster method searchQuery.
/**
* Performs a Full Text Search (FTS) query with custom {@link SearchOptions}.
*
* @param query the query, in the form of a {@link SearchQuery}
* @param options the custom options for this query.
* @return the {@link SearchRequest} once the response arrives successfully, inside a {@link Mono}
*/
public Mono<ReactiveSearchResult> searchQuery(final String indexName, final SearchQuery query, final SearchOptions options) {
notNull(query, "SearchQuery", () -> new ReducedSearchErrorContext(indexName, null));
notNull(options, "SearchOptions", () -> new ReducedSearchErrorContext(indexName, query.export().toMap()));
SearchOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return SearchAccessor.searchQueryReactive(asyncCluster.core(), asyncCluster.searchRequest(indexName, query, opts), serializer);
});
}
use of com.couchbase.client.java.codec.JsonSerializer in project couchbase-jvm-clients by couchbase.
the class AsyncBucket method viewQuery.
public CompletableFuture<ViewResult> viewQuery(final String designDoc, final String viewName, final ViewOptions options) {
notNull(options, "ViewOptions", () -> new ReducedViewErrorContext(designDoc, viewName, name));
ViewOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment.jsonSerializer() : opts.serializer();
return ViewAccessor.viewQueryAsync(core, viewRequest(designDoc, viewName, opts), serializer);
}
Aggregations