use of io.spine.client.CompositeColumnFilter in project core-java by SpineEventEngine.
the class EntityQueriesShould method not_create_query_for_non_existing_column.
@Test(expected = IllegalArgumentException.class)
public void not_create_query_for_non_existing_column() {
final ColumnFilter filter = ColumnFilters.eq("nonExistingColumn", 42);
final CompositeColumnFilter compositeFilter = ColumnFilters.all(filter);
final EntityFilters filters = EntityFilters.newBuilder().addFilter(compositeFilter).build();
createEntityQuery(filters, AbstractVersionableEntity.class);
}
use of io.spine.client.CompositeColumnFilter in project core-java by SpineEventEngine.
the class ERepositoryShould method convert_time_query_to_EntityFilters.
@Test
public void convert_time_query_to_EntityFilters() {
final EventStreamQuery query = EventStreamQuery.newBuilder().setAfter(Timestamps.MIN_VALUE).setBefore(Timestamps.MAX_VALUE).build();
final EntityFilters entityFilters = toEntityFilters(query);
assertEquals(1, entityFilters.getFilterCount());
final CompositeColumnFilter compositeFilter = entityFilters.getFilter(0);
final List<ColumnFilter> columnFilters = compositeFilter.getFilterList();
assertEquals(CompositeOperator.ALL, compositeFilter.getOperator());
assertEquals(2, columnFilters.size());
}
use of io.spine.client.CompositeColumnFilter in project core-java by SpineEventEngine.
the class ERepository method typeFilter.
private static Optional<CompositeColumnFilter> typeFilter(EventStreamQuery query) {
final CompositeColumnFilter.Builder typeFilter = CompositeColumnFilter.newBuilder().setOperator(EITHER);
for (EventFilter eventFilter : query.getFilterList()) {
final String type = eventFilter.getEventType();
if (!type.trim().isEmpty()) {
final ColumnFilter filter = eq(TYPE_COLUMN, type);
typeFilter.addFilter(filter);
}
}
return buildFilter(typeFilter);
}
use of io.spine.client.CompositeColumnFilter in project core-java by SpineEventEngine.
the class RecordStorageShould method update_entity_column_values.
@Test
public void update_entity_column_values() {
final Project.Status initialStatus = DONE;
// is used for documentation purposes.
@SuppressWarnings("UnnecessaryLocalVariable") final Project.Status statusAfterUpdate = CANCELLED;
final Int32Value initialStatusValue = Int32Value.newBuilder().setValue(initialStatus.getNumber()).build();
final ColumnFilter status = eq("projectStatusValue", initialStatusValue);
final CompositeColumnFilter aggregatingFilter = CompositeColumnFilter.newBuilder().setOperator(ALL).addFilter(status).build();
final EntityFilters filters = EntityFilters.newBuilder().addFilter(aggregatingFilter).build();
final RecordStorage<I> storage = getStorage();
final EntityQuery<I> query = EntityQueries.from(filters, storage);
final I id = newId();
final TestCounterEntity<I> entity = new TestCounterEntity<>(id);
entity.setStatus(initialStatus);
final EntityRecord record = newStorageRecord(id, newState(id));
final EntityRecordWithColumns recordWithColumns = create(record, entity, storage);
final FieldMask fieldMask = FieldMask.getDefaultInstance();
// Create the record.
storage.write(id, recordWithColumns);
final Iterator<EntityRecord> recordsBefore = storage.readAll(query, fieldMask);
assertSingleRecord(record, recordsBefore);
// Update the entity columns of the record.
entity.setStatus(statusAfterUpdate);
final EntityRecordWithColumns updatedRecordWithColumns = create(record, entity, storage);
storage.write(id, updatedRecordWithColumns);
final Iterator<EntityRecord> recordsAfter = storage.readAll(query, fieldMask);
assertFalse(recordsAfter.hasNext());
}
Aggregations