Search in sources :

Example 6 with User

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

Example 7 with User

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

the class DefaultKeyValueTemplateTest method shouldGet.

@Test
public void shouldGet() {
    User user = new User(KEY, "otavio", 27);
    when(manager.get(KEY)).thenReturn(Optional.of(Value.of(user)));
    Optional<User> userOptional = subject.get(KEY, User.class);
    assertTrue(userOptional.isPresent());
    assertEquals(user, userOptional.get());
}
Also used : User(org.jnosql.artemis.model.User) Test(org.junit.jupiter.api.Test)

Example 8 with User

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

the class KeyValueRepositoryProxyTest method shouldSaveIterable.

@Test
public void shouldSaveIterable() {
    ArgumentCaptor<Iterable> captor = ArgumentCaptor.forClass(Iterable.class);
    User user = new User("ada", "Ada", 10);
    userRepository.save(Collections.singleton(user));
    Mockito.verify(repository).put(captor.capture());
    User value = (User) captor.getValue().iterator().next();
    assertEquals(user, value);
}
Also used : User(org.jnosql.artemis.model.User) Test(org.junit.jupiter.api.Test)

Example 9 with User

use of org.jnosql.artemis.model.User in project jnosql-artemis 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("user")).thenReturn(Optional.of(Value.of(new User("Default", "Default", 10))));
    return bucketManager;
}
Also used : User(org.jnosql.artemis.model.User) BucketManager(org.jnosql.diana.api.key.BucketManager) Person(org.jnosql.artemis.model.Person) Produces(javax.enterprise.inject.Produces)

Example 10 with User

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

the class DefaultKeyValueEntityConverterTest method shouldConvertToKeyValue.

@Test
public void shouldConvertToKeyValue() {
    User user = new User("nickname", "name", 24);
    KeyValueEntity<String> keyValueEntity = converter.toKeyValue(user);
    assertEquals("nickname", keyValueEntity.getKey());
    assertEquals(user, keyValueEntity.getValue().get());
}
Also used : User(org.jnosql.artemis.model.User) 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