@Test public void testPrepareAllConstraints() { QueryLaunchingConstraint c1 = mock(QueryLaunchingConstraint.class); QueryLaunchingConstraint c2 = mock(QueryLaunchingConstraint.class); QueryLaunchingConstraint dc1 = mock(QueryLaunchingConstraint.class); QueryLaunchingConstraint dc2 = mock(QueryLaunchingConstraint.class); QueryContext mockCandidateQuery = mock(QueryContext.class); when(mockCandidateQuery.getSelectedDriverQueryConstraints()).thenReturn(ImmutableSet.of(dc1, dc2)); DefaultQueryLaunchingConstraintsChecker constraintsChecker = new DefaultQueryLaunchingConstraintsChecker(ImmutableSet.of(c1, c2)); assertEquals(constraintsChecker.prepareAllConstraints(mockCandidateQuery), ImmutableSet.of(c1, c2, dc1, dc2)); }
@VisibleForTesting Set<QueryLaunchingConstraint> prepareAllConstraints(final QueryContext candidateQuery) { ImmutableSet<QueryLaunchingConstraint> driverConstraints = candidateQuery.getSelectedDriverQueryConstraints(); BackOffRetryHandler<QueryContext> retryPolicy = candidateQuery.getRetryPolicy(); Sets.SetView<QueryLaunchingConstraint> constraints = Sets.union(this.lensQueryConstraints, driverConstraints); if (retryPolicy == null) { return constraints; } else { return Sets.union(Collections.singleton(new RetryPolicyToConstraingAdapter(retryPolicy)), constraints); } }
DefaultQueryLaunchingConstraintsChecker implements QueryLaunchingConstraintsChecker { @VisibleForTesting Set<QueryLaunchingConstraint> prepareAllConstraints(final QueryContext candidateQuery) { ImmutableSet<QueryLaunchingConstraint> driverConstraints = candidateQuery.getSelectedDriverQueryConstraints(); BackOffRetryHandler<QueryContext> retryPolicy = candidateQuery.getRetryPolicy(); Sets.SetView<QueryLaunchingConstraint> constraints = Sets.union(this.lensQueryConstraints, driverConstraints); if (retryPolicy == null) { return constraints; } else { return Sets.union(Collections.singleton(new RetryPolicyToConstraingAdapter(retryPolicy)), constraints); } } }
DefaultQueryLaunchingConstraintsChecker implements QueryLaunchingConstraintsChecker { @VisibleForTesting Set<QueryLaunchingConstraint> prepareAllConstraints(final QueryContext candidateQuery) { ImmutableSet<QueryLaunchingConstraint> driverConstraints = candidateQuery.getSelectedDriverQueryConstraints(); BackOffRetryHandler<QueryContext> retryPolicy = candidateQuery.getRetryPolicy(); Sets.SetView<QueryLaunchingConstraint> constraints = Sets.union(this.lensQueryConstraints, driverConstraints); if (retryPolicy == null) { return constraints; } else { return Sets.union(Collections.singleton(new RetryPolicyToConstraingAdapter(retryPolicy)), constraints); } } DefaultQueryLaunchingConstraintsChecker(
    @NonNull final ImmutableSet<QueryLaunchingConstraint> lensQueryConstraints); }
DefaultQueryLaunchingConstraintsChecker implements QueryLaunchingConstraintsChecker { @VisibleForTesting Set<QueryLaunchingConstraint> prepareAllConstraints(final QueryContext candidateQuery) { ImmutableSet<QueryLaunchingConstraint> driverConstraints = candidateQuery.getSelectedDriverQueryConstraints(); BackOffRetryHandler<QueryContext> retryPolicy = candidateQuery.getRetryPolicy(); Sets.SetView<QueryLaunchingConstraint> constraints = Sets.union(this.lensQueryConstraints, driverConstraints); if (retryPolicy == null) { return constraints; } else { return Sets.union(Collections.singleton(new RetryPolicyToConstraingAdapter(retryPolicy)), constraints); } } DefaultQueryLaunchingConstraintsChecker(
    @NonNull final ImmutableSet<QueryLaunchingConstraint> lensQueryConstraints); @Override boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries); }
DefaultQueryLaunchingConstraintsChecker implements QueryLaunchingConstraintsChecker { @VisibleForTesting Set<QueryLaunchingConstraint> prepareAllConstraints(final QueryContext candidateQuery) { ImmutableSet<QueryLaunchingConstraint> driverConstraints = candidateQuery.getSelectedDriverQueryConstraints(); BackOffRetryHandler<QueryContext> retryPolicy = candidateQuery.getRetryPolicy(); Sets.SetView<QueryLaunchingConstraint> constraints = Sets.union(this.lensQueryConstraints, driverConstraints); if (retryPolicy == null) { return constraints; } else { return Sets.union(Collections.singleton(new RetryPolicyToConstraingAdapter(retryPolicy)), constraints); } } DefaultQueryLaunchingConstraintsChecker(
    @NonNull final ImmutableSet<QueryLaunchingConstraint> lensQueryConstraints); @Override boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries);  }