use of org.hisp.dhis.system.notification.Notification in project dhis2-core by dhis2.
the class TrackerImportControllerTest method verifyShouldFindJob.
@Test
void verifyShouldFindJob() throws Exception {
String uid = CodeGenerator.generateUid();
// When
when(notifier.getNotificationsByJobId(JobType.TRACKER_IMPORT_JOB, uid)).thenReturn(new LinkedList<>(singletonList(new Notification())));
// Then
mockMvc.perform(get(ENDPOINT + "/jobs/" + uid).content("{}").contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(jsonPath("$.message").doesNotExist()).andExpect(jsonPath("$").isArray()).andExpect(jsonPath("$", hasSize(1))).andExpect(jsonPath("$.[0].uid").isNotEmpty()).andExpect(content().contentType("application/json")).andReturn().getResponse().getContentAsString();
verify(notifier).getNotificationsByJobId(JobType.TRACKER_IMPORT_JOB, uid);
}
use of org.hisp.dhis.system.notification.Notification in project dhis2-core by dhis2.
the class SystemController method getTaskJson.
@RequestMapping(value = "/tasks/{category}", method = RequestMethod.GET, produces = { "*/*", "application/json" })
public void getTaskJson(@PathVariable("category") String category, @RequestParam(required = false) String lastId, HttpServletResponse response) throws IOException {
List<Notification> notifications = new ArrayList<>();
if (category != null) {
TaskCategory taskCategory = TaskCategory.valueOf(category.toUpperCase());
TaskId taskId = new TaskId(taskCategory, currentUserService.getCurrentUser());
notifications = notifier.getNotifications(taskId, lastId);
}
renderService.toJson(response.getOutputStream(), notifications);
}
Aggregations