Search in sources :

Example 86 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectEventHandlerTest method testDelegateUserRemoved.

@Test
public void testDelegateUserRemoved() {
    Class<? extends ProjectEvent> clazz = UserRemovedProjectEvent.class;
    Project project = new Project();
    User user = new User();
    Object[] args = { project, user };
    MethodEvent methodEvent = new MethodEvent(clazz, null, args);
    when(eventRepository.save(any(ProjectEvent.class))).thenReturn(new UserRemovedProjectEvent(project, user));
    handler.delegate(methodEvent);
    ArgumentCaptor<ProjectEvent> captor = ArgumentCaptor.forClass(ProjectEvent.class);
    verify(eventRepository).save(captor.capture());
    ProjectEvent event = captor.getValue();
    assertTrue(event instanceof UserRemovedProjectEvent);
    verify(projectRepository).save(any(Project.class));
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) User(ca.corefacility.bioinformatics.irida.model.user.User) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) DataAddedToSampleProjectEvent(ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) Test(org.junit.Test)

Example 87 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectEventHandlerTest method testOtherEvent.

@Test
public void testOtherEvent() {
    Class<? extends ProjectEvent> clazz = ProjectEvent.class;
    Project project = new Project();
    User user = new User();
    Object[] args = { project, user };
    MethodEvent methodEvent = new MethodEvent(clazz, null, args);
    handler.delegate(methodEvent);
    verifyZeroInteractions(eventRepository);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) User(ca.corefacility.bioinformatics.irida.model.user.User) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) DataAddedToSampleProjectEvent(ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) Test(org.junit.Test)

Example 88 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectTest method testNullProjectName.

@Test
public void testNullProjectName() {
    Project p = new Project();
    p.setName(null);
    Set<ConstraintViolation<Project>> violations = validator.validate(p);
    assertEquals("Wrong number of violations.", 2, violations.size());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 89 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectTest method testEmptyProjectName.

@Test
public void testEmptyProjectName() {
    Project p = new Project();
    p.setName("");
    Set<ConstraintViolation<Project>> violations = validator.validate(p);
    assertEquals("Wrong number of violations.", 1, violations.size());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 90 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectServiceImplIT method testShareSamplesWithOwner.

@Test
@WithMockUser(username = "user1", roles = "USER")
public void testShareSamplesWithOwner() {
    Project source = projectService.read(2L);
    Project destination = projectService.read(10L);
    Sample sample1 = sampleService.read(1L);
    Set<Sample> samples = Sets.newHashSet(sample1);
    List<ProjectSampleJoin> copiedSamples = projectService.shareSamples(source, destination, samples, true);
    assertEquals(samples.size(), copiedSamples.size());
    copiedSamples.forEach(j -> {
        assertTrue("Project should be owner for sample", j.isOwner());
    });
    assertNotNull("Samples should still exist in source project", projectSampleJoinRepository.readSampleForProject(source, sample1));
    assertNotNull("Sample should exist in destination project", projectSampleJoinRepository.readSampleForProject(destination, sample1));
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

Project (ca.corefacility.bioinformatics.irida.model.project.Project)331 Test (org.junit.Test)190 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)120 User (ca.corefacility.bioinformatics.irida.model.user.User)88 WithMockUser (org.springframework.security.test.context.support.WithMockUser)80 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)71 Join (ca.corefacility.bioinformatics.irida.model.joins.Join)62 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)51 RelatedProjectJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin)37 ArrayList (java.util.ArrayList)34 ProjectUserJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin)30 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)30 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)27 ProjectRole (ca.corefacility.bioinformatics.irida.model.enums.ProjectRole)25 ReferenceFile (ca.corefacility.bioinformatics.irida.model.project.ReferenceFile)23 ProjectEvent (ca.corefacility.bioinformatics.irida.model.event.ProjectEvent)22 ProjectAnalysisSubmissionJoin (ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin)22 List (java.util.List)22 UserRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent)21 ImmutableMap (com.google.common.collect.ImmutableMap)21