Search in sources :

Example 31 with KeyValueEntity

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

the class DefaultKeyValueTemplateTest method shouldPutTTLIterable.

@Test
public void shouldPutTTLIterable() {
    Duration duration = Duration.ofSeconds(2L);
    User user = new User(KEY, "otavio", 27);
    subject.put(singletonList(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 32 with KeyValueEntity

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

the class DefaultKeyValueTemplateTest method shouldInsertTTLIterable.

@Test
public void shouldInsertTTLIterable() {
    Duration duration = Duration.ofSeconds(2L);
    User user = new User(KEY, "otavio", 27);
    subject.insert(singletonList(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 33 with KeyValueEntity

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

the class DefaultKeyValueTemplateTest method shouldPut.

@Test
public void shouldPut() {
    User user = new User(KEY, "otavio", 27);
    subject.put(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 34 with KeyValueEntity

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

the class DefaultKeyValueTemplateTest method shouldUpdate.

@Test
public void shouldUpdate() {
    User user = new User(KEY, "otavio", 27);
    subject.update(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 35 with KeyValueEntity

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

the class DefaultKeyValueEntityConverterTest method shouldConvertToKeyWhenKeyTypeIsDifferent.

@Test
public void shouldConvertToKeyWhenKeyTypeIsDifferent() {
    Person person = Person.builder().withId(123L).withName("Ada").build();
    KeyValueEntity entity = converter.toKeyValue(person);
    Assertions.assertEquals(123L, entity.getKey());
}
Also used : Person(jakarta.nosql.tck.entities.Person) 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