use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class SequencingRunServiceImplIT method testAddDetachedRunToSequenceFile.
/**
* This test simulates a bug that happens from the REST API when uploading
* sequence files to samples, where a new sequence file is created, then
* detached from a transaction.
*
* @throws IOException
* @throws InterruptedException
*/
@Test
@WithMockUser(username = "fbristow", password = "password1", roles = "ADMIN")
public void testAddDetachedRunToSequenceFile() throws IOException, InterruptedException {
final String SEQUENCE = "ACGTACGTN";
final byte[] FASTQ_FILE_CONTENTS = ("@testread\n" + SEQUENCE + "\n+\n?????????\n@testread2\n" + SEQUENCE + "\n+\n?????????").getBytes();
Path p = Files.createTempFile(null, null);
Files.write(p, FASTQ_FILE_CONTENTS);
SequenceFile sf = new SequenceFile();
sf.setFile(p);
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
Sample sample = sampleService.read(1L);
SequencingRun run = miseqRunService.read(2L);
objectService.createSequencingObjectInSample(so, sample);
miseqRunService.addSequencingObjectToSequencingRun(run, so);
AnalysisFastQC analysis = null;
do {
try {
analysis = analysisService.getFastQCAnalysisForSequenceFile(so, sf.getId());
} catch (final EntityNotFoundException e) {
logger.info("Fastqc still isn't finished, sleeping a bit.");
Thread.sleep(1000);
}
} while (analysis == null);
assertNotNull("FastQC analysis should have been created for sequence file.", analysis);
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class SampleServiceImplIT method testRemoveGenomeAssemblyFromSampleSuccess.
@Test
@WithMockUser(username = "fbristow", roles = "USER")
public void testRemoveGenomeAssemblyFromSampleSuccess() {
Sample s = sampleService.read(1L);
assertNotNull(sampleService.getGenomeAssemblyForSample(s, 1L));
sampleService.removeGenomeAssemblyFromSample(s, 1L);
try {
sampleService.getGenomeAssemblyForSample(s, 1L);
} catch (EntityNotFoundException e) {
return;
}
fail("Did not catch " + EntityNotFoundException.class);
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class RemoteAPIControllerTest method testReadNoToken.
@Test
public void testReadNoToken() {
Long apiId = 1L;
ExtendedModelMap model = new ExtendedModelMap();
RemoteAPI client = new RemoteAPI("name", "http://uri", "a description", "id", "secret");
when(remoteAPIService.read(apiId)).thenReturn(client);
when(tokenService.getToken(client)).thenThrow(new EntityNotFoundException("no token"));
remoteAPIController.read(apiId, model, locale);
verify(remoteAPIService).read(apiId);
verify(tokenService).getToken(client);
assertTrue(model.containsAttribute("remoteApi"));
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class PasswordResetControllerTest method testSubmitEmailNotExists.
@Test
public void testSubmitEmailNotExists() {
String email = "tom@nowhere.com";
ExtendedModelMap model = new ExtendedModelMap();
when(userService.loadUserByEmail(email)).thenThrow(new EntityNotFoundException("email doesn't exist"));
String submitEmail = controller.submitEmail(email, model);
assertEquals(PasswordResetController.CREATE_RESET_PAGE, submitEmail);
assertTrue(model.containsKey("email"));
assertTrue(model.containsKey("emailError"));
verify(userService).loadUserByEmail(email);
verifyZeroInteractions(emailController);
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class AnnouncementServiceImpl method markAnnouncementAsUnreadByUser.
/**
* {@inheritDoc}
*/
@Override
@Transactional
@PreAuthorize("hasAnyRole('ROLE_USER')")
public void markAnnouncementAsUnreadByUser(Announcement announcement, User user) throws EntityNotFoundException {
try {
final AnnouncementUserJoin join = announcementUserJoinRepository.getAnnouncementUserJoin(announcement, user);
Long id = join.getId();
announcementUserJoinRepository.delete(id);
} catch (NullPointerException e) {
throw new EntityNotFoundException("The user [" + user.getId() + "] has not yet read announcement [" + announcement.getId() + "]: cannot mark as unread.");
}
}
Aggregations