@Test void testValidateFetch() { @SuppressWarnings("unchecked") Query<Entity> query = mock(Query.class); Fetch fetch = mock(Fetch.class); when(query.getFetch()).thenReturn(fetch); EntityType entityType = mock(EntityType.class); queryValidator.validate(query, entityType); verify(fetchValidator).validateFetch(fetch, entityType); }
public void validate(Query<? extends Entity> query, EntityType entityType) { query.getRules().forEach(queryRule -> validateQueryRule(queryRule, entityType)); Fetch fetch = query.getFetch(); if (fetch != null) { Fetch validatedFetch = fetchValidator.validateFetch(fetch, entityType); query.setFetch(validatedFetch); } }
QueryValidator { public void validate(Query<? extends Entity> query, EntityType entityType) { query.getRules().forEach(queryRule -> validateQueryRule(queryRule, entityType)); Fetch fetch = query.getFetch(); if (fetch != null) { Fetch validatedFetch = fetchValidator.validateFetch(fetch, entityType); query.setFetch(validatedFetch); } } }
QueryValidator { public void validate(Query<? extends Entity> query, EntityType entityType) { query.getRules().forEach(queryRule -> validateQueryRule(queryRule, entityType)); Fetch fetch = query.getFetch(); if (fetch != null) { Fetch validatedFetch = fetchValidator.validateFetch(fetch, entityType); query.setFetch(validatedFetch); } } QueryValidator(FetchValidator fetchValidator, EntityManager entityManager); }
QueryValidator { public void validate(Query<? extends Entity> query, EntityType entityType) { query.getRules().forEach(queryRule -> validateQueryRule(queryRule, entityType)); Fetch fetch = query.getFetch(); if (fetch != null) { Fetch validatedFetch = fetchValidator.validateFetch(fetch, entityType); query.setFetch(validatedFetch); } } QueryValidator(FetchValidator fetchValidator, EntityManager entityManager); void validate(Query<? extends Entity> query, EntityType entityType); }
QueryValidator { public void validate(Query<? extends Entity> query, EntityType entityType) { query.getRules().forEach(queryRule -> validateQueryRule(queryRule, entityType)); Fetch fetch = query.getFetch(); if (fetch != null) { Fetch validatedFetch = fetchValidator.validateFetch(fetch, entityType); query.setFetch(validatedFetch); } } QueryValidator(FetchValidator fetchValidator, EntityManager entityManager); void validate(Query<? extends Entity> query, EntityType entityType);  }