use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class ReadAnalysisSubmissionPermissionTest method testRejectPermission.
/**
* Tests rejecting permission for a user to read an analysis submission by
* the submission id.
*/
@Test
public void testRejectPermission() {
String username = "aaron";
User u = new User();
u.setUsername(username);
Authentication auth = new UsernamePasswordAuthenticationToken("aaron", "password1");
AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(workflowId).name("test").inputFiles(inputSingleFiles).referenceFile(referenceFile).build();
analysisSubmission.setSubmitter(new User());
when(userRepository.loadUserByUsername(username)).thenReturn(u);
when(analysisSubmissionRepository.findOne(1L)).thenReturn(analysisSubmission);
assertFalse("permission was not granted.", readAnalysisSubmissionPermission.isAllowed(auth, 1L));
verify(userRepository).loadUserByUsername(username);
verify(analysisSubmissionRepository).findOne(1L);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class ReadAnalysisSubmissionPermissionTest method testPermitAutoAssembly.
@Test
public void testPermitAutoAssembly() {
String username = "aaron";
User u = new User();
u.setUsername(username);
Authentication auth = new UsernamePasswordAuthenticationToken("aaron", "password1");
Project p = new Project();
SequenceFilePair pair = new SequenceFilePair();
AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(workflowId).name("test").inputFiles(ImmutableSet.of(pair)).referenceFile(referenceFile).build();
analysisSubmission.setSubmitter(new User());
pair.setAutomatedAssembly(analysisSubmission);
/*
* testing that analysis is shared with a project that user isn't a part
* of
*/
when(pasRepository.getProjectsForSubmission(analysisSubmission)).thenReturn(ImmutableList.of(new ProjectAnalysisSubmissionJoin(p, analysisSubmission)));
when(readProjectPermission.customPermissionAllowed(auth, p)).thenReturn(false);
when(userRepository.loadUserByUsername(username)).thenReturn(u);
when(analysisSubmissionRepository.findOne(1L)).thenReturn(analysisSubmission);
when(seqObjectPermission.customPermissionAllowed(auth, pair)).thenReturn(true);
when(sequencingObjectRepository.findSequencingObjectsForAnalysisSubmission(analysisSubmission)).thenReturn(ImmutableSet.of(pair));
assertTrue("permission should be granted.", readAnalysisSubmissionPermission.isAllowed(auth, 1L));
verify(userRepository).loadUserByUsername(username);
verify(analysisSubmissionRepository).findOne(1L);
verify(seqObjectPermission).customPermissionAllowed(auth, pair);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class ReadAnalysisSubmissionPermissionTest method testGrantPermissionWithDomainObject.
/**
* Tests granting permission for a user to read an analysis submission by
* the submission object.
*/
@Test
public void testGrantPermissionWithDomainObject() {
String username = "aaron";
User u = new User();
u.setUsername(username);
Authentication auth = new UsernamePasswordAuthenticationToken("aaron", "password1");
AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(workflowId).name("test").inputFiles(inputSingleFiles).referenceFile(referenceFile).build();
analysisSubmission.setSubmitter(u);
when(userRepository.loadUserByUsername(username)).thenReturn(u);
when(analysisSubmissionRepository.findOne(1L)).thenReturn(analysisSubmission);
assertTrue("permission was not granted.", readAnalysisSubmissionPermission.isAllowed(auth, analysisSubmission));
verify(userRepository).loadUserByUsername(username);
verifyZeroInteractions(analysisSubmissionRepository);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class DatabaseSetupGalaxyITService method setupPairSubmissionInDatabase.
/**
* Sets up an {@link AnalysisSubmission} with a list of paired sequence
* files and saves all dependencies in database.
*
* @param sampleId
* The id of the sample to associate with the given sequence
* file.
* @param sequenceFilePaths1
* A list of paths for the first part of the pair.
* @param sequenceFilePaths2
* A list of paths for the second part of the pair. The path to
* an input sequence file for this test.
* @param iridaWorkflowId
* The id of an irida workflow.
* @return An {@link AnalysisSubmission} which has been saved to the
* database.
*/
public AnalysisSubmission setupPairSubmissionInDatabase(long sampleId, List<Path> sequenceFilePaths1, List<Path> sequenceFilePaths2, UUID iridaWorkflowId) {
List<SequenceFilePair> sequenceFilePairs = setupSampleSequenceFileInDatabase(sampleId, sequenceFilePaths1, sequenceFilePaths2);
AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("paired analysis").inputFiles(Sets.newHashSet(sequenceFilePairs)).build();
analysisSubmissionService.create(submission);
return analysisSubmissionRepository.findOne(submission.getId());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class DatabaseSetupGalaxyITService method setupSubmissionInDatabase.
/**
* Sets up an AnalysisSubmission and saves all dependencies in database.
*
* @param sampleId
* The id of the sample to associate with the given sequence
* file.
* @param sequenceFileSet
* A set of sequence files to use for this submission.
* @param referenceFilePath
* The path to an input reference file for this test.
* @param iridaWorkflowId
* The id of an irida workflow.
* @return An AnalysisSubmissionPhylogenomics which has been saved to the
* database.
*/
public AnalysisSubmission setupSubmissionInDatabase(long sampleId, Set<SequencingObject> sequenceFileSet, Path referenceFilePath, UUID iridaWorkflowId) {
ReferenceFile referenceFile = referenceFileRepository.save(new ReferenceFile(referenceFilePath));
AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("my analysis").inputFiles(sequenceFileSet).referenceFile(referenceFile).build();
analysisSubmissionService.create(submission);
return analysisSubmissionRepository.findOne(submission.getId());
}
Aggregations