Search in sources :

Example 41 with ColumnEntity

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());
}
Also used : Money(jakarta.nosql.tck.entities.Money) ColumnEntity(jakarta.nosql.column.ColumnEntity) Worker(jakarta.nosql.tck.entities.Worker) Job(jakarta.nosql.tck.entities.Job) Test(org.junit.jupiter.api.Test)

Example 42 with ColumnEntity

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());
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnEntityPostPersist(jakarta.nosql.mapping.column.ColumnEntityPostPersist) Test(org.junit.jupiter.api.Test)

Example 43 with ColumnEntity

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;
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Produces(javax.enterprise.inject.Produces)

Example 44 with ColumnEntity

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());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Example 45 with ColumnEntity

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());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnEntity(jakarta.nosql.column.ColumnEntity) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnEntity (jakarta.nosql.column.ColumnEntity)146 Test (org.junit.jupiter.api.Test)103 Column (jakarta.nosql.column.Column)39 ColumnQuery (jakarta.nosql.column.ColumnQuery)23 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 ValueSource (org.junit.jupiter.params.provider.ValueSource)23 Duration (java.time.Duration)13 ArrayList (java.util.ArrayList)13 List (java.util.List)13 Arrays.asList (java.util.Arrays.asList)11 Person (jakarta.nosql.tck.entities.Person)9 ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 Value (jakarta.nosql.Value)6 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)6 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)5 Actor (jakarta.nosql.tck.entities.Actor)5 Director (jakarta.nosql.tck.entities.Director)5 Movie (jakarta.nosql.tck.entities.Movie)5