Search in sources :

Example 16 with KeyValueEntity

use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana-driver by eclipse.

the class HazelcastBucketManagerTest method shouldMultiGet.

@Test
public void shouldMultiGet() {
    User user = new User("otavio");
    KeyValueEntity keyValue = KeyValueEntity.of("otavio", Value.of(user));
    keyValueEntityManager.put(keyValue);
    assertNotNull(keyValueEntityManager.get("otavio"));
}
Also used : User(org.eclipse.jnosql.communication.hazelcast.keyvalue.model.User) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 17 with KeyValueEntity

use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana-driver by eclipse.

the class KeyValueEntityManagerTest method shouldMultiGet.

@Test
public void shouldMultiGet() {
    User user = new User("otavio");
    KeyValueEntity keyValue = KeyValueEntity.of("otavio", Value.of(user));
    keyValueEntityManager.put(keyValue);
    assertNotNull(keyValueEntityManager.get("otavio"));
}
Also used : User(org.eclipse.jnosql.communication.infinispan.keyvalue.model.User) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 18 with KeyValueEntity

use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana-driver by eclipse.

the class RiakBucketManagerTest method shouldMultiGet.

@Test
public void shouldMultiGet() {
    User user = new User("otavio");
    KeyValueEntity keyValue = KeyValueEntity.of("otavio", Value.of(user));
    keyValueEntityManager.put(keyValue);
    assertNotNull(keyValueEntityManager.get("otavio"));
}
Also used : KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 19 with KeyValueEntity

use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.

the class PutQueryParser method query.

Stream<Value> query(String query, BucketManager manager) {
    PutQuery putQuery = provider.apply(query);
    Params params = Params.newParams();
    Value key = Values.getValue(putQuery.getKey(), params);
    Value value = Values.getValue(putQuery.getValue(), params);
    Optional<Duration> ttl = putQuery.getTtl();
    if (params.isNotEmpty()) {
        throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
    }
    KeyValueEntity entity = KeyValueEntity.of(key.get(), value.get());
    if (ttl.isPresent()) {
        manager.put(entity, ttl.get());
    } else {
        manager.put(entity);
    }
    return Stream.empty();
}
Also used : QueryException(jakarta.nosql.QueryException) Value(jakarta.nosql.Value) Params(jakarta.nosql.Params) Duration(java.time.Duration) PutQuery(jakarta.nosql.query.PutQuery) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity)

Example 20 with KeyValueEntity

use of jakarta.nosql.keyvalue.KeyValueEntity in project jnosql-diana by eclipse.

the class DefaultKeyValueEntityTest method shouldGetValue.

@Test
public void shouldGetValue() {
    Value value = Value.of("value");
    KeyValueEntity entity = KeyValueEntity.of("key", value);
    assertNotNull(entity);
    assertEquals("value", entity.getValue());
}
Also used : Value(jakarta.nosql.Value) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Aggregations

KeyValueEntity (jakarta.nosql.keyvalue.KeyValueEntity)38 Test (org.junit.jupiter.api.Test)31 User (jakarta.nosql.tck.entities.User)11 Duration (java.time.Duration)7 Value (jakarta.nosql.Value)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 ValueSource (org.junit.jupiter.params.provider.ValueSource)6 TypeReference (jakarta.nosql.TypeReference)3 KeyValuePreparedStatement (jakarta.nosql.keyvalue.KeyValuePreparedStatement)3 Params (jakarta.nosql.Params)2 QueryException (jakarta.nosql.QueryException)1 KeyValueEntityPostPersist (jakarta.nosql.mapping.keyvalue.KeyValueEntityPostPersist)1 KeyValueEntityPrePersist (jakarta.nosql.mapping.keyvalue.KeyValueEntityPrePersist)1 PutQuery (jakarta.nosql.query.PutQuery)1 Car (jakarta.nosql.tck.entities.Car)1 Person (jakarta.nosql.tck.entities.Person)1 User (org.eclipse.jnosql.communication.hazelcast.keyvalue.model.User)1 User (org.eclipse.jnosql.communication.infinispan.keyvalue.model.User)1 User (org.eclipse.jnosql.communication.memcached.keyvalue.model.User)1