use of io.spine.client.Query in project core-java by SpineEventEngine.
the class StandShould method throw_invalid_query_exception_packed_as_IAE_if_invalid_query_message_passed.
@Test
public void throw_invalid_query_exception_packed_as_IAE_if_invalid_query_message_passed() {
final Stand stand = Stand.newBuilder().build();
final Query invalidQuery = Query.getDefaultInstance();
try {
stand.execute(invalidQuery, StreamObservers.<QueryResponse>noOpObserver());
fail("Expected IllegalArgumentException due to invalid query message passed," + " but got nothing");
} catch (IllegalArgumentException e) {
verifyInvalidQueryException(invalidQuery, e);
}
}
use of io.spine.client.Query in project core-java by SpineEventEngine.
the class StandShould method throw_invalid_query_exception_packed_as_IAE_if_querying_unknown_type.
@Test
public void throw_invalid_query_exception_packed_as_IAE_if_querying_unknown_type() {
final Stand stand = Stand.newBuilder().build();
checkTypesEmpty(stand);
// Customer type was NOT registered.
// So create a query for an unknown type.
final Query readAllCustomers = requestFactory.query().all(Customer.class);
try {
stand.execute(readAllCustomers, StreamObservers.<QueryResponse>noOpObserver());
fail("Expected IllegalArgumentException upon executing query with unknown target," + " but got nothing");
} catch (IllegalArgumentException e) {
verifyUnsupportedQueryTargetException(readAllCustomers, e);
}
}
use of io.spine.client.Query in project core-java by SpineEventEngine.
the class QueryBuilderShould method persist_only_last_ids_clause.
@Test
public void persist_only_last_ids_clause() {
final Iterable<?> genericIds = asList(newUuid(), -1, newMessageId());
final Long[] longIds = { 1L, 2L, 3L };
final Message[] messageIds = { newMessageId(), newMessageId(), newMessageId() };
final String[] stringIds = { newUuid(), newUuid(), newUuid() };
final Integer[] intIds = { 4, 5, 6 };
final Query query = factory().query().select(TestEntity.class).byId(genericIds).byId(longIds).byId(stringIds).byId(intIds).byId(messageIds).build();
assertNotNull(query);
final Target target = query.getTarget();
final EntityFilters filters = target.getFilters();
final Collection<EntityId> entityIds = filters.getIdFilter().getIdsList();
assertSize(messageIds.length, entityIds);
final Function<EntityId, ProjectId> transformer = new EntityIdUnpacker<>(ProjectId.class);
final Iterable<? extends Message> actualValues = transform(entityIds, transformer);
assertThat(actualValues, containsInAnyOrder(messageIds));
}
use of io.spine.client.Query in project core-java by SpineEventEngine.
the class QueryOperationShould method reject_null_input.
@Test(expected = NullPointerException.class)
public void reject_null_input() {
final Query nullQuery = Tests.nullRef();
new QueryOperation(nullQuery) {
@Override
public void run() {
// Do nothing;
}
};
}
use of io.spine.client.Query in project core-java by SpineEventEngine.
the class QueryOperationShould method return_query_id.
@Test
public void return_query_id() {
final QueryId id = Queries.generateId();
final Query query = Query.newBuilder().setId(id).build();
final QueryOperation op = new QueryOperation(query) {
@Override
public void run() {
// Do nothing.
}
};
assertEquals(id, op.queryId());
}
Aggregations