use of ca.corefacility.bioinformatics.irida.model.project.ProjectReferenceFileJoin in project irida by phac-nml.
the class ProjectServiceImplTest method testAddReferenceFileToProject.
@Test
public void testAddReferenceFileToProject() throws IOException {
Project p = new Project();
Path createTempFile = Files.createTempFile(null, null);
ReferenceFile f = new ReferenceFile(createTempFile);
when(referenceFileRepository.save(f)).thenReturn(f);
projectService.addReferenceFileToProject(p, f);
verify(referenceFileRepository).save(f);
verify(prfjRepository).save(new ProjectReferenceFileJoin(p, f));
}
use of ca.corefacility.bioinformatics.irida.model.project.ProjectReferenceFileJoin in project irida by phac-nml.
the class ProjectServiceImpl method addReferenceFileToProject.
/**
* {@inheritDoc}
*/
@Override
@Transactional
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#project, 'isProjectOwner')")
public Join<Project, ReferenceFile> addReferenceFileToProject(Project project, ReferenceFile referenceFile) {
referenceFile = referenceFileRepository.save(referenceFile);
ProjectReferenceFileJoin j = new ProjectReferenceFileJoin(project, referenceFile);
return prfjRepository.save(j);
}
use of ca.corefacility.bioinformatics.irida.model.project.ProjectReferenceFileJoin in project irida by phac-nml.
the class ReferenceFileControllerTest method testCreateNewReferenceFile.
@Test
public void testCreateNewReferenceFile() throws IOException {
Path path = Paths.get(FILE_PATH);
byte[] origBytes = Files.readAllBytes(path);
List<MultipartFile> mockMultipartFiles = ImmutableList.of(new MockMultipartFile(FILE_NAME, FILE_NAME, "octet-stream", origBytes));
// TODO: (14-08-14 - Josh) look at Franklin's TestDataFactory
Project project = new Project("foo");
ReferenceFile referenceFile = new TestReferenceFile(path, 2L);
when(projectService.read(PROJECT_ID)).thenReturn(project);
when(projectService.addReferenceFileToProject(eq(project), any(ReferenceFile.class))).thenReturn(new ProjectReferenceFileJoin(project, referenceFile));
MockHttpServletResponse response = new MockHttpServletResponse();
controller.addReferenceFileToProject(PROJECT_ID, mockMultipartFiles, response, null);
verify(projectService).read(PROJECT_ID);
verify(projectService).addReferenceFileToProject(eq(project), any(ReferenceFile.class));
}
Aggregations