use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class InsertQueryParserTest method shouldExecutePrepareStatement.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "insert God (name = @name)" })
public void shouldExecutePrepareStatement(String query) {
ArgumentCaptor<ColumnEntity> captor = ArgumentCaptor.forClass(ColumnEntity.class);
ColumnPreparedStatement prepare = parser.prepare(query, manager, observer);
prepare.bind("name", "Diana");
prepare.getResult();
Mockito.verify(manager).insert(captor.capture());
ColumnEntity entity = captor.getValue();
assertEquals("God", entity.getName());
assertEquals(Column.of("name", "Diana"), entity.find("name").get());
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class UpdateQueryParserTest method shouldExecutePrepareStatement.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "update God (name = @name)" })
public void shouldExecutePrepareStatement(String query) {
ArgumentCaptor<ColumnEntity> captor = ArgumentCaptor.forClass(ColumnEntity.class);
ColumnPreparedStatement prepare = parser.prepare(query, manager, observer);
prepare.bind("name", "Diana");
prepare.getResult();
Mockito.verify(manager).update(captor.capture());
ColumnEntity entity = captor.getValue();
assertEquals("God", entity.getName());
assertEquals(Column.of("name", "Diana"), entity.find("name").get());
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class UpdateQueryParserTest method shouldReturnParserQuery4.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "update Person {\"name\": \"Ada Lovelace\", \"age\": 12, \"sibling\":" + " [\"Ana\" ,\"Maria\"]," + " \"address\":{\"country\": \"United Kingdom\", \"city\": \"London\"}}" })
public void shouldReturnParserQuery4(String query) {
ArgumentCaptor<ColumnEntity> captor = ArgumentCaptor.forClass(ColumnEntity.class);
parser.query(query, manager, observer);
Mockito.verify(manager).update(captor.capture());
ColumnEntity entity = captor.getValue();
List<String> siblings = entity.find("sibling").get().get(new TypeReference<List<String>>() {
});
List<Column> address = entity.find("address").get().get(new TypeReference<List<Column>>() {
});
assertEquals("Person", entity.getName());
assertEquals(Column.of("name", "Ada Lovelace"), entity.find("name").get());
assertEquals(Column.of("age", BigDecimal.valueOf(12)), entity.find("age").get());
assertThat(siblings, contains("Ana", "Maria"));
assertThat(address, containsInAnyOrder(Column.of("country", "United Kingdom"), Column.of("city", "London")));
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class UpdateQueryParserTest method shouldReturnParserQuery.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "update God (name = \"Diana\")" })
public void shouldReturnParserQuery(String query) {
ArgumentCaptor<ColumnEntity> captor = ArgumentCaptor.forClass(ColumnEntity.class);
parser.query(query, manager, observer);
Mockito.verify(manager).update(captor.capture());
ColumnEntity entity = captor.getValue();
assertEquals("God", entity.getName());
assertEquals(Column.of("name", "Diana"), entity.find("name").get());
}
use of jakarta.nosql.column.ColumnEntity in project jnosql-diana by eclipse.
the class DefaultColumnTemplateTest method shouldInsert.
@Test
public void shouldInsert() {
ColumnEntity columnEntity = ColumnEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
Mockito.when(managerMock.insert(any(ColumnEntity.class))).thenReturn(columnEntity);
subject.insert(this.person);
verify(managerMock).insert(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());
}
Aggregations