Search in sources :

Example 1 with SampleAddedProjectEvent

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

the class ProjectEventHandlerTest method testDelegateSampleAdded.

@Test
public void testDelegateSampleAdded() {
    Class<? extends ProjectEvent> clazz = SampleAddedProjectEvent.class;
    Project project = new Project();
    Sample sample = new Sample();
    ProjectSampleJoin returnValue = new ProjectSampleJoin(project, sample, true);
    Object[] args = { project, sample };
    MethodEvent methodEvent = new MethodEvent(clazz, returnValue, args);
    when(eventRepository.save(any(ProjectEvent.class))).thenReturn(new SampleAddedProjectEvent(returnValue));
    handler.delegate(methodEvent);
    ArgumentCaptor<ProjectEvent> captor = ArgumentCaptor.forClass(ProjectEvent.class);
    verify(eventRepository).save(captor.capture());
    ProjectEvent event = captor.getValue();
    assertTrue(event instanceof SampleAddedProjectEvent);
    verify(projectRepository).save(any(Project.class));
}
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) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) 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 2 with SampleAddedProjectEvent

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

the class ProjectEventServiceImplIT method testAddProjectSample.

@WithMockUser(username = "tom", password = "password1", roles = "ADMIN")
@Test
public void testAddProjectSample() {
    Project project = projectService.read(1L);
    Sample sample = sampleService.read(2L);
    projectService.addSampleToProject(project, sample, true);
    Page<ProjectEvent> eventsForProject = projectEventService.getEventsForProject(project, new PageRequest(0, 10));
    assertEquals(1, eventsForProject.getTotalElements());
    ProjectEvent event = eventsForProject.iterator().next();
    assertTrue(event instanceof SampleAddedProjectEvent);
    SampleAddedProjectEvent userEvent = (SampleAddedProjectEvent) event;
    assertEquals(project, userEvent.getProject());
    assertEquals(sample, userEvent.getSample());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) PageRequest(org.springframework.data.domain.PageRequest) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

ProjectEvent (ca.corefacility.bioinformatics.irida.model.event.ProjectEvent)2 SampleAddedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent)2 UserRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent)2 UserRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent)2 Project (ca.corefacility.bioinformatics.irida.model.project.Project)2 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)2 Test (org.junit.Test)2 DataAddedToSampleProjectEvent (ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent)1 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)1 PageRequest (org.springframework.data.domain.PageRequest)1 WithMockUser (org.springframework.security.test.context.support.WithMockUser)1