Search in sources :

Example 31 with ColumnEntity

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

Example 32 with ColumnEntity

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

Example 33 with ColumnEntity

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

Example 34 with ColumnEntity

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

Example 35 with ColumnEntity

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

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