### Question:
JobQueueBatch implements Serializable { public void setRunningStatus(UUID aggregatorID) { if (this.status != JobStatus.QUEUED) { throw new JobQueueFailure(jobID, batchID, String.format("Cannot run job. JobStatus: %s", this.status)); } this.verifyAggregatorID(aggregatorID); status = JobStatus.RUNNING; this.aggregatorID = aggregatorID; startTime = OffsetDateTime.now(ZoneOffset.UTC); this.setUpdateTime(); } JobQueueBatch();  JobQueueBatch(UUID jobID,
                         UUID orgID,
                         String providerID,
                         List<String> patients,
                         List<ResourceType> resourceTypes,
                         OffsetDateTime since,
                         OffsetDateTime transactionTime); static Boolean isValidResourceType(ResourceType type); Boolean isValid(); UUID getBatchID(); UUID getJobID(); UUID getOrgID(); String getProviderID(); JobStatus getStatus(); Integer getPriority(); List<String> getPatients(); Optional<Integer> getPatientIndex(); List<ResourceType> getResourceTypes(); Optional<OffsetDateTime> getSince(); OffsetDateTime getTransactionTime(); Optional<UUID> getAggregatorID(); void setAggregatorIDForTesting(UUID aggregatorID); Optional<OffsetDateTime> getUpdateTime(); Optional<OffsetDateTime> getSubmitTime(); Optional<OffsetDateTime> getStartTime(); Optional<OffsetDateTime> getCompleteTime(); void setCompleteTime(OffsetDateTime time); List<JobQueueBatchFile> getJobQueueBatchFiles(); Optional<JobQueueBatchFile> getJobQueueFile(ResourceType forResourceType); Optional<JobQueueBatchFile> getJobQueueFile(String fileName); synchronized Optional<JobQueueBatchFile> getJobQueueFileLatest(ResourceType forResourceType); synchronized JobQueueBatchFile addJobQueueFile(ResourceType resourceType, int sequence, int batchSize); void setRunningStatus(UUID aggregatorID); Optional<String> fetchNextPatient(UUID aggregatorID); void setPausedStatus(UUID aggregatorID); void setCompletedStatus(UUID aggregatorID); void setFailedStatus(UUID aggregatorID); void restartBatch(); void setPriority(Integer priority); void setUpdateTime(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final List<ResourceType> validResourceTypes; }### Answer:
@Test void testSetRunningStatus() { final var job = Mockito.spy(createJobQueueBatch()); job.setRunningStatus(aggregatorID); assertEquals(JobStatus.RUNNING, job.getStatus()); assertEquals(aggregatorID, job.getAggregatorID().get()); assertNotNull(job.getStartTime()); Mockito.verify(job).verifyAggregatorID(aggregatorID); }
@Test void testSetRunningStatus_NotInQueuedState() { final var job = createJobQueueBatch(); job.status = JobStatus.RUNNING; try { job.setRunningStatus(aggregatorID); Assertions.fail(); } catch (JobQueueFailure e) { assertTrue(e.getMessage().contains("Cannot run job. JobStatus")); } }