use of jakarta.nosql.column.ColumnEntity in project jnosql-diana 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 jakarta.nosql.column.ColumnEntity in project jnosql-diana 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 jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class ManagerProducerProducer method getColumnFamilyManager.
@Produces
public ColumnFamilyManager getColumnFamilyManager() {
ColumnFamilyManager columnFamilyManager = Mockito.mock(ColumnFamilyManager.class);
ColumnEntity entity = ColumnEntity.of("person");
entity.add(Column.of("name", "Ada"));
entity.add(Column.of("age", 10));
entity.add(Column.of("salary", BigDecimal.TEN));
entity.add(Column.of("phones", singletonList("22342342")));
when(columnFamilyManager.insert(Mockito.any(ColumnEntity.class))).thenReturn(entity);
when(columnFamilyManager.update(Mockito.any(ColumnEntity.class))).thenReturn(entity);
return columnFamilyManager;
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldPagingState.
@Test
public void shouldPagingState() {
for (long index = 1; index <= 10; index++) {
ColumnEntity columnFamily = getColumnFamily();
columnFamily.add("id", index);
entityManager.insert(columnFamily);
}
ColumnQuery query = select().from(Constants.COLUMN_FAMILY).build();
CassandraQuery cassandraQuery = CassandraQuery.of(query);
assertFalse(cassandraQuery.getPagingState().isPresent());
List<ColumnEntity> entities = entityManager.select(cassandraQuery).collect(toList());
assertEquals(10, entities.size());
assertTrue(cassandraQuery.getPagingState().isPresent());
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana-driver by eclipse.
the class CassandraColumnFamilyManagerTest method shouldReturnSingleResult.
@Test
public void shouldReturnSingleResult() {
ColumnEntity columnEntity = getColumnFamily();
entityManager.insert(columnEntity);
ColumnQuery query = select().from(columnEntity.getName()).where("id").eq(10L).build();
Optional<ColumnEntity> entity = entityManager.singleResult(query);
query = select().from(columnEntity.getName()).where("id").eq(-10L).build();
entity = entityManager.singleResult(query);
assertFalse(entity.isPresent());
}
Aggregations