Search in sources :

Example 1 with BoolValue

use of com.google.protobuf.BoolValue in project core-java by SpineEventEngine.

the class EntityQueriesShould method construct_non_empty_queries.

@Test
public void construct_non_empty_queries() {
    final Message someGenericId = Sample.messageOfType(ProjectId.class);
    final Any someId = AnyPacker.pack(someGenericId);
    final EntityId entityId = EntityId.newBuilder().setId(someId).build();
    final EntityIdFilter idFilter = EntityIdFilter.newBuilder().addIds(entityId).build();
    final Version versionValue = Version.newBuilder().setNumber(1).build();
    final BoolValue archivedValue = BoolValue.newBuilder().setValue(true).build();
    final EntityFilters filters = EntityFilters.newBuilder().setIdFilter(idFilter).putColumnFilter("version", AnyPacker.pack(versionValue)).putColumnFilter("archived", AnyPacker.pack(archivedValue)).build();
    final Class<? extends Entity> entityClass = AbstractVersionableEntity.class;
    final EntityQuery<?> query = EntityQueries.from(filters, entityClass);
    assertNotNull(query);
    assertSize(2, query.getParameters());
    final Collection<?> ids = query.getIds();
    assertFalse(ids.isEmpty());
    assertSize(1, ids);
    final Object singleId = ids.iterator().next();
    assertEquals(someGenericId, singleId);
    final Map<Column<?>, Object> params = query.getParameters();
    final Collection<Object> values = params.values();
    assertContains(versionValue, values);
    assertContains(archivedValue.getValue(), values);
}
Also used : Message(com.google.protobuf.Message) EntityIdFilter(io.spine.client.EntityIdFilter) EntityFilters(io.spine.client.EntityFilters) BoolValue(com.google.protobuf.BoolValue) Any(com.google.protobuf.Any) EntityId(io.spine.client.EntityId) Version(io.spine.base.Version) AbstractVersionableEntity(io.spine.server.entity.AbstractVersionableEntity) Test(org.junit.Test)

Aggregations

Any (com.google.protobuf.Any)1 BoolValue (com.google.protobuf.BoolValue)1 Message (com.google.protobuf.Message)1 Version (io.spine.base.Version)1 EntityFilters (io.spine.client.EntityFilters)1 EntityId (io.spine.client.EntityId)1 EntityIdFilter (io.spine.client.EntityIdFilter)1 AbstractVersionableEntity (io.spine.server.entity.AbstractVersionableEntity)1 Test (org.junit.Test)1