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));
}
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());
}
Aggregations