use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventServiceImplIT method testGetEventsAfterDate.
@WithMockUser(username = "tom", password = "password1", roles = "ADMIN")
@Test
public void testGetEventsAfterDate() throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date beginning = formatter.parse("2013-07-18 14:00:00");
User user = userService.read(3L);
List<ProjectEvent> events = projectEventService.getEventsForUserAfterDate(user, beginning);
assertEquals("1 event should be returned", 1, events.size());
}
use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventServiceImplIT method testErrorThrownNoEvent.
@WithMockUser(username = "tom", password = "password1", roles = "ADMIN")
@Test
public void testErrorThrownNoEvent() {
Project project = projectService.read(1L);
Sample sample = sampleService.read(1L);
try {
projectService.addSampleToProject(project, sample, true);
fail("EntityExistsException should have been thrown");
} catch (EntityExistsException ex) {
// it's all good
}
Page<ProjectEvent> eventsForProject = projectEventService.getEventsForProject(project, new PageRequest(0, 10));
assertEquals("No event should be created", 0, eventsForProject.getTotalElements());
}
use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class EmailControllerImpl method buildEventsListFromCollection.
/**
* Convert the Page of events to the list expected in the model
*
* @param events
* Page of {@link ProjectEvent}s
* @return A List<Map<String,Object>> containing the events and fragment
* names
*/
private List<Map<String, Object>> buildEventsListFromCollection(Collection<ProjectEvent> events) {
List<Map<String, Object>> eventInfo = new ArrayList<>();
for (ProjectEvent e : events) {
if (FRAGMENT_NAMES.containsKey(e.getClass())) {
Map<String, Object> info = new HashMap<>();
info.put("name", FRAGMENT_NAMES.get(e.getClass()));
info.put("event", e);
eventInfo.add(info);
}
}
return eventInfo;
}
use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventHandlerTest method testHandleSequenceFileAddedEventMultipleProjects.
@SuppressWarnings("unchecked")
@Test
public void testHandleSequenceFileAddedEventMultipleProjects() {
Class<? extends ProjectEvent> clazz = DataAddedToSampleProjectEvent.class;
Project project = new Project("p1");
Project project2 = new Project("p2");
Sample sample = new Sample();
SequenceFile file = new SequenceFile();
SingleEndSequenceFile seqObj = new SingleEndSequenceFile(file);
SampleSequencingObjectJoin join = new SampleSequencingObjectJoin(sample, seqObj);
when(psjRepository.getProjectForSample(sample)).thenReturn(Lists.newArrayList(new ProjectSampleJoin(project, sample, true), new ProjectSampleJoin(project2, sample, true)));
when(eventRepository.save(any(ProjectEvent.class))).thenReturn(new DataAddedToSampleProjectEvent(project, sample));
Object[] args = {};
MethodEvent methodEvent = new MethodEvent(clazz, join, args);
handler.delegate(methodEvent);
ArgumentCaptor<ProjectEvent> captor = ArgumentCaptor.forClass(ProjectEvent.class);
verify(eventRepository, times(2)).save(captor.capture());
List<ProjectEvent> allValues = captor.getAllValues();
Set<Project> projects = Sets.newHashSet(project, project2);
for (ProjectEvent event : allValues) {
assertTrue(event instanceof DataAddedToSampleProjectEvent);
Project eventProject = event.getProject();
assertTrue(projects.contains(eventProject));
projects.remove(eventProject);
}
verify(projectRepository, times(2)).save(project);
}
use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventHandlerTest method testHandleSequenceFileAddedEventSingle.
@SuppressWarnings("unchecked")
@Test
public void testHandleSequenceFileAddedEventSingle() {
Class<? extends ProjectEvent> clazz = DataAddedToSampleProjectEvent.class;
Project project = new Project();
Sample sample = new Sample();
SequenceFile file = new SequenceFile();
SingleEndSequenceFile seqObj = new SingleEndSequenceFile(file);
SampleSequencingObjectJoin join = new SampleSequencingObjectJoin(sample, seqObj);
when(psjRepository.getProjectForSample(sample)).thenReturn(Lists.newArrayList(new ProjectSampleJoin(project, sample, true)));
when(eventRepository.save(any(ProjectEvent.class))).thenReturn(new DataAddedToSampleProjectEvent(project, sample));
Object[] args = {};
MethodEvent methodEvent = new MethodEvent(clazz, join, args);
handler.delegate(methodEvent);
ArgumentCaptor<ProjectEvent> captor = ArgumentCaptor.forClass(ProjectEvent.class);
verify(eventRepository).save(captor.capture());
ProjectEvent event = captor.getValue();
assertTrue(event instanceof DataAddedToSampleProjectEvent);
verify(projectRepository).save(any(Project.class));
verify(sampleRepository).save(any(Sample.class));
}
Aggregations