Search in sources :

Example 6 with KeyValueEntity

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

the class DefaultKeyValueEventPersistManagerTest method shouldFirePostColumn.

@Test
public void shouldFirePostColumn() {
    KeyValueEntity entity = KeyValueEntity.of("key", "value");
    subject.firePostKeyValue(entity);
    ArgumentCaptor<KeyValueEntityPostPersist> captor = ArgumentCaptor.forClass(KeyValueEntityPostPersist.class);
    verify(keyValueEntityPostPersistEvent).fire(captor.capture());
    KeyValueEntityPostPersist captorValue = captor.getValue();
    assertEquals(entity, captorValue.getEntity());
}
Also used : KeyValueEntityPostPersist(jakarta.nosql.mapping.keyvalue.KeyValueEntityPostPersist) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 7 with KeyValueEntity

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

the class DefaultKeyValueTemplateTest method shouldPutTTL.

@Test
public void shouldPutTTL() {
    Duration duration = Duration.ofSeconds(2L);
    User user = new User(KEY, "otavio", 27);
    subject.put(user, duration);
    Mockito.verify(manager).put(captor.capture(), Mockito.eq(duration));
    KeyValueEntity entity = captor.getValue();
    assertEquals(KEY, entity.getKey());
    assertEquals(user, entity.getValue());
}
Also used : User(jakarta.nosql.tck.entities.User) Duration(java.time.Duration) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 8 with KeyValueEntity

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

the class DefaultKeyValueTemplateTest method shouldInsertIterable.

@Test
public void shouldInsertIterable() {
    User user = new User(KEY, "otavio", 27);
    subject.insert(singletonList(user));
    Mockito.verify(manager).put(captor.capture());
    KeyValueEntity entity = captor.getValue();
    assertEquals(KEY, entity.getKey());
    assertEquals(user, entity.getValue());
}
Also used : User(jakarta.nosql.tck.entities.User) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 9 with KeyValueEntity

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

the class DefaultKeyValueTemplateTest method shouldPutIterable.

@Test
public void shouldPutIterable() {
    User user = new User(KEY, "otavio", 27);
    subject.put(singletonList(user));
    Mockito.verify(manager).put(captor.capture());
    KeyValueEntity entity = captor.getValue();
    assertEquals(KEY, entity.getKey());
    assertEquals(user, entity.getValue());
}
Also used : User(jakarta.nosql.tck.entities.User) KeyValueEntity(jakarta.nosql.keyvalue.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 10 with KeyValueEntity

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

the class DefaultKeyValueTemplateTest method shouldUpdateIterable.

@Test
public void shouldUpdateIterable() {
    User user = new User(KEY, "otavio", 27);
    subject.update(singletonList(user));
    Mockito.verify(manager).put(captor.capture());
    KeyValueEntity entity = captor.getValue();
    assertEquals(KEY, entity.getKey());
    assertEquals(user, entity.getValue());
}
Also used : User(jakarta.nosql.tck.entities.User) 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