Search in sources :

Example 11 with Incident

use of org.opencastproject.job.api.Incident in project opencast by opencast.

the class AbstractIncidentService method getLocalization.

@Override
public IncidentL10n getLocalization(long id, Locale locale) throws IncidentServiceException, NotFoundException {
    final Incident incident = getIncident(id);
    final List<String> loc = localeToList(locale);
    // check if cache map is empty
    // fill cache from
    final String title = findText(loc, incident.getCode(), FIELD_TITLE).getOrElse(NO_TITLE);
    final String description = findText(loc, incident.getCode(), FIELD_DESCRIPTION).map(replaceVarsF(incident.getDescriptionParameters())).getOrElse(NO_DESCRIPTION);
    return new IncidentL10n() {

        @Override
        public String getTitle() {
            return title;
        }

        @Override
        public String getDescription() {
            return description;
        }
    };
}
Also used : Incident(org.opencastproject.job.api.Incident) IncidentL10n(org.opencastproject.serviceregistry.api.IncidentL10n)

Example 12 with Incident

use of org.opencastproject.job.api.Incident in project opencast by opencast.

the class OsgiIncidentServiceTest method testRetrieving.

@Test
public void testRetrieving() throws Exception {
    // manually create and store a job bypassing the service registry because the JPA implementation of the registry
    // is not very test friendly
    // Mock up a job
    Job job = createNiceMock(Job.class);
    expect(job.getId()).andStubReturn(1L);
    expect(job.getProcessingHost()).andStubReturn("localhost");
    expect(job.getJobType()).andStubReturn("org.opencastproject.service");
    expect(job.getCreator()).andStubReturn("creator");
    expect(job.getOrganization()).andStubReturn("organization");
    replay(job);
    jobs.put(job.getId(), job);
    incidents.record(job, Incident.Severity.FAILURE, 1511);
    // retrieve the job incident
    final List<Incident> incidents = incidentService.getIncidentsOfJob(Immutables.list(job.getId()));
    assertEquals(1, incidents.size());
    assertEquals(Incident.Severity.FAILURE, incidents.get(0).getSeverity());
    assertEquals("localhost", incidents.get(0).getProcessingHost());
    assertEquals("org.opencastproject.service", incidents.get(0).getServiceType());
    assertEquals("org.opencastproject.service.1511", incidents.get(0).getCode());
// todo more tests
}
Also used : Incident(org.opencastproject.job.api.Incident) Job(org.opencastproject.job.api.Job) Test(org.junit.Test)

Aggregations

Incident (org.opencastproject.job.api.Incident)12 IncidentTree (org.opencastproject.job.api.IncidentTree)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)4 Job (org.opencastproject.job.api.Job)4 IncidentServiceException (org.opencastproject.serviceregistry.api.IncidentServiceException)4 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)4 URI (java.net.URI)3 LinkedList (java.util.LinkedList)3 NotFoundException (org.opencastproject.util.NotFoundException)3 Tuple (org.opencastproject.util.data.Tuple)3 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 Before (org.junit.Before)2 IncidentTreeImpl (org.opencastproject.job.api.IncidentTreeImpl)2 JaxbIncident (org.opencastproject.job.api.JaxbIncident)2 MediaPackageBuilder (org.opencastproject.mediapackage.MediaPackageBuilder)2 RestQuery (org.opencastproject.util.doc.rest.RestQuery)2 WorkflowDefinitionImpl (org.opencastproject.workflow.api.WorkflowDefinitionImpl)2