use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.
the class GetQueryParser method query.
Stream<Value> query(String query, BucketManager manager) {
GetQuery getQuery = provider.apply(query);
Params params = Params.newParams();
List<Value> values = getQuery.getKeys().stream().map(k -> Values.getValue(k, params)).collect(toList());
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
return values.stream().map(Value::get).map(manager::get).filter(Optional::isPresent).map(Optional::get);
}
use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.
the class GetQueryParser method prepare.
public KeyValuePreparedStatement prepare(String query, BucketManager manager) {
GetQuery getQuery = provider.apply(query);
Params params = Params.newParams();
List<Value> values = getQuery.getKeys().stream().map(k -> Values.getValue(k, params)).collect(toList());
return DefaultKeyValuePreparedStatement.get(values, manager, params, query);
}
use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.
the class MockProducer method getBucketManagerMock.
@Produces
@Database(value = DatabaseType.KEY_VALUE, provider = "keyvalueMock")
public BucketManager getBucketManagerMock() {
BucketManager bucketManager = Mockito.mock(BucketManager.class);
Person person = Person.builder().withName("keyvalueMock").build();
when(bucketManager.get("key")).thenReturn(Optional.ofNullable(Value.of(person)));
when(bucketManager.get(10L)).thenReturn(Optional.ofNullable(Value.of(person)));
when(bucketManager.get("user")).thenReturn(Optional.of(Value.of(new User("keyvalueMock", "keyvalueMock", 10))));
return bucketManager;
}
use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.
the class MockProducer method getBucketManager.
@Produces
public BucketManager getBucketManager() {
BucketManager bucketManager = Mockito.mock(BucketManager.class);
Person person = Person.builder().withName("Default").build();
when(bucketManager.get("key")).thenReturn(Optional.ofNullable(Value.of(person)));
when(bucketManager.get(10L)).thenReturn(Optional.ofNullable(Value.of(person)));
when(bucketManager.get("user")).thenReturn(Optional.of(Value.of(new User("Default", "Default", 10))));
return bucketManager;
}
use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.
the class DefaultKeyValueRepositoryProducerTest method shouldCreateFromManager.
@Test
public void shouldCreateFromManager() {
BucketManager manager = Mockito.mock(BucketManager.class);
PersonRepository personRepository = producer.get(PersonRepository.class, manager);
assertNotNull(personRepository);
}
Aggregations