Search in sources :

Example 1 with Notification

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);
}
Also used : Notification(org.hisp.dhis.system.notification.Notification) Test(org.junit.jupiter.api.Test)

Example 2 with Notification

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);
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId) TaskCategory(org.hisp.dhis.scheduling.TaskCategory) ArrayList(java.util.ArrayList) Notification(org.hisp.dhis.system.notification.Notification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Notification (org.hisp.dhis.system.notification.Notification)2 ArrayList (java.util.ArrayList)1 TaskCategory (org.hisp.dhis.scheduling.TaskCategory)1 TaskId (org.hisp.dhis.scheduling.TaskId)1 Test (org.junit.jupiter.api.Test)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1