use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnEntityConverterTest method shouldConvertToEntityWhenHasConverter.
@Test
public void shouldConvertToEntityWhenHasConverter() {
Worker worker = new Worker();
Job job = new Job();
job.setCity("Sao Paulo");
job.setDescription("Java Developer");
worker.setName("Bob");
worker.setSalary(new Money("BRL", BigDecimal.TEN));
worker.setJob(job);
ColumnEntity entity = converter.toColumn(worker);
Worker worker1 = converter.toEntity(entity);
assertEquals(worker.getSalary(), worker1.getSalary());
assertEquals(job.getCity(), worker1.getJob().getCity());
assertEquals(job.getDescription(), worker1.getJob().getDescription());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnEntityConverterTest method shouldConvertToEmbeddedClassWhenHasSubColumn2.
@Test
public void shouldConvertToEmbeddedClassWhenHasSubColumn2() {
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");
entity.add(Column.of("title", "Matrix"));
entity.add(Column.of("year", 2012));
entity.add(Column.of("actors", singleton("Actor")));
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 shouldConvertFromListEmbeddable.
@Test
public void shouldConvertFromListEmbeddable() {
ColumnEntity entity = ColumnEntity.of("AppointmentBook");
entity.add(Column.of("_id", "ids"));
List<List<Column>> columns = new ArrayList<>();
columns.add(asList(Column.of("name", "Ada"), Column.of("type", ContactType.EMAIL), Column.of("information", "ada@lovelace.com")));
columns.add(asList(Column.of("name", "Ada"), Column.of("type", ContactType.MOBILE), Column.of("information", "11 1231231 123")));
columns.add(asList(Column.of("name", "Ada"), Column.of("type", ContactType.PHONE), Column.of("information", "phone")));
entity.add(Column.of("contacts", columns));
AppointmentBook appointmentBook = converter.toEntity(entity);
List<Contact> contacts = appointmentBook.getContacts();
assertEquals("ids", appointmentBook.getId());
assertEquals("Ada", contacts.stream().map(Contact::getName).distinct().findFirst().get());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class DefaultColumnEventPersistManagerTest method shouldFirePostColumn.
@Test
public void shouldFirePostColumn() {
ColumnEntity entity = ColumnEntity.of("columnFamily");
subject.firePostColumn(entity);
ArgumentCaptor<ColumnEntityPostPersist> captor = ArgumentCaptor.forClass(ColumnEntityPostPersist.class);
verify(columnEntityPostPersistEvent).fire(captor.capture());
ColumnEntityPostPersist captorValue = captor.getValue();
assertEquals(entity, captorValue.getEntity());
}
use of org.jnosql.diana.api.column.ColumnEntity in project jnosql-artemis by eclipse.
the class MockProducer method getColumnFamilyManager.
@Produces
public ColumnFamilyManager getColumnFamilyManager() {
ColumnEntity entity = ColumnEntity.of("Person");
entity.add(org.jnosql.diana.api.column.Column.of("name", "Default"));
entity.add(org.jnosql.diana.api.column.Column.of("age", 10));
ColumnFamilyManager manager = mock(ColumnFamilyManager.class);
when(manager.insert(Mockito.any(ColumnEntity.class))).thenReturn(entity);
return manager;
}
Aggregations