use of ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles in project irida by phac-nml.
the class ExportUploadServiceTest method testGetResultsSubmitted.
@SuppressWarnings("unchecked")
@Test
public void testGetResultsSubmitted() throws IOException, UploadException {
NcbiExportSubmissionService exportSubmissionService = mock(NcbiExportSubmissionService.class);
NcbiBioSampleFiles sample2 = new NcbiBioSampleFiles();
sample2.setId("NMLTEST2");
NcbiBioSampleFiles sample3 = new NcbiBioSampleFiles();
sample3.setId("NMLTEST3");
NcbiExportSubmission submission = new NcbiExportSubmission();
submission.setBioSampleFiles(Lists.newArrayList(sample2, sample3));
submission.setDirectoryPath("submit/Test/example");
when(exportSubmissionService.getSubmissionsWithState(any(Set.class))).thenReturn(Lists.newArrayList(submission));
String report = "<?xml version='1.0' encoding='utf-8'?>\n" + "<SubmissionStatus submission_id=\"SUB189884\" status=\"processing\">\n" + " <Action action_id=\"SUB189884-nmltest2\" target_db=\"SRA\" status=\"processing\">\n" + " <Response status=\"processing\"/>\n" + " </Action>\n" + " <Action action_id=\"SUB189884-nmltest3\" target_db=\"SRA\" status=\"submitted\"/>\n" + "</SubmissionStatus>\n";
String ftpHost = "localhost";
String ftpUser = "test";
String ftpPassword = "password";
String baseDirectory = "/home/test/submit/Test";
String submissionDirectory = baseDirectory + "/example";
String reportFile = submissionDirectory + "/report.2.xml";
FakeFtpServer server = new FakeFtpServer();
server.addUserAccount(new UserAccount(ftpUser, ftpPassword, "/home/test"));
FileSystem fileSystem = new UnixFakeFileSystem();
fileSystem.add(new DirectoryEntry(submissionDirectory));
fileSystem.add(new FileEntry(reportFile, report));
server.setFileSystem(fileSystem);
// finds an open port
server.setServerControlPort(0);
ExportUploadService exportUploadService = new ExportUploadService(exportSubmissionService, null, new TestEmailController());
try {
server.start();
int ftpPort = server.getServerControlPort();
exportUploadService.setConnectionDetails(ftpHost, ftpPort, ftpUser, ftpPassword, baseDirectory);
exportUploadService.updateRunningUploads();
} finally {
server.stop();
}
assertEquals("sample2 should have processing state", ExportUploadState.PROCESSING, sample2.getSubmissionStatus());
assertEquals("sample3 should have processing state", ExportUploadState.SUBMITTED, sample3.getSubmissionStatus());
}
use of ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles in project irida by phac-nml.
the class ExportUploadServiceTest method testGetResultsWithAccession.
@SuppressWarnings("unchecked")
@Test
public void testGetResultsWithAccession() throws IOException, UploadException {
NcbiExportSubmissionService exportSubmissionService = mock(NcbiExportSubmissionService.class);
NcbiBioSampleFiles sample2 = new NcbiBioSampleFiles();
sample2.setId("NMLTEST2");
NcbiExportSubmission submission = new NcbiExportSubmission();
submission.setBioSampleFiles(Lists.newArrayList(sample2));
submission.setDirectoryPath("submit/Test/example");
String newAccession = "SRR12345";
when(exportSubmissionService.getSubmissionsWithState(any(Set.class))).thenReturn(Lists.newArrayList(submission));
String report = "<?xml version='1.0' encoding='utf-8'?>\n" + "<SubmissionStatus submission_id=\"SUB11245\" status=\"processed-ok\">\n" + " <Action action_id=\"SUB11245-nmltest2\" target_db=\"SRA\" status=\"processed-ok\" notify_submitter=\"true\">\n" + " <Response status=\"processed-ok\">\n" + " <Object target_db=\"SRA\" object_id=\"RUN:3119494\" spuid_namespace=\"NML\" spuid=\"nmltest2\" accession=\"" + newAccession + "\" status=\"updated\">\n" + " <Meta>\n" + " <SRAStudy>SRP12345</SRAStudy>\n" + " </Meta>\n" + " </Object>\n" + " </Response>\n" + " </Action>\n" + "</SubmissionStatus>";
String ftpHost = "localhost";
String ftpUser = "test";
String ftpPassword = "password";
String baseDirectory = "/home/test/submit/Test";
String submissionDirectory = baseDirectory + "/example";
String reportFile = submissionDirectory + "/report.2.xml";
FakeFtpServer server = new FakeFtpServer();
server.addUserAccount(new UserAccount(ftpUser, ftpPassword, "/home/test"));
FileSystem fileSystem = new UnixFakeFileSystem();
fileSystem.add(new DirectoryEntry(submissionDirectory));
fileSystem.add(new FileEntry(reportFile, report));
server.setFileSystem(fileSystem);
// finds an open port
server.setServerControlPort(0);
ExportUploadService exportUploadService = new ExportUploadService(exportSubmissionService, null, new TestEmailController());
try {
server.start();
int ftpPort = server.getServerControlPort();
exportUploadService.setConnectionDetails(ftpHost, ftpPort, ftpUser, ftpPassword, baseDirectory);
exportUploadService.updateRunningUploads();
} finally {
server.stop();
}
assertEquals("sample2 should have processing state", ExportUploadState.PROCESSED_OK, sample2.getSubmissionStatus());
assertEquals("sample2 should have an accession", newAccession, sample2.getAccession());
}
use of ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles in project irida by phac-nml.
the class ExportUploadServiceTest method createFakeSubmission.
/**
* Create a fake submission for test uploads
*
* @return a {@link NcbiExportSubmission}
* @throws IOException
* if the test file couldn't be created
*/
private NcbiExportSubmission createFakeSubmission() throws IOException {
NcbiExportSubmission submission = new NcbiExportSubmission();
submission.setId(1L);
NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles();
Path tempFile = Files.createTempFile("sequencefile", ".fastq");
SequenceFile sequenceFile = new SequenceFile(tempFile);
sequenceFile.setId(1L);
SingleEndSequenceFile singleFile = new SingleEndSequenceFile(sequenceFile);
singleFile.setId(1L);
ncbiBioSampleFiles.setFiles(Lists.newArrayList(singleFile));
submission.setBioSampleFiles(Lists.newArrayList(ncbiBioSampleFiles));
return submission;
}
use of ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles in project irida by phac-nml.
the class NcbiExportSubmissionServceTest method testCreateNoFiles.
@Test(expected = IllegalArgumentException.class)
public void testCreateNoFiles() {
NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles("sample", Lists.newArrayList(), Lists.newArrayList(), null, "library_name", null, null, null, "library_construction_protocol", "namespace");
NcbiExportSubmission submission = new NcbiExportSubmission(null, null, "bioProjectId", "organization", "ncbiNamespace", new Date(), Lists.newArrayList(ncbiBioSampleFiles));
service.create(submission);
}
use of ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles in project irida by phac-nml.
the class NcbiExportSubmissionServceTest method testCreatePairs.
@Test
public void testCreatePairs() {
SequenceFile sequenceFile = new SequenceFile();
NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles("sample", Lists.newArrayList(), Lists.newArrayList(new SequenceFilePair(sequenceFile, sequenceFile)), null, "library_name", null, null, null, "library_construction_protocol", "namespace");
NcbiExportSubmission submission = new NcbiExportSubmission(null, null, "bioProjectId", "organization", "ncbiNamespace", new Date(), Lists.newArrayList(ncbiBioSampleFiles));
service.create(submission);
verify(repository).save(submission);
}
Aggregations