Search in sources :

Example 11 with ColumnFamilyManager

use of jakarta.nosql.column.ColumnFamilyManager in project jnosql-diana by eclipse.

the class MockProducer method getColumnFamilyManagerMock.

@Produces
@Database(value = DatabaseType.COLUMN, provider = "columnRepositoryMock")
public ColumnFamilyManager getColumnFamilyManagerMock() {
    ColumnEntity entity = ColumnEntity.of("Person");
    entity.add(Column.of("name", "columnRepositoryMock"));
    entity.add(Column.of("age", 10));
    ColumnFamilyManager manager = mock(ColumnFamilyManager.class);
    when(manager.insert(Mockito.any(ColumnEntity.class))).thenReturn(entity);
    return manager;
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Produces(javax.enterprise.inject.Produces) Database(jakarta.nosql.mapping.Database)

Example 12 with ColumnFamilyManager

use of jakarta.nosql.column.ColumnFamilyManager in project jnosql-diana by eclipse.

the class ColumnFamilyManagerConverterTest method shouldReturnManager.

@Test
public void shouldReturnManager() {
    final String prefix = UUID.randomUUID().toString();
    System.setProperty(prefix, prefix);
    System.setProperty(prefix + ".settings.key", "value");
    System.setProperty(prefix + ".settings.key2", "value2");
    System.setProperty(prefix + ".provider", ColumnConfigurationMock.class.getName());
    System.setProperty(prefix + ".database", "database");
    final ColumnFamilyManager manager = config.getValue(prefix, ColumnFamilyManager.class);
    final ColumnConfigurationMock.ColumnFamilyManagerMock managerMock = ColumnConfigurationMock.ColumnFamilyManagerMock.class.cast(manager);
    Assertions.assertEquals("database", managerMock.getDatabase());
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
    System.clearProperty(prefix + ".database");
}
Also used : ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Test(org.junit.jupiter.api.Test)

Example 13 with ColumnFamilyManager

use of jakarta.nosql.column.ColumnFamilyManager in project jnosql-diana by eclipse.

the class MockProducer method getColumnFamilyManagerMock.

@Produces
@Database(value = DatabaseType.COLUMN, provider = "columnRepositoryMock")
public ColumnFamilyManager getColumnFamilyManagerMock() {
    ColumnEntity entity = ColumnEntity.of("Person");
    entity.add(Column.of("name", "columnRepositoryMock"));
    entity.add(Column.of("age", 10));
    ColumnFamilyManager manager = mock(ColumnFamilyManager.class);
    when(manager.insert(Mockito.any(ColumnEntity.class))).thenReturn(entity);
    return manager;
}
Also used : ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Produces(javax.enterprise.inject.Produces) Database(jakarta.nosql.mapping.Database)

Example 14 with ColumnFamilyManager

use of jakarta.nosql.column.ColumnFamilyManager in project jnosql-diana by eclipse.

the class DefaultDeleteQueryBuilderTest method shouldExecuteDelete.

@Test
public void shouldExecuteDelete() {
    String columnFamily = "columnFamily";
    ColumnFamilyManager manager = mock(ColumnFamilyManager.class);
    ArgumentCaptor<ColumnDeleteQuery> queryCaptor = ArgumentCaptor.forClass(ColumnDeleteQuery.class);
    delete().from(columnFamily).delete(manager);
    verify(manager).delete(queryCaptor.capture());
    ColumnDeleteQuery query = queryCaptor.getValue();
    assertTrue(query.getColumns().isEmpty());
    assertFalse(query.getCondition().isPresent());
    assertEquals(columnFamily, query.getColumnFamily());
}
Also used : ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 15 with ColumnFamilyManager

use of jakarta.nosql.column.ColumnFamilyManager in project jnosql-diana by eclipse.

the class ColumnPageTest method setUp.

@BeforeEach
public void setUp() {
    managerMock = Mockito.mock(ColumnFamilyManager.class);
    columnEventPersistManager = Mockito.mock(ColumnEventPersistManager.class);
    captor = ArgumentCaptor.forClass(ColumnEntity.class);
    Instance<ColumnFamilyManager> instance = Mockito.mock(Instance.class);
    when(instance.get()).thenReturn(managerMock);
    this.subject = new DefaultColumnTemplate(converter, instance, new DefaultColumnWorkflow(columnEventPersistManager, converter), columnEventPersistManager, classMappings, converters);
    Pagination pagination = Pagination.page(1).size(1);
    ColumnQueryPagination query = ColumnQueryPagination.of(select().from("person").build(), pagination);
    for (int index = 0; index <= 10; index++) {
        Column[] columns = new Column[] { Column.of("age", index), Column.of("name", "Ada " + index), Column.of("_id", (long) index) };
        ColumnEntity columnEntity = ColumnEntity.of("Person");
        columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
        when(managerMock.select(query)).thenReturn(Stream.of(columnEntity));
        query = query.next();
    }
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnEventPersistManager(jakarta.nosql.mapping.column.ColumnEventPersistManager) ColumnEntity(jakarta.nosql.column.ColumnEntity) ColumnFamilyManager(jakarta.nosql.column.ColumnFamilyManager) Column(jakarta.nosql.column.Column) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ColumnFamilyManager (jakarta.nosql.column.ColumnFamilyManager)16 ColumnEntity (jakarta.nosql.column.ColumnEntity)8 Test (org.junit.jupiter.api.Test)7 Produces (javax.enterprise.inject.Produces)5 ColumnTemplateProducer (jakarta.nosql.mapping.column.ColumnTemplateProducer)3 ColumnQuery (jakarta.nosql.column.ColumnQuery)2 Database (jakarta.nosql.mapping.Database)2 Column (jakarta.nosql.column.Column)1 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)1 Pagination (jakarta.nosql.mapping.Pagination)1 ColumnEventPersistManager (jakarta.nosql.mapping.column.ColumnEventPersistManager)1 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)1 ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)1 PersonRepository (jakarta.nosql.tck.entities.PersonRepository)1 Config (org.eclipse.microprofile.config.Config)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1