Search in sources :

Example 11 with User

use of org.jnosql.artemis.model.User in project jnosql-artemis by eclipse.

the class DefaultKeyValueEntityConverterTest method shouldConvertAndFeedTheKeyValueIfKeyAndFieldAreDifferent.

@Test
public void shouldConvertAndFeedTheKeyValueIfKeyAndFieldAreDifferent() {
    User expectedUser = new User("nickname", "name", 21);
    User user = converter.toEntity(User.class, KeyValueEntity.of("nickname", new User("newName", "name", 21)));
    assertEquals(expectedUser, user);
}
Also used : User(org.jnosql.artemis.model.User) Test(org.junit.jupiter.api.Test)

Example 12 with User

use of org.jnosql.artemis.model.User in project jnosql-artemis 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().get());
}
Also used : User(org.jnosql.artemis.model.User) Duration(java.time.Duration) KeyValueEntity(org.jnosql.diana.api.key.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Example 13 with User

use of org.jnosql.artemis.model.User in project jnosql-artemis by eclipse.

the class DefaultKeyValueTemplateTest method shouldCheckNullParametersInGet.

@Test
public void shouldCheckNullParametersInGet() {
    User user = new User(KEY, "otavio", 27);
    assertThrows(NullPointerException.class, () -> subject.get(null, null));
    assertThrows(NullPointerException.class, () -> subject.get(user, null));
    assertThrows(NullPointerException.class, () -> subject.get(null, User.class));
}
Also used : User(org.jnosql.artemis.model.User) Test(org.junit.jupiter.api.Test)

Example 14 with User

use of org.jnosql.artemis.model.User in project jnosql-artemis by eclipse.

the class DefaultKeyValueTemplateTest method shouldCheckNullParametersInPut.

@Test
public void shouldCheckNullParametersInPut() {
    User user = new User(KEY, "otavio", 27);
    assertThrows(NullPointerException.class, () -> subject.put(null));
    assertThrows(NullPointerException.class, () -> subject.put(null, null));
    assertThrows(NullPointerException.class, () -> subject.put(null, Duration.ofSeconds(2L)));
    assertThrows(NullPointerException.class, () -> subject.put(user, null));
    assertThrows(NullPointerException.class, () -> subject.put((Iterable<? extends Object>) null));
    assertThrows(NullPointerException.class, () -> subject.put((Iterable<? extends Object>) null, null));
}
Also used : User(org.jnosql.artemis.model.User) Test(org.junit.jupiter.api.Test)

Example 15 with User

use of org.jnosql.artemis.model.User in project jnosql-artemis 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().get());
}
Also used : User(org.jnosql.artemis.model.User) KeyValueEntity(org.jnosql.diana.api.key.KeyValueEntity) Test(org.junit.jupiter.api.Test)

Aggregations

User (org.jnosql.artemis.model.User)21 Test (org.junit.jupiter.api.Test)19 KeyValueEntity (org.jnosql.diana.api.key.KeyValueEntity)4 Duration (java.time.Duration)2 Produces (javax.enterprise.inject.Produces)2 Person (org.jnosql.artemis.model.Person)2 BucketManager (org.jnosql.diana.api.key.BucketManager)2