@Test public void testCanLaunchShouldReturnTrueWhenConstraintsSetIsEmpty() { QueryContext mockCandidateQuery = mock(QueryContext.class); EstimatedImmutableQueryCollection mockRunningQueries = mock(EstimatedImmutableQueryCollection.class); ImmutableSet<QueryLaunchingConstraint> emptySetOfConstraints = ImmutableSet.copyOf(Sets.<QueryLaunchingConstraint>newHashSet()); when(mockCandidateQuery.getSelectedDriverQueryConstraints()).thenReturn(emptySetOfConstraints); QueryLaunchingConstraintsChecker constraintsChecker = new DefaultQueryLaunchingConstraintsChecker(ImmutableSet.copyOf(emptySetOfConstraints)); boolean canLaunchQuery = constraintsChecker.canLaunch(mockCandidateQuery, mockRunningQueries); Assert.assertTrue(canLaunchQuery); }
@Override public boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { Set<QueryLaunchingConstraint> allConstraints = prepareAllConstraints(candidateQuery); for (QueryLaunchingConstraint queryConstraint : allConstraints) { String launchRejectionMessage = queryConstraint.allowsLaunchOf(candidateQuery, launchedQueries); if (launchRejectionMessage != null) { log.info("query {} not allowed to launch. Constraint failed: {} with message: {}", candidateQuery, queryConstraint, launchRejectionMessage); candidateQuery.getStatus().setProgressMessage(launchRejectionMessage); return false; } } return true; }
DefaultQueryLaunchingConstraintsChecker implements QueryLaunchingConstraintsChecker { @Override public boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { Set<QueryLaunchingConstraint> allConstraints = prepareAllConstraints(candidateQuery); for (QueryLaunchingConstraint queryConstraint : allConstraints) { String launchRejectionMessage = queryConstraint.allowsLaunchOf(candidateQuery, launchedQueries); if (launchRejectionMessage != null) { log.info("query {} not allowed to launch. Constraint failed: {} with message: {}", candidateQuery, queryConstraint, launchRejectionMessage); candidateQuery.getStatus().setProgressMessage(launchRejectionMessage); return false; } } return true; } }
DefaultQueryLaunchingConstraintsChecker implements QueryLaunchingConstraintsChecker { @Override public boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { Set<QueryLaunchingConstraint> allConstraints = prepareAllConstraints(candidateQuery); for (QueryLaunchingConstraint queryConstraint : allConstraints) { String launchRejectionMessage = queryConstraint.allowsLaunchOf(candidateQuery, launchedQueries); if (launchRejectionMessage != null) { log.info("query {} not allowed to launch. Constraint failed: {} with message: {}", candidateQuery, queryConstraint, launchRejectionMessage); candidateQuery.getStatus().setProgressMessage(launchRejectionMessage); return false; } } return true; } DefaultQueryLaunchingConstraintsChecker(
    @NonNull final ImmutableSet<QueryLaunchingConstraint> lensQueryConstraints); }
DefaultQueryLaunchingConstraintsChecker implements QueryLaunchingConstraintsChecker { @Override public boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { Set<QueryLaunchingConstraint> allConstraints = prepareAllConstraints(candidateQuery); for (QueryLaunchingConstraint queryConstraint : allConstraints) { String launchRejectionMessage = queryConstraint.allowsLaunchOf(candidateQuery, launchedQueries); if (launchRejectionMessage != null) { log.info("query {} not allowed to launch. Constraint failed: {} with message: {}", candidateQuery, queryConstraint, launchRejectionMessage); candidateQuery.getStatus().setProgressMessage(launchRejectionMessage); return false; } } return true; } DefaultQueryLaunchingConstraintsChecker(
    @NonNull final ImmutableSet<QueryLaunchingConstraint> lensQueryConstraints); @Override boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries); }
DefaultQueryLaunchingConstraintsChecker implements QueryLaunchingConstraintsChecker { @Override public boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { Set<QueryLaunchingConstraint> allConstraints = prepareAllConstraints(candidateQuery); for (QueryLaunchingConstraint queryConstraint : allConstraints) { String launchRejectionMessage = queryConstraint.allowsLaunchOf(candidateQuery, launchedQueries); if (launchRejectionMessage != null) { log.info("query {} not allowed to launch. Constraint failed: {} with message: {}", candidateQuery, queryConstraint, launchRejectionMessage); candidateQuery.getStatus().setProgressMessage(launchRejectionMessage); return false; } } return true; } DefaultQueryLaunchingConstraintsChecker(
    @NonNull final ImmutableSet<QueryLaunchingConstraint> lensQueryConstraints); @Override boolean canLaunch(final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries);  }