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;
}
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");
}
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;
}
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());
}
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();
}
}
Aggregations