use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class DefaultColumnTemplateTest method shouldInsertEntities.
@Test
public void shouldInsertEntities() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Mockito.when(managerMock.insert(any(ColumnEntity.class))).thenReturn(columnEntity);
subject.insert(Arrays.asList(person, person));
verify(managerMock, times(2)).insert(any(ColumnEntity.class));
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class DefaultColumnTemplateTest method shouldInsertEntitiesTTL.
@Test
public void shouldInsertEntitiesTTL() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Duration duration = Duration.ofHours(2);
Mockito.when(managerMock.insert(any(ColumnEntity.class), Mockito.eq(duration))).thenReturn(columnEntity);
subject.insert(Arrays.asList(person, person), duration);
verify(managerMock, times(2)).insert(any(ColumnEntity.class), any(Duration.class));
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class DefaultColumnTemplateTest method shouldReturnSingleResult.
@Test
public void shouldReturnSingleResult() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Mockito.when(managerMock.select(any(ColumnQuery.class))).thenReturn(Stream.of(columnEntity));
ColumnQuery query = select().from("person").build();
Optional<Person> result = subject.singleResult(query);
assertTrue(result.isPresent());
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class DefaultColumnTemplateTest method shouldUpdate.
@Test
public void shouldUpdate() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Mockito.when(managerMock.update(any(ColumnEntity.class))).thenReturn(columnEntity);
subject.update(this.person);
verify(managerMock).update(captor.capture());
verify(columnEventPersistManager).firePostEntity(any(Person.class));
verify(columnEventPersistManager).firePreEntity(any(Person.class));
verify(columnEventPersistManager).firePreColumn(any(ColumnEntity.class));
verify(columnEventPersistManager).firePostColumn(any(ColumnEntity.class));
ColumnEntity value = captor.getValue();
assertEquals("Person", value.getName());
assertEquals(4, value.getColumns().size());
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class MockProducer method getColumnFamilyManager.
@Produces
public ColumnFamilyManager getColumnFamilyManager() {
ColumnEntity entity = ColumnEntity.of("Person");
entity.add(Column.of("name", "Default"));
entity.add(Column.of("age", 10));
ColumnFamilyManager manager = mock(ColumnFamilyManager.class);
when(manager.insert(Mockito.any(ColumnEntity.class))).thenReturn(entity);
return manager;
}
Aggregations