JobServiceImpl extends WaspMessageHandlingServiceImpl implements JobService { @Override public Job createJobFromJobDraft(JobDraft jobDraft, User user) throws FileMoveException{ Assert.assertParameterNotNull(jobDraft, "No JobDraft provided"); Assert.assertParameterNotNullNotZero(jobDraft.getId(), "Invalid JobDraft Provided"); Assert.assertParameterNotNull(user, "No User provided"); Assert.assertParameterNotNullNotZero(user.getId(), "Invalid User Provided"); Job job = new Job(); job.setUserId(user.getId()); job.setLabId(jobDraft.getLabId()); job.setName(jobDraft.getName()); job.setWorkflowId(jobDraft.getWorkflowId()); job.setIsActive(1); job.setViewablebylab(0); Job jobDb = jobDao.save(job); String sampleDraftPairs = null; for (JobDraftMeta jdm: jobDraft.getJobDraftMeta()) { if(jdm.getK().indexOf(SAMPLE_PAIR_META_KEY)>-1){ sampleDraftPairs = jdm.getV(); continue; } if(jdm.getK().indexOf(REPLICATE_SETS_META_KEY)>-1){ continue; } JobMeta jobMeta = new JobMeta(); jobMeta.setJobId(jobDb.getId()); jobMeta.setK(jdm.getK()); jobMeta.setV(jdm.getV()); jobMetaDao.save(jobMeta); } for (JobDraftSoftware jdr: jobDraft.getJobDraftSoftware()) { JobSoftware jobSoftware = new JobSoftware(); jobSoftware.setJobId(jobDb.getId()); jobSoftware.setSoftwareId(jdr.getSoftwareId()); jobSoftwareDao.save(jobSoftware); } for (JobDraftresourcecategory jdr: jobDraft.getJobDraftresourcecategory()) { JobResourcecategory jobResourceCategory = new JobResourcecategory(); jobResourceCategory.setJobId(jobDb.getId()); jobResourceCategory.setResourcecategoryId(jdr.getResourcecategoryId()); jobResourcecategoryDao.save(jobResourceCategory); } JobUser jobUser = new JobUser(); jobUser.setUserId(user.getId()); jobUser.setJobId(jobDb.getId()); Role role = roleDao.getRoleByRoleName("js"); jobUser.setRoleId(role.getId()); jobUserDao.save(jobUser); Lab lab = labDao.getLabByLabId(jobDb.getLabId()); if (jobUser.getUserId().intValue() != lab.getPrimaryUserId().intValue()) { JobUser jobUser2 = new JobUser(); jobUser2.setUserId(lab.getPrimaryUserId()); jobUser2.setJobId(jobDb.getId()); Role role2 = roleDao.getRoleByRoleName("jv"); jobUser2.setRoleId(role2.getId()); jobUserDao.save(jobUser2); } Map<Integer,JobCellSelection> jobDraftCellMap = new HashMap<Integer,JobCellSelection>(); for (JobDraftCellSelection jdc: jobDraft.getJobDraftCellSelection()) { JobCellSelection jobCellSelection = new JobCellSelection(); jobCellSelection.setJobId(jobDb.getId()); jobCellSelection.setCellIndex(jdc.getCellIndex()); JobCellSelection jobCellSelectionDb = jobCellSelectionDao.save(jobCellSelection); jobDraftCellMap.put(jdc.getId(), jobCellSelectionDb); } List<Sample> samples = new ArrayList<Sample>(); Map<Integer, Integer> sampleDraftIDKeyToSampleIDValueMap = new HashMap<Integer, Integer>(); Map<SampleDraft, Sample> sampleDraftKeyToSampleValueMap = new HashMap<SampleDraft, Sample>(); for (SampleDraft sd: jobDraft.getSampleDraft()) { Sample sample = new Sample(); sample.setName(sd.getName()); sample.setSampleTypeId(sd.getSampleTypeId()); sample.setSampleSubtypeId(sd.getSampleSubtypeId()); sample.setSubmitterLabId(jobDb.getLabId()); sample.setSubmitterUserId(user.getId()); sample.setSubmitterJobId(jobDb.getId()); sample.setIsReceived(0); sample.setIsActive(1); Sample sampleDb = sampleDao.save(sample); samples.add(sampleDb); sampleDraftIDKeyToSampleIDValueMap.put(sd.getId(), sampleDb.getId()); sampleDraftKeyToSampleValueMap.put(sd, sampleDb); for (SampleDraftMeta sdm: sd.getSampleDraftMeta()) { SampleMeta sampleMeta = new SampleMeta(); sampleMeta.setSampleId(sampleDb.getId()); sampleMeta.setK(sdm.getK()); sampleMeta.setV(sdm.getV()); sampleMeta.setPosition(sdm.getPosition()); sampleMetaDao.save(sampleMeta); } JobSample jobSample = new JobSample(); jobSample.setJobId(jobDb.getId()); jobSample.setSampleId(sampleDb.getId()); jobSampleDao.save(jobSample); for (SampleDraftJobDraftCellSelection sdc: sd.getSampleDraftJobDraftCellSelection()) { SampleJobCellSelection sampleJobCellSelection = new SampleJobCellSelection(); sampleJobCellSelection.setSampleId(sampleDb.getId()); sampleJobCellSelection.setJobCellSelectionId(jobDraftCellMap.get(sdc.getJobDraftCellSelectionId()).getId()); sampleJobCellSelection.setLibraryIndex(sdc.getLibraryIndex()); sampleJobCellSelectionDao.save(sampleJobCellSelection); } } if(sampleDraftPairs != null){ for(String pair : sampleDraftPairs.split(";")){ try{ String[] pairList = pair.split(":"); Integer T = sampleDraftIDKeyToSampleIDValueMap.get(Integer.valueOf(pairList[0])); Integer C = sampleDraftIDKeyToSampleIDValueMap.get(Integer.valueOf(pairList[1])); sampleService.createTestControlSamplePairsByIds(T, C, jobDb); }catch(Exception e){ logger.warn("e.getMessage(): Error translate sampleDraftPairs to samplePairs"); throw new RuntimeException("Error translate sampleDraftPairs to samplePairs"); } } } List<List<SampleDraft>> replicateSetsListForJobDraft = jobDraftService.getReplicateSets(jobDraft); StringBuilder replicatesAsStringBuilder = new StringBuilder(""); for(List<SampleDraft> sampleDraftReplicateSet : replicateSetsListForJobDraft){ int counter = 0; for(SampleDraft sd : sampleDraftReplicateSet){ if(counter++ > 0){ replicatesAsStringBuilder.append(":"); } Integer sampleId = sampleDraftIDKeyToSampleIDValueMap.get(sd.getId()); replicatesAsStringBuilder.append(sampleId.toString()); } if(counter>0){ replicatesAsStringBuilder.append(";"); } } String replicatesString = new String(replicatesAsStringBuilder); if(!replicatesString.isEmpty()){ JobMeta jobMeta = new JobMeta(); jobMeta.setJobId(jobDb.getId()); String replicatesKey = jobDb.getWorkflow().getIName()+"."+REPLICATE_SETS_META_KEY; jobMeta.setK(replicatesKey); jobMeta.setV(replicatesString); jobMetaDao.save(jobMeta); } if (jobDraft.getJobDraftFile() != null) { for (JobDraftFile jdf : jobDraft.getJobDraftFile()) { FileGroup group = jdf.getFileGroup(); try { fileService.promoteJobDraftFileGroupToJob(jobDb, group); } catch (Exception e) { logger.warn(e.getLocalizedMessage()); throw new RuntimeException(e); } } } AcctGrant grant = accountsService.getGrantForJobDraft(jobDraft); accountsService.saveJobGrant(jobDb, grant); jobDraft.setStatus("SUBMITTED"); jobDraft.setSubmittedjobId(jobDb.getId()); jobDraftDao.save(jobDraft); logger.debug("calling initiateBatchJobForJobSubmission() for job with id='" + jobDb.getId() + "'"); initiateBatchJobForJobSubmission(jobDb); for (Sample sample: samples){ logger.debug("calling initiateBatchJobForSample() for sample with id='" + sample.getId() + "'"); if (sampleTypeDao.getSampleTypeBySampleTypeId(sample.getSampleTypeId()).getIName().equals("library")){ sampleService.initiateBatchJobForSample(jobDb, sample, "wasp.userLibrary.jobflow.v1"); } else { sampleService.initiateBatchJobForSample(jobDb, sample, "wasp.sample.jobflow.v1"); } } return jobDb; }  @Override @Autowired void setJobDao(JobDao jobDao); @Override JobDao getJobDao(); @Autowired void setJobMetaDao(JobMetaDao jobMetaDao); @Override JobMetaDao getJobMetaDao(); void setJobSoftwareDao(JobSoftwareDao jobSoftwareDao); void setJobResourcecategoryDao(JobResourcecategoryDao jobResourcecategoryDao); void setJobSampleDao(JobSampleDao jobSampleDao); @Override JobSampleDao getJobSampleDao(); void setSampleDao(SampleDao sampleDao); void setRoleDao(RoleDao roleDao); void setJobUserDao(JobUserDao jobUserDao); void setLabDao(LabDao labDao); void setJobCellSelectionDao(JobCellSelectionDao jobCellSelectionDao); void setSampleJobCellSelectionDao(SampleJobCellSelectionDao sampleJobCellSelectionDao); void setWorkflowDao(WorkflowDao workflowDao); void setJobDraftDao(JobDraftDao jobDraftDao); void setSampleMetaDao(SampleMetaDao sampleMetaDao); void setSampleService(SampleService sampleService); void setSampleTypeDao(SampleTypeDao sampleTypeDao); void setLogger(Logger logger); JobDraftService getJobDraftService(); void setJobDraftService(JobDraftService jobDraftService); @Override Job getJobByJobId(Integer jobId); @Override @Transactional(value="entityManager", propagation=Propagation.REQUIRES_NEW) Job getJobByJobIdInDiscreteTransaction(Integer jobId); @Override List<Sample> getSubmittedSamples(Job job); @Override List<Sample> getSubmittedSamplesNotYetReceived(Job job); @Override List<Sample> getSubmittedSamplesNotYetQC(Job job); @Override List<Sample> getLibrariesNotYetQC(Job job); @Override List<Job> getActiveJobs(); @Override boolean isJobActive(Job job); @Override List<Job> getJobsAwaitingReceivingOfSamples(); @Override boolean isJobsAwaitingReceivingOfSamples(List<Job> activeJobs); @Override boolean isJobAwaitingReceivingOfSamples(Job job); @Override boolean isJobAwaitingCellLibraryQC(Job job); @Override boolean isJobsAwaitingCellLibraryQC(List<Job> jobs); @Override List<Job> getJobsAwaitingFmApproval(); @Override List<Job> getJobsAwaitingPiLmApproval(); @Override List<Job> getJobsAwaitingDaApproval(); @Override List<Job> getJobsAwaitingSampleQC(); @Override boolean isJobAwaitingSampleQC(Job job); @Override boolean isJobsAwaitingSampleQC(List<Job> jobs); @Override List<Job> getJobsAwaitingLibraryQC(); @Override boolean isJobsAwaitingLibraryQC(List<Job> jobs); @Override boolean isJobAwaitingLibraryQC(Job job); @Override void sortJobsByJobId(List<Job> jobs); @Override boolean isJobAwaitingPiApproval(Job job); @Override boolean isJobAwaitingDaApproval(Job job); @Override boolean isJobAwaitingFmApproval(Job job); @Override boolean isJobPendingApprovalOrQuote(Job job); @Override boolean isJobAwaitingQuote(Job job); @Override List<Job> getJobsAwaitingQuote(); @Override boolean isJobsAwaitingQuote(List<Job> activeJobs); @Override LinkedHashMap<String, String> getExtraJobDetails(Job job); @Override LinkedHashMap<String, String> getJobApprovals(Job job); @Override Job createJobFromJobDraft(JobDraft jobDraft, User user); @Override void initiateBatchJobForJobSubmission(Job job); @Override List<Job> getJobsAwaitingLibraryCreation(); @Override boolean isJobAwaitingLibraryCreation(Job job); @Override List<Job> getJobsWithLibrariesToGoOnPlatformUnit(ResourceCategory resourceCategory); @Override List<Job> getJobsWithLibrariesToGoOnPlatformUnit(); @Override boolean isJobWithLibrariesToGoOnPlatformUnit(Job job); @Override List<Sample> getPlatformUnitWithLibrariesOnForJob(Job job); @Override List<Job> getJobsSubmittedOrViewableByUser(User user); @Override boolean isJobAwaitingLibraryCreation(Job job, Sample sample); @Override void updateJobQuoteStatus(Job job, WaspStatus status); @Override void updateJobApprovalStatus(String jobApproveCode, Job job, WaspStatus status, String comment); @Override void updateJobDaApprovalStatus(Job job, WaspStatus status, String comment); @Override void updateJobPiApprovalStatus(Job job, WaspStatus status, String comment); @Override void updateJobFmApprovalStatus(Job job, WaspStatus status, String comment); @Override void addJobViewer(Integer jobId, String newViewerEmailAddress); @Override void removeJobViewer(Integer jobId, Integer userId); @Override void setFacilityJobComment(Integer jobId, String comment); @Override List<MetaMessage> getAllFacilityJobComments(Integer jobId); @Override void setUserSubmittedJobComment(Integer jobId, String comment); @Override List<MetaMessage> getUserSubmittedJobComment(Integer jobId); @Override Map<Sample, String> getCoverageMap(Job job); @Override void setJobDao(SampleDao mockSampleDao); @Override WaspJobContext getWaspJobContext(Job job); @Override void setJobApprovalComment(String jobApproveCode, Integer jobId, String comment); @Override List<MetaMessage> getJobApprovalComments(String jobApproveCode, Integer jobId); @Override HashMap<String, MetaMessage> getLatestJobApprovalsComments(Set<String> jobApproveCodeSet, Integer jobId); @Override Map<String, Object> getTreeViewBranch(Integer id, Integer pid, String type, Integer jid); @Override LinkedHashMap<String, Object> getJobDetailWithMeta(int jobId); @Override String getJobStatusComment(Job job); @Override String getDetailedJobStatusString(Job job); @Override List<Software> getSoftwareForJob(Job job); @Override boolean isQcPerformedOrPreprocessingFailedForAtLeastOneCellLibraryForAllSubmittedSamples(Job job); @Override boolean isAnySampleCurrentlyBeingProcessed(Job job); @Override void initiateAggregationAnalysisBatchJob(Job job); @Override JobDataTabViewing getTabViewPluginByJob(Job job); @Override List<Job> getActiveJobsWithNoSamplesCurrentlyBeingProcessed(); boolean isAggregationAnalysisBatchJob(Job job); @Override ExitStatus getJobStatus(Job job); @Override boolean isTerminated(Job job); @Override boolean isFinishedSuccessfully(Job job); @Override void terminate(Job job); @Override void setJobApprovalStatusAndComment(String jobApproveCode, Job job, WaspStatus status, String comment); @Override void addNewQuote(Integer jobId, AcctQuote quoteForm, List<AcctQuoteMeta> metaList); @Override Job getJobAndSoftware(Job job); @Override List<Sample> getLibraries(Job job); @Override FileGroup createNewQuoteAndSaveQuoteFile(MPSQuote mpsQuote, File file, Float totalFinalCost, boolean saveQuoteAsJSON); @Override FileGroup createNewQuoteOrInvoiceAndUploadFile(Job job, MultipartFile mpFile, String fileDescription, Float totalCost); @Override Strategy getStrategy(String strategyType, Job job); @Override List<JobMeta> getJobMeta(Integer jobId); @Override List<List<Sample>> getSampleReplicates(Job job); @Override boolean getIsAnalysisSelected(Job job); @Override List<String> getAllPossibleJobStatusAsString(); @Override boolean updateJobAnalysisSelected(Job job, boolean analysisSelected, List<Integer> softwareIdList); Date getJobCompletionDate(Job job); static final String SAMPLE_PAIR_META_KEY; }
@Test (description="") public void createJobFromJobDraft () { mockJobServiceImpl.setJobDao(mockJobDao); mockJobServiceImpl.setSampleDao(mockSampleDao); mockJobServiceImpl.setJobMetaDao(mockJobMetaDao); mockJobServiceImpl.setJobSoftwareDao(mockJobSoftwareDao); mockJobServiceImpl.setJobResourcecategoryDao(mockJobResourcecategoryDao); mockJobServiceImpl.setRoleDao(mockRoleDao); mockJobServiceImpl.setJobUserDao(mockJobUserDao); mockJobServiceImpl.setLabDao(mockLabDao); mockJobServiceImpl.setJobCellSelectionDao(mockJobCellSelectionDao); mockJobServiceImpl.setSampleMetaDao(mockSampleMetaDao); mockJobServiceImpl.setJobSampleDao(mockJobSampleDao); mockJobServiceImpl.setSampleJobCellSelectionDao(mockSampleJobCellSelectionDao); mockJobServiceImpl.setJobDraftDao(mockJobDraftDao); mockJobServiceImpl.setSampleTypeDao(mockSampleTypeDao); mockJobServiceImpl.setJobDraftService(mockJobDraftServiceImpl); ReflectionTestUtils.setField(mockJobServiceImpl, "accountsService", mockAccountsService); mockJobServiceImpl.setLogger(LoggerFactory.getLogger(WaspServiceImpl.class)); User user = new User(); user.setUserId(123); JobDraft jobDraft = new JobDraft(); jobDraft.setJobDraftId(1); jobDraft.setLabId(123); jobDraft.setName("my job"); jobDraft.setWorkflowId(1); Job job = new Job(); job.setJobId(1); job.setUserId(user.getUserId()); job.setLabId(jobDraft.getLabId()); job.setName(jobDraft.getName()); job.setWorkflowId(jobDraft.getWorkflowId()); job.setIsActive(1); job.setCreatets(new Date()); job.setViewablebylab(0); expect(mockJobDao.save(EasyMock.isA(Job.class))).andReturn(job); replay(mockJobDao); JobDraftMeta jobDraftMeta = new JobDraftMeta(); jobDraftMeta.setK("chipSeq.samplePairsTvsC"); jobDraftMeta.setV("1:2;2:1;"); List <JobDraftMeta> jobDraftMetaList = new ArrayList <JobDraftMeta>(); jobDraftMetaList.add(jobDraftMeta); jobDraft.setJobDraftMeta(jobDraftMetaList); JobMeta jobMeta = new JobMeta(); jobMeta.setJobId(job.getJobId()); jobMeta.setK(jobDraftMeta.getK()); jobMeta.setV(jobDraftMeta.getV()); expect(mockJobMetaDao.save(EasyMock.isA(JobMeta.class))).andReturn(jobMeta); replay(mockJobMetaDao); List<List<SampleDraft>> replicateSetsListForJobDraft = new ArrayList<List<SampleDraft>>(); expect(mockJobDraftServiceImpl.getReplicateSets(EasyMock.isA(JobDraft.class))).andReturn(replicateSetsListForJobDraft); replay(mockJobDraftServiceImpl); JobDraftSoftware jobDraftSoftware = new JobDraftSoftware(); jobDraftSoftware.setSoftwareId(new Integer(123)); List <JobDraftSoftware> jobDraftSoftwareList = new ArrayList <JobDraftSoftware>(); jobDraftSoftwareList.add(jobDraftSoftware); jobDraft.setJobDraftSoftware(jobDraftSoftwareList); JobSoftware jobSoftware = new JobSoftware(); jobSoftware.setJobId(job.getJobId()); jobSoftware.setSoftwareId(jobDraftSoftware.getSoftwareId()); expect(mockJobSoftwareDao.save(EasyMock.isA(JobSoftware.class))).andReturn(jobSoftware); replay(mockJobSoftwareDao); JobDraftresourcecategory jobDraftresourcecategory= new JobDraftresourcecategory(); jobDraftresourcecategory.setResourcecategoryId(new Integer(123)); List <JobDraftresourcecategory> jobDraftresourcecategoryList = new ArrayList <JobDraftresourcecategory>(); jobDraftresourcecategoryList.add(jobDraftresourcecategory); jobDraft.setJobDraftresourcecategory(jobDraftresourcecategoryList); JobResourcecategory jobResourceCategory = new JobResourcecategory(); jobResourceCategory.setJobId(job.getJobId()); jobResourceCategory.setResourcecategoryId(jobDraftresourcecategory.getResourcecategoryId()); expect(mockJobResourcecategoryDao.save(EasyMock.isA(JobResourcecategory.class))).andReturn(jobResourceCategory); replay(mockJobResourcecategoryDao); Role role = new Role(); role.setRoleId(new Integer(1)); expect(mockRoleDao.getRoleByRoleName("js")).andReturn(role); replay(mockRoleDao); JobUser jobUser = new JobUser(); jobUser.setUserId(user.getUserId()); jobUser.setJobId(job.getJobId()); jobUser.setRoleId(role.getRoleId()); expect(mockJobUserDao.save(EasyMock.isA(JobUser.class))).andReturn(jobUser); replay(mockJobUserDao); Lab lab = new Lab(); lab.setLabId(new Integer(1)); lab.setPrimaryUserId(new Integer(job.getUserId())); expect(mockLabDao.getLabByLabId(job.getLabId())).andReturn(lab); replay(mockLabDao); JobDraftCellSelection jdc = new JobDraftCellSelection(); jdc.setCellIndex(new Integer(1)); jdc.setJobDraftCellSelectionId(1); List <JobDraftCellSelection> jdcList = new ArrayList <JobDraftCellSelection>(); jdcList.add(jdc); jobDraft.setJobDraftCellSelection(jdcList); JobCellSelection jobCellSelection = new JobCellSelection(); jobCellSelection.setJobId(job.getJobId()); jobCellSelection.setCellIndex(jdc.getCellIndex()); jobCellSelection.setJobCellSelectionId(1); Map<Integer,JobCellSelection> jobDraftCellMap = new HashMap<Integer,JobCellSelection>(); jobDraftCellMap.put(jdc.getJobDraftCellSelectionId(), jobCellSelection); expect(mockJobCellSelectionDao.save(EasyMock.isA(JobCellSelection.class))).andReturn(jobCellSelection); replay(mockJobCellSelectionDao); SampleDraftJobDraftCellSelection sdjdc = new SampleDraftJobDraftCellSelection(); sdjdc.setJobDraftCellSelectionId(1); sdjdc.setLibraryIndex(1); List <SampleDraftJobDraftCellSelection> sdjdcList = new ArrayList <SampleDraftJobDraftCellSelection>(); sdjdcList.add(sdjdc); SampleDraft sd = new SampleDraft(); sd.setName("sample draft"); sd.setSampleTypeId(1); sd.setSampleSubtypeId(1); sd.setSampleDraftJobDraftCellSelection(sdjdcList); sd.setSampleDraftId(new Integer(1)); Sample sample = new Sample(); sample.setSampleId(1); sample.setName(sd.getName()); sample.setSampleTypeId(sd.getSampleTypeId()); sample.setSampleSubtypeId(sd.getSampleSubtypeId()); sample.setSubmitterLabId(job.getLabId()); sample.setSubmitterUserId(user.getUserId()); sample.setSubmitterJobId(job.getJobId()); sample.setIsReceived(0); sample.setIsActive(1); expect(mockSampleDao.save(EasyMock.isA(Sample.class))).andReturn(sample); replay(mockSampleDao); SampleDraftMeta sdm = new SampleDraftMeta(); sdm.setK("genericBiomolecule.organism"); sdm.setV("9606"); sdm.setPosition(1); SampleMeta sampleMeta = new SampleMeta(); sampleMeta.setK(sdm.getK()); sampleMeta.setV(sdm.getV()); sampleMeta.setPosition(sdm.getPosition()); List <SampleDraftMeta> sdMetaList = new ArrayList <SampleDraftMeta>(); sdMetaList.add(sdm); sd.setSourceSampleId(new Integer(1)); sd.setSampleDraftMeta(sdMetaList); List <SampleDraft> sdList = new ArrayList <SampleDraft>(); sdList.add(sd); jobDraft.setSampleDraft(sdList); expect(mockSampleMetaDao.save(EasyMock.isA(SampleMeta.class))).andReturn(sampleMeta); replay(mockSampleMetaDao); JobSample jobSample = new JobSample(); jobSample.setJobId(job.getJobId()); jobSample.setSampleId(sample.getSampleId()); expect(mockJobSampleDao.save(EasyMock.isA(JobSample.class))).andReturn(jobSample); replay(mockJobSampleDao); SampleJobCellSelection sampleJobCellSelection = new SampleJobCellSelection(); sampleJobCellSelection.setSampleId(sample.getSampleId()); sampleJobCellSelection.setJobCellSelectionId(jobDraftCellMap.get(sdjdc.getJobDraftCellSelectionId()).getJobCellSelectionId()); sampleJobCellSelection.setLibraryIndex(sdjdc.getLibraryIndex()); expect(mockSampleJobCellSelectionDao.save(EasyMock.isA(SampleJobCellSelection.class))).andReturn(sampleJobCellSelection); replay(mockSampleJobCellSelectionDao); AcctGrant grant = new AcctGrant(); expect(mockAccountsService.getGrantForJobDraft(EasyMock.isA(JobDraft.class))).andReturn(grant); expect(mockAccountsService.saveJobGrant(job, grant)).andReturn(null); replay(mockAccountsService); jobDraft.setStatus("SUBMITTED"); jobDraft.setSubmittedjobId(job.getJobId()); expect(mockJobDraftDao.save(EasyMock.isA(JobDraft.class))).andReturn(jobDraft); replay(mockJobDraftDao); try { mockJobServiceImpl.initiateBatchJobForJobSubmission(job); } catch (WaspMessageBuildingException e1) { e1.printStackTrace(); } EasyMock.expectLastCall(); SampleType sampleType = new SampleType(); sampleType.setIName("library"); expect(mockSampleTypeDao.getSampleTypeBySampleTypeId(1)).andReturn(sampleType); replay(mockSampleTypeDao); mockJobServiceImpl.setSampleService(mockSampleService); mockSampleService.initiateBatchJobForSample(job, sample, "wasp.userLibrary.jobflow.v1"); EasyMock.expectLastCall(); try { Assert.assertEquals(mockJobServiceImpl.createJobFromJobDraft(jobDraft, user), job); } catch (FileMoveException e) { e.printStackTrace(); } EasyMockUnitils.verify(); }