Search in sources :

Example 1 with Incidents

use of org.opencastproject.serviceregistry.api.Incidents in project opencast by opencast.

the class OsgiIncidentServiceTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    final EntityManagerFactory emf = PersistenceUtil.newTestEntityManagerFactory(AbstractIncidentService.PERSISTENCE_UNIT_NAME);
    penv = PersistenceEnvs.persistenceEnvironment(emf);
    // Mock up a job
    Job job = createNiceMock(Job.class);
    expect(job.getProcessingHost()).andStubReturn(PROCESSING_HOST);
    expect(job.getJobType()).andStubReturn(JOB_TYPE);
    expect(job.getCreator()).andStubReturn("creator");
    expect(job.getOrganization()).andStubReturn("organization");
    replay(job);
    // Mock up a service registry
    final ServiceRegistry serviceRegistry = createNiceMock(ServiceRegistry.class);
    expect(serviceRegistry.getJob(EasyMock.anyLong())).andAnswer(new IAnswer<Job>() {

        @Override
        public Job answer() throws Throwable {
            final Long jobId = (Long) EasyMock.getCurrentArguments()[0];
            return jobs.get(jobId);
        }
    }).anyTimes();
    replay(serviceRegistry);
    // Mock up a workflow service
    final WorkflowService workflowService = createNiceMock(WorkflowService.class);
    replay(workflowService);
    incidentService = new AbstractIncidentService() {

        @Override
        protected ServiceRegistry getServiceRegistry() {
            return serviceRegistry;
        }

        @Override
        protected WorkflowService getWorkflowService() {
            return workflowService;
        }

        @Override
        protected PersistenceEnv getPenv() {
            return PersistenceEnvs.persistenceEnvironment(emf);
        }
    };
    incidents = new Incidents(serviceRegistry, incidentService);
}
Also used : IAnswer(org.easymock.IAnswer) PersistenceEnv(org.opencastproject.util.persistence.PersistenceEnv) WorkflowService(org.opencastproject.workflow.api.WorkflowService) EntityManagerFactory(javax.persistence.EntityManagerFactory) Incidents(org.opencastproject.serviceregistry.api.Incidents) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) Before(org.junit.Before)

Example 2 with Incidents

use of org.opencastproject.serviceregistry.api.Incidents in project opencast by opencast.

the class ServiceRegistryJpaImpl method setIncidentService.

/**
 * OSGi DI.
 */
public void setIncidentService(IncidentService incidentService) {
    // Manually resolve the cyclic dependency between the incident service and the service registry
    ((OsgiIncidentService) incidentService).setServiceRegistry(this);
    this.incidents = new Incidents(this, incidentService);
}
Also used : Incidents(org.opencastproject.serviceregistry.api.Incidents)

Aggregations

Incidents (org.opencastproject.serviceregistry.api.Incidents)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 IAnswer (org.easymock.IAnswer)1 Before (org.junit.Before)1 Job (org.opencastproject.job.api.Job)1 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)1 PersistenceEnv (org.opencastproject.util.persistence.PersistenceEnv)1 WorkflowService (org.opencastproject.workflow.api.WorkflowService)1