AsyncJobStatusCurator extends AbstractHibernateCurator<AsyncJobStatus> { public int updateJobState(AsyncJobStatusQueryBuilder queryBuilder, JobState state) { EntityManager entityManager = this.getEntityManager(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaUpdate<AsyncJobStatus> update = criteriaBuilder.createCriteriaUpdate(AsyncJobStatus.class); Root<AsyncJobStatus> job = update.from(AsyncJobStatus.class); update.<Integer>set(job.get("previousState"), job.get("state")) .set(job.get("state"), state); List<Predicate> predicates = this.buildJobQueryPredicates(criteriaBuilder, job, queryBuilder); if (predicates.size() > 0) { Predicate[] predicateArray = new Predicate[predicates.size()]; update.where(predicates.toArray(predicateArray)); return entityManager.createQuery(update) .executeUpdate(); } return 0; } AsyncJobStatusCurator(); List<AsyncJobStatus> getJobsInState(Collection<JobState> states); List<AsyncJobStatus> getJobsInState(JobState... states); List<AsyncJobStatus> getNonTerminalJobs(); List<AsyncJobStatus> findJobs(AsyncJobStatusQueryBuilder queryBuilder); long getJobCount(AsyncJobStatusQueryBuilder queryBuilder); int deleteJobs(AsyncJobStatusQueryBuilder queryBuilder); int updateJobState(AsyncJobStatusQueryBuilder queryBuilder, JobState state); List<String> fetchJobIdsByArguments(String jobKey, Map<String, String> arguments); static final int MAX_JOB_ARGUMENTS_PER_QUERY; }
@Test public void testUpdateJobStateByIdsWithExtraneous() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expectedJobIds = new Random().ints(Math.min(3, created.size()), 0, created.size()) .mapToObj(i -> created.get(i)) .map(job -> job.getId()) .collect(Collectors.toList()); List<String> extraneousJobIds = Arrays.asList("extra_id-1", "extra_id-2", "extra_id-3"); List<String> jobIds = new LinkedList<>(); jobIds.addAll(expectedJobIds); jobIds.addAll(extraneousJobIds); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setJobIds(jobIds); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(extraneousJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateBySingleJobKey() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expected = Arrays.asList("job_key-1"); List<String> extraneous = Arrays.asList(); List<String> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getJobKey())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setJobKeys(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByMultipleJobKeys() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expected = Arrays.asList("job_key-1", "job_key-2"); List<String> extraneous = Arrays.asList(); List<String> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getJobKey())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setJobKeys(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByMultipleJobKeysWithExtraneousKeys() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expected = Arrays.asList("job_key-1", "job_key-3"); List<String> extraneous = Arrays.asList("job_key-4", "job_key-6"); List<String> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getJobKey())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setJobKeys(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateBySingleJobState() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<JobState> expected = Arrays.asList(JobState.CREATED); List<JobState> extraneous = Arrays.asList(); List<JobState> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getState())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setJobStates(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByMultipleJobStates() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<JobState> expected = Arrays.asList(JobState.CREATED, JobState.RUNNING); List<JobState> extraneous = Arrays.asList(); List<JobState> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getState())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setJobStates(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByMultipleJobStatesWithExtraneousStates() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<JobState> expected = Arrays.asList(JobState.CREATED, JobState.QUEUED); List<JobState> extraneous = Arrays.asList(JobState.SCHEDULED); List<JobState> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getState())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setJobStates(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByOwnerIds() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expected = Arrays.asList(owners.get(1).getId()); List<String> extraneous = Arrays.asList(); List<String> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getContextOwnerId())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setOwnerIds(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByMultipleOwnerIds() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expected = Arrays.asList(owners.get(1).getId(), owners.get(3).getId()); List<String> extraneous = Arrays.asList(); List<String> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getContextOwnerId())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setOwnerIds(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByMultipleOwnerIdsWithExtraneousOwners() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expected = Arrays.asList(owners.get(1).getId(), owners.get(3).getId()); List<String> extraneous = Arrays.asList("ex_owner_id-1", "ex_owner_id-2"); List<String> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getContextOwnerId())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setOwnerIds(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByNullOwnerId() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expected = Arrays.asList((String) null); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getContextOwnerId())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setOwnerIds(expected); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByMixedOwnerIds() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> expected = Arrays.asList(null, owners.get(2).getId()); List<String> extraneous = Arrays.asList(); List<String> combined = new LinkedList<>(); combined.addAll(expected); combined.addAll(extraneous); List<String> expectedJobIds = created.stream() .filter(job -> expected.contains(job.getContextOwnerId())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setOwnerIds(combined); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByLastUpdateTimeBeforeDate() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } Date now = new Date(); List<String> expectedJobIds = created.stream() .filter(job -> now.compareTo(job.getUpdated()) >= 0) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setEndDate(now); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByLastUpdateTimeAfterDate() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } Date now = new Date(); List<String> expectedJobIds = created.stream() .filter(job -> now.compareTo(job.getUpdated()) <= 0) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setStartDate(now); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByLastUpdateTimeInRange() { List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<JobState> states = Arrays.asList(JobState.CREATED, JobState.QUEUED, JobState.RUNNING); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } Date start = Util.addDaysToDt(-1); Date end = Util.addDaysToDt(1); List<String> expectedJobIds = created.stream() .filter(job -> start.compareTo(job.getUpdated()) <= 0 && end.compareTo(job.getUpdated()) >= 0) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setStartDate(start) .setEndDate(end); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateByMultipleParameters() { Owner owner1 = this.createOwner(); Owner owner2 = this.createOwner(); List<String> keys = Arrays.asList("job_key-1", "job_key-2", "job_key-3"); List<Owner> owners = Arrays.asList(null, owner1, owner2); List<JobState> states = Arrays.asList(JobState.QUEUED, JobState.RUNNING, JobState.FAILED, JobState.FINISHED); List<String> principals = Arrays.asList("principal-1", "principal-2", "principal-3"); List<String> origins = Arrays.asList("origin-1", "origin-2", "origin-3"); List<String> executors = Arrays.asList("executor-1", "executor-2", "executor-3"); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, principals, origins, executors); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } List<String> jobKeys = Arrays.asList("job_key-1"); List<JobState> jobStates = Arrays.asList(JobState.QUEUED, JobState.RUNNING); List<String> ownerIds = Arrays.asList(owner2.getId()); List<String> jobPrincipals = Arrays.asList("principal-2"); List<String> jobOrigins = Arrays.asList("origin-3"); List<String> jobExecutors = Arrays.asList("executor-1"); Date start = Util.addDaysToDt(-1); Date end = Util.addDaysToDt(1); List<String> expectedJobIds = created.stream() .filter(job -> jobKeys.contains(job.getJobKey())) .filter(job -> jobStates.contains(job.getState())) .filter(job -> job.getContextOwner() != null && ownerIds.contains(job.getContextOwner().getId())) .filter(job -> start.compareTo(job.getUpdated()) <= 0 && end.compareTo(job.getUpdated()) >= 0) .filter(job -> jobPrincipals.contains(job.getPrincipalName())) .filter(job -> jobOrigins.contains(job.getOrigin())) .filter(job -> jobExecutors.contains(job.getExecutor())) .map(job -> job.getId()) .collect(Collectors.toList()); assertTrue(expectedJobIds.size() > 0); AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder() .setJobKeys(jobKeys) .setJobStates(jobStates) .setOwnerIds(ownerIds) .setPrincipalNames(jobPrincipals) .setOrigins(jobOrigins) .setExecutors(jobExecutors) .setStartDate(start) .setEndDate(end); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(expectedJobIds.size(), updated); this.validateJobStates(jobMap, expectedJobIds, JobState.ABORTED); }
@Test public void testUpdateJobStateWithoutParameters() { List<String> keys = Arrays.asList("job_key-1", "job_key-2"); List<JobState> states = Arrays.asList(JobState.values()); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } AsyncJobStatusQueryBuilder queryBuilder = new AsyncJobStatusQueryBuilder(); int updated = this.asyncJobCurator.updateJobState(queryBuilder, JobState.ABORTED); assertEquals(0, updated); this.validateJobStates(jobMap, Arrays.asList(), JobState.ABORTED); }
@Test public void testUpdateJobStateWithNullBuilder() { List<String> keys = Arrays.asList("job_key-1", "job_key-2"); List<JobState> states = Arrays.asList(JobState.values()); List<Owner> owners = Arrays.asList(null, this.createOwner(), this.createOwner()); List<AsyncJobStatus> created = this.createJobsForQueryTests(keys, states, owners, null, null, null); Map<String, AsyncJobStatus> jobMap = new HashMap<>(); for (AsyncJobStatus job : created) { jobMap.put(job.getId(), job); } int updated = this.asyncJobCurator.updateJobState(null, JobState.ABORTED); assertEquals(0, updated); this.validateJobStates(jobMap, Arrays.asList(), JobState.ABORTED); }