use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnTemplateTest method shouldInsertEntitiesTTL.
@Test
public void shouldInsertEntitiesTTL() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Duration duration = Duration.ofHours(2);
Mockito.when(managerMock.insert(any(ColumnEntity.class), Mockito.eq(duration))).thenReturn(columnEntity);
subject.insert(Arrays.asList(person, person), duration);
verify(managerMock, times(2)).insert(any(ColumnEntity.class), any(Duration.class));
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnEntityConverterTest method shouldConvertToEmbeddedClassWhenHasSubColumn.
@Test
public void shouldConvertToEmbeddedClassWhenHasSubColumn() {
Movie movie = new Movie("Matrix", 2012, Collections.singleton("Actor"));
Director director = Director.builderDiretor().withAge(12).withId(12).withName("Otavio").withPhones(asList("234", "2342")).withMovie(movie).build();
ColumnEntity entity = converter.toColumn(director);
Director director1 = converter.toEntity(entity);
assertEquals(movie, director1.getMovie());
assertEquals(director.getName(), director1.getName());
assertEquals(director.getAge(), director1.getAge());
assertEquals(director.getId(), director1.getId());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnEntityConverterTest method shouldConvertoListEmbeddable.
@Test
public void shouldConvertoListEmbeddable() {
AppointmentBook appointmentBook = new AppointmentBook("ids");
appointmentBook.add(Contact.builder().withType(ContactType.EMAIL).withName("Ada").withInformation("ada@lovelace.com").build());
appointmentBook.add(Contact.builder().withType(ContactType.MOBILE).withName("Ada").withInformation("11 1231231 123").build());
appointmentBook.add(Contact.builder().withType(ContactType.PHONE).withName("Ada").withInformation("12 123 1231 123123").build());
ColumnEntity entity = converter.toColumn(appointmentBook);
Column contacts = entity.find("contacts").get();
assertEquals("ids", appointmentBook.getId());
List<List<Column>> columns = (List<List<Column>>) contacts.get();
assertEquals(3L, columns.stream().flatMap(Collection::stream).filter(c -> c.getName().equals("name")).count());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnEntityConverterTest method shouldConvertToEmbeddedClassWhenHasSubColumn3.
@Test
public void shouldConvertToEmbeddedClassWhenHasSubColumn3() {
Movie movie = new Movie("Matrix", 2012, singleton("Actor"));
Director director = Director.builderDiretor().withAge(12).withId(12).withName("Otavio").withPhones(asList("234", "2342")).withMovie(movie).build();
ColumnEntity entity = converter.toColumn(director);
entity.remove("movie");
Map<String, Object> map = new HashMap<>();
map.put("title", "Matrix");
map.put("year", 2012);
map.put("actors", singleton("Actor"));
entity.add(Column.of("movie", map));
Director director1 = converter.toEntity(entity);
assertEquals(movie, director1.getMovie());
assertEquals(director.getName(), director1.getName());
assertEquals(director.getAge(), director1.getAge());
assertEquals(director.getId(), director1.getId());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnEntityConverterTest method shouldReturnErrorWhenToEntityIsNull.
@Test
public void shouldReturnErrorWhenToEntityIsNull() {
ColumnEntity entity = ColumnEntity.of("Actor");
Stream.of(columns).forEach(entity::add);
Actor actor = Actor.actorBuilder().build();
assertThrows(NullPointerException.class, () -> {
converter.toEntity(null, entity);
});
assertThrows(NullPointerException.class, () -> {
converter.toEntity(actor, null);
});
}
Aggregations