use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectServiceImplTest method testAddSampleToProjectNoSamplePersistedInvalidSample.
@Test(expected = ConstraintViolationException.class)
public void testAddSampleToProjectNoSamplePersistedInvalidSample() {
Project p = project();
Sample s = new Sample();
s.setSampleName("name");
Set<ConstraintViolation<Sample>> violations = new HashSet<>();
violations.add(ConstraintViolationImpl.forBeanValidation(null, null, Sample.class, null, null, null, null, null, null));
when(validator.validate(s)).thenReturn(violations);
projectService.addSampleToProject(p, s, true);
verifyZeroInteractions(sampleRepository, psjRepository);
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectServiceImplTest method testAddSampleToProjectNoSamplePersisted.
@Test
public void testAddSampleToProjectNoSamplePersisted() {
Project p = project();
Sample s = new Sample();
s.setSampleName("name");
Set<ConstraintViolation<Sample>> noViolations = new HashSet<>();
when(validator.validate(s)).thenReturn(noViolations);
when(sampleRepository.save(s)).thenReturn(s);
projectService.addSampleToProject(p, s, true);
verify(sampleRepository).save(s);
verify(psjRepository).save(new ProjectSampleJoin(p, s, true));
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectServiceImplTest method testUpdateProjectUserJoinIllegalChange.
@Test(expected = ProjectWithoutOwnerException.class)
public void testUpdateProjectUserJoinIllegalChange() throws ProjectWithoutOwnerException {
Project project = new Project("Project 1");
User user = new User();
ProjectRole projectRole = ProjectRole.PROJECT_USER;
ProjectUserJoin oldJoin = new ProjectUserJoin(project, user, ProjectRole.PROJECT_OWNER);
@SuppressWarnings("unchecked") List<Join<Project, User>> owners = Lists.newArrayList(new ProjectUserJoin(project, user, ProjectRole.PROJECT_OWNER));
when(pujRepository.getProjectJoinForUser(project, user)).thenReturn(oldJoin);
when(pujRepository.getUsersForProjectByRole(project, ProjectRole.PROJECT_OWNER)).thenReturn(owners);
projectService.updateUserProjectRole(project, user, projectRole);
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectServiceImplTest method testAddUserToProjectTwice.
@Test(expected = EntityExistsException.class)
public void testAddUserToProjectTwice() {
User u = new User("test", "test@nowhere.com", "PASSWOD!1", "Test", "User", "1234");
u.setId(new Long(1111));
Project p = project();
ProjectRole r = ProjectRole.PROJECT_USER;
ProjectUserJoin join = new ProjectUserJoin(p, u, r);
when(pujRepository.save(join)).thenThrow(new DataIntegrityViolationException("Duplicates."));
projectService.addUserToProject(p, u, r);
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectServiceImplTest method testRemoveSamplesFromProject.
@Test
public void testRemoveSamplesFromProject() {
Project project = new Project();
List<Sample> samples = ImmutableList.of(new Sample("s1"), new Sample("s2"));
ProjectSampleJoin psj0 = new ProjectSampleJoin(project, samples.get(0), true);
ProjectSampleJoin psj1 = new ProjectSampleJoin(project, samples.get(1), true);
when(psjRepository.readSampleForProject(project, samples.get(0))).thenReturn(psj0);
when(psjRepository.readSampleForProject(project, samples.get(1))).thenReturn(psj1);
projectService.removeSamplesFromProject(project, samples);
verify(psjRepository).delete(psj0);
verify(psjRepository).delete(psj1);
}
Aggregations