use of ca.corefacility.bioinformatics.irida.model.announcements.Announcement in project irida by phac-nml.
the class AnnouncementServiceImplIT method testUpdateAnnouncementAsAdminSuccess.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testUpdateAnnouncementAsAdminSuccess() {
Announcement announcement = announcementService.read(1L);
final String newMessage = "A new message";
announcement.setMessage(newMessage);
announcement = announcementService.update(announcement);
assertEquals("Message content doesn't match", newMessage, announcement.getMessage());
}
use of ca.corefacility.bioinformatics.irida.model.announcements.Announcement in project irida by phac-nml.
the class AnnouncementServiceImplIT method testSearchReturnsExistingAnnouncement.
@Test
@WithMockUser(username = "user", roles = "USER")
public void testSearchReturnsExistingAnnouncement() {
String searchString = "Downtime";
Page<Announcement> searchAnnouncement = announcementService.search(AnnouncementSpecification.searchAnnouncement(searchString), new PageRequest(0, 10, new Sort(Sort.Direction.ASC, "id")));
assertEquals("Unexpected number of announcements returned", 2, searchAnnouncement.getContent().size());
for (Announcement a : searchAnnouncement) {
assertTrue(a.getMessage().contains(searchString));
}
}
use of ca.corefacility.bioinformatics.irida.model.announcements.Announcement in project irida by phac-nml.
the class AnnouncementServiceImplIT method testUserMarkAnnouncementAsReadSuccess.
@Test
@WithMockUser(username = "user3", roles = "USER")
public void testUserMarkAnnouncementAsReadSuccess() {
final Announcement a = announcementService.read(2L);
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
final User user = userService.getUserByUsername(auth.getName());
try {
announcementService.markAnnouncementAsReadByUser(a, user);
} catch (AccessDeniedException e) {
fail("User should be able able to mark announcement as read.");
} catch (EntityExistsException e) {
fail("Failed for unknown reason, stack trace follows:");
e.printStackTrace();
}
}
use of ca.corefacility.bioinformatics.irida.model.announcements.Announcement in project irida by phac-nml.
the class AnnouncementServiceImplIT method testSearchNullSearchString.
@Test
@WithMockUser(username = "user", roles = "USER")
public void testSearchNullSearchString() {
Page<Announcement> searchAnnouncement = announcementService.search(AnnouncementSpecification.searchAnnouncement(null), new PageRequest(0, 10, new Sort(Sort.Direction.ASC, "id")));
assertEquals("Unexpected number of announcements returned", 0, searchAnnouncement.getContent().size());
}
use of ca.corefacility.bioinformatics.irida.model.announcements.Announcement in project irida by phac-nml.
the class AnnouncementServiceImplIT method testCreateAnnouncementNotAdmin.
@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "user", roles = "USER")
public void testCreateAnnouncementNotAdmin() {
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
final User user = userService.getUserByUsername(auth.getName());
announcementService.create(new Announcement("This is a message", user));
}
Aggregations