use of org.opencastproject.message.broker.api.MessageSender in project opencast by opencast.
the class WorkflowServiceSolrIndexTest method setUp.
@Before
public void setUp() throws Exception {
// security service
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(SecurityServiceStub.DEFAULT_ORG_ADMIN).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
OrganizationDirectoryService orgDirectroy = EasyMock.createNiceMock(OrganizationDirectoryService.class);
EasyMock.expect(orgDirectroy.getOrganization((String) EasyMock.anyObject())).andReturn(securityService.getOrganization()).anyTimes();
EasyMock.replay(orgDirectroy);
// Create a job with a workflow as its payload
List<Job> jobs = new ArrayList<>();
Job job = new JobImpl();
WorkflowInstanceImpl workflow = new WorkflowInstanceImpl();
workflow.setId(123);
workflow.setCreator(securityService.getUser());
workflow.setOrganization(securityService.getOrganization());
workflow.setState(WorkflowState.INSTANTIATED);
workflow.setMediaPackage(MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew());
String jobPayload = WorkflowParser.toXml(workflow);
job.setPayload(jobPayload);
job.setOrganization(securityService.getOrganization().getId());
jobs.add(job);
// Mock up the service registry to return the job
ServiceRegistry serviceRegistry = EasyMock.createMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.count(WorkflowService.JOB_TYPE, null)).andReturn(1L);
EasyMock.expect(serviceRegistry.getJobs(WorkflowService.JOB_TYPE, null)).andReturn(jobs);
EasyMock.expect(serviceRegistry.getJob(123)).andReturn(job);
EasyMock.expect(serviceRegistry.getJobPayloads("START_WORKFLOW")).andReturn(Collections.singletonList(jobPayload));
EasyMock.replay(serviceRegistry);
MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
EasyMock.replay(messageSender);
// Now create the dao
dao = new WorkflowServiceSolrIndex();
dao.solrRoot = PathSupport.concat("target", Long.toString(System.currentTimeMillis()));
dao.setServiceRegistry(serviceRegistry);
dao.setSecurityService(securityService);
dao.setOrgDirectory(orgDirectroy);
dao.activate("System Admin");
}
use of org.opencastproject.message.broker.api.MessageSender in project opencast by opencast.
the class WorkflowOperationSkippingTest method setUp.
@Before
public void setUp() throws Exception {
sRoot = new File(getStorageRoot());
try {
FileUtils.forceMkdir(sRoot);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
// create operation handlers for our workflows
succeedingOperationHandler = new SucceedingWorkflowOperationHandler(mediapackage1);
handlerRegistrations = new HashSet<HandlerRegistration>();
handlerRegistrations.add(new HandlerRegistration("op1", succeedingOperationHandler));
handlerRegistrations.add(new HandlerRegistration("op2", succeedingOperationHandler));
// instantiate a service implementation and its DAO, overriding the methods that depend on the osgi runtime
service = new WorkflowServiceImpl() {
@Override
public Set<HandlerRegistration> getRegisteredHandlers() {
return handlerRegistrations;
}
};
scanner = new WorkflowDefinitionScanner();
service.addWorkflowDefinitionScanner(scanner);
MediaPackageMetadataService mds = EasyMock.createNiceMock(MediaPackageMetadataService.class);
EasyMock.replay(mds);
service.addMetadataService(mds);
workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.getCollectionContents((String) EasyMock.anyObject())).andReturn(new URI[0]);
EasyMock.replay(workspace);
// security service
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(SecurityServiceStub.DEFAULT_ORG_ADMIN).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
service.setSecurityService(securityService);
UserDirectoryService userDirectoryService = EasyMock.createMock(UserDirectoryService.class);
EasyMock.expect(userDirectoryService.loadUser((String) EasyMock.anyObject())).andReturn(DEFAULT_ORG_ADMIN).anyTimes();
EasyMock.replay(userDirectoryService);
service.setUserDirectoryService(userDirectoryService);
Organization organization = new DefaultOrganization();
List<Organization> organizationList = new ArrayList<Organization>();
organizationList.add(organization);
OrganizationDirectoryService organizationDirectoryService = EasyMock.createMock(OrganizationDirectoryService.class);
EasyMock.expect(organizationDirectoryService.getOrganizations()).andReturn(organizationList).anyTimes();
EasyMock.expect(organizationDirectoryService.getOrganization((String) EasyMock.anyObject())).andReturn(organization).anyTimes();
EasyMock.replay(organizationDirectoryService);
service.setOrganizationDirectoryService(organizationDirectoryService);
ServiceRegistryInMemoryImpl serviceRegistry = new ServiceRegistryInMemoryImpl(service, securityService, userDirectoryService, organizationDirectoryService, EasyMock.createNiceMock(IncidentService.class));
dao = new WorkflowServiceSolrIndex();
dao.solrRoot = sRoot + File.separator + "solr." + System.currentTimeMillis();
MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
EasyMock.replay(messageSender);
AuthorizationService authzService = EasyMock.createNiceMock(AuthorizationService.class);
EasyMock.expect(authzService.getActiveAcl((MediaPackage) EasyMock.anyObject())).andReturn(Tuple.tuple(acl, AclScope.Series)).anyTimes();
EasyMock.replay(authzService);
service.setAuthorizationService(authzService);
dao.setServiceRegistry(serviceRegistry);
dao.setSecurityService(securityService);
dao.setAuthorizationService(authzService);
dao.setOrgDirectory(organizationDirectoryService);
dao.activate("System Admin");
service.setDao(dao);
service.setServiceRegistry(serviceRegistry);
service.setMessageSender(messageSender);
service.setUserDirectoryService(userDirectoryService);
service.activate(null);
InputStream is = null;
try {
is = WorkflowOperationSkippingTest.class.getResourceAsStream("/workflow-definition-skipping.xml");
workingDefinition = WorkflowParser.parseWorkflowDefinition(is);
service.registerWorkflowDefinition(workingDefinition);
IOUtils.closeQuietly(is);
MediaPackageBuilder mediaPackageBuilder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
mediaPackageBuilder.setSerializer(new DefaultMediaPackageSerializerImpl(new File("target/test-classes")));
is = WorkflowOperationSkippingTest.class.getResourceAsStream("/mediapackage-1.xml");
mediapackage1 = mediaPackageBuilder.loadFromXml(is);
IOUtils.closeQuietly(is);
Assert.assertNotNull(mediapackage1.getIdentifier());
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of org.opencastproject.message.broker.api.MessageSender in project opencast by opencast.
the class AclScannerTest method setUp.
@Before
public void setUp() throws Exception {
Organization org1 = new JpaOrganization("org1", "org1", new HashMap<String, Integer>(), "ADMIN", "ANONYMOUS", new HashMap<String, String>());
Organization org2 = new JpaOrganization("org2", "org2", new HashMap<String, Integer>(), "ADMIN", "ANONYMOUS", new HashMap<String, String>());
Organization org3 = new JpaOrganization("org3", "org3", new HashMap<String, Integer>(), "ADMIN", "ANONYMOUS", new HashMap<String, String>());
List<Organization> orgs = new ArrayList<>();
orgs.add(org1);
orgs.add(org2);
orgs.add(org3);
aclDb = EasyMock.createNiceMock(AclDb.class);
orgService = EasyMock.createNiceMock(OrganizationDirectoryService.class);
EasyMock.expect(orgService.getOrganizations()).andReturn(orgs).anyTimes();
final SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
final MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
final AclTransitionDb aclTransitionDb = EasyMock.createNiceMock(AclTransitionDb.class);
List<EpisodeACLTransition> episodeTransitions = new ArrayList<>();
List<SeriesACLTransition> seriesTransitions = new ArrayList<>();
EasyMock.expect(aclTransitionDb.getByQuery(EasyMock.anyObject(Organization.class), EasyMock.anyObject(TransitionQuery.class))).andReturn(new TransitionResultImpl(episodeTransitions, seriesTransitions)).anyTimes();
// EasyMock.replay(aclDb);
EasyMock.replay(orgService, messageSender, aclTransitionDb, securityService);
AclServiceFactory aclServiceFactory = new AclServiceFactory() {
@Override
public AclService serviceFor(Organization org) {
return new AclServiceImpl(new DefaultOrganization(), aclDb, aclTransitionDb, null, null, null, null, messageSender, null);
}
};
aclScanner = new AclScanner();
aclScanner.setAclServiceFactory(aclServiceFactory);
aclScanner.setOrganizationDirectoryService(orgService);
aclScanner.setSecurityService(securityService);
}
use of org.opencastproject.message.broker.api.MessageSender in project opencast by opencast.
the class EventCommentDatabaseImplTest method setUp.
@Before
public void setUp() throws Exception {
UserDirectoryService userDirectoryService = EasyMock.createNiceMock(UserDirectoryService.class);
EasyMock.expect(userDirectoryService.loadUser(EasyMock.anyObject(String.class))).andReturn(USER).anyTimes();
EasyMock.replay(userDirectoryService);
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
EasyMock.replay(messageSender);
persistence = new EventCommentDatabaseServiceImpl();
persistence.setEntityManagerFactory(newTestEntityManagerFactory(PERSISTENCE_UNIT));
persistence.setUserDirectoryService(userDirectoryService);
persistence.setMessageSender(messageSender);
persistence.setSecurityService(securityService);
persistence.activate(null);
}
use of org.opencastproject.message.broker.api.MessageSender in project opencast by opencast.
the class TestThemesEndpoint method setupServices.
private void setupServices() throws Exception {
user = new JaxbUser("test", null, "Test User", "test@test.com", "test", new DefaultOrganization(), new HashSet<JaxbRole>());
UserDirectoryService userDirectoryService = EasyMock.createNiceMock(UserDirectoryService.class);
EasyMock.expect(userDirectoryService.loadUser((String) EasyMock.anyObject())).andReturn(user).anyTimes();
EasyMock.replay(userDirectoryService);
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.expect(securityService.getUser()).andReturn(user).anyTimes();
EasyMock.replay(securityService);
SeriesService seriesService = EasyMock.createNiceMock(SeriesService.class);
EasyMock.replay(seriesService);
MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
messageSender.sendObjectMessage(EasyMock.anyObject(String.class), EasyMock.anyObject(MessageSender.DestinationType.class), EasyMock.anyObject(Serializable.class));
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(messageSender);
// Create AdminUI Search Index
AdminUISearchIndex adminUISearchIndex = EasyMock.createMock(AdminUISearchIndex.class);
final Capture<ThemeSearchQuery> themeQueryCapture = new Capture<ThemeSearchQuery>();
EasyMock.expect(adminUISearchIndex.getByQuery(EasyMock.capture(themeQueryCapture))).andAnswer(new IAnswer<SearchResult<org.opencastproject.index.service.impl.index.theme.Theme>>() {
@Override
public SearchResult<org.opencastproject.index.service.impl.index.theme.Theme> answer() throws Throwable {
return createThemeCaptureResult(themeQueryCapture);
}
});
final Capture<SeriesSearchQuery> seriesQueryCapture = new Capture<SeriesSearchQuery>();
EasyMock.expect(adminUISearchIndex.getByQuery(EasyMock.capture(seriesQueryCapture))).andAnswer(new IAnswer<SearchResult<Series>>() {
@Override
public SearchResult<Series> answer() throws Throwable {
return createSeriesCaptureResult(seriesQueryCapture);
}
});
EasyMock.replay(adminUISearchIndex);
themesServiceDatabaseImpl = new ThemesServiceDatabaseImpl();
themesServiceDatabaseImpl.setEntityManagerFactory(newTestEntityManagerFactory(ThemesServiceDatabaseImpl.PERSISTENCE_UNIT));
themesServiceDatabaseImpl.setUserDirectoryService(userDirectoryService);
themesServiceDatabaseImpl.setSecurityService(securityService);
themesServiceDatabaseImpl.setMessageSender(messageSender);
themesServiceDatabaseImpl.activate(null);
StaticFileService staticFileService = EasyMock.createNiceMock(StaticFileService.class);
EasyMock.expect(staticFileService.getFile(EasyMock.anyString())).andReturn(new ByteArrayInputStream("test".getBytes("utf-8"))).anyTimes();
EasyMock.expect(staticFileService.getFileName(EasyMock.anyString())).andStubReturn("test.mp4");
EasyMock.replay(staticFileService);
BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
EasyMock.expect(bundleContext.getProperty("org.opencastproject.server.url")).andReturn("http://localhost:8080").anyTimes();
EasyMock.replay(bundleContext);
ComponentContext componentContext = EasyMock.createNiceMock(ComponentContext.class);
EasyMock.expect(componentContext.getBundleContext()).andReturn(bundleContext).anyTimes();
EasyMock.expect(componentContext.getProperties()).andReturn(new Hashtable<String, Object>()).anyTimes();
EasyMock.replay(componentContext);
StaticFileRestService staticFileRestService = new StaticFileRestService();
staticFileRestService.setStaticFileService(staticFileService);
staticFileRestService.activate(componentContext);
this.setThemesServiceDatabase(themesServiceDatabaseImpl);
this.setSecurityService(securityService);
this.setSeriesService(seriesService);
this.setStaticFileService(staticFileService);
this.setStaticFileRestService(staticFileRestService);
this.setIndex(adminUISearchIndex);
}
Aggregations