Skip to content

Commit

Permalink
Check query.target manually
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yevsyukov committed Oct 15, 2022
1 parent 2f128b5 commit 0f54897
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Streams.stream;
import static io.spine.validate.Validate.check;

/**
* Processes the queries targeting {@link io.spine.server.entity.Entity Entity} objects.
Expand All @@ -50,6 +51,11 @@ class EntityQueryProcessor implements QueryProcessor {

@Override
public ImmutableCollection<EntityStateWithVersion> process(Query query) {
check(query);
// Specifically check the target until Validation generates code
// for `(validate)` field option.
// See: https://github.com/SpineEventEngine/validation/issues/59
check(query.getTarget());
var entities = query.all()
? loadAll(query.responseFormat())
: loadByQuery(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import io.spine.testing.client.TestActorRequestFactory;
import io.spine.testing.server.blackbox.BlackBox;
import io.spine.type.TypeName;
import io.spine.validate.NonValidated;
import io.spine.validate.ValidationException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -126,10 +127,10 @@ void readAllAndSort() {
@Test
@DisplayName("fail if the query does not specify filters and `include_all` is not set")
void failOnInvalidQuery() {
var target = Target.newBuilder()
@NonValidated Target target = Target.newBuilder()
.setType(TypeName.of(Mirror.class).value())
.buildPartial();
var query = Query.newBuilder()
@NonValidated Query query = Query.newBuilder()
.setId(QueryId.newBuilder().setValue(newUuid()))
.setContext(factory.newActorContext())
.setTarget(target)
Expand Down

0 comments on commit 0f54897

Please sign in to comment.