use of org.opencastproject.transcription.ibmwatson.persistence.TranscriptionDatabase in project opencast by opencast.
the class IBMWatsonTranscriptionServiceTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
URI mediaPackageURI = IBMWatsonTranscriptionServiceTest.class.getResource("/mp.xml").toURI();
mediaPackage = builder.loadFromXml(mediaPackageURI.toURL().openStream());
URI audioUrl = IBMWatsonTranscriptionServiceTest.class.getResource("/audio.ogg").toURI();
audioFile = new File(audioUrl);
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(IBMWatsonTranscriptionService.ENABLED_CONFIG, "true");
props.put(IBMWatsonTranscriptionService.IBM_WATSON_USER_CONFIG, "user");
props.put(IBMWatsonTranscriptionService.IBM_WATSON_PSW_CONFIG, "psw");
props.put(IBMWatsonTranscriptionService.COMPLETION_CHECK_BUFFER_CONFIG, 0);
props.put(IBMWatsonTranscriptionService.MAX_PROCESSING_TIME_CONFIG, 0);
props.put(IBMWatsonTranscriptionService.NOTIFICATION_EMAIL_CONFIG, "anyone@opencast.org");
ComponentContext cc = EasyMock.createNiceMock(ComponentContext.class);
EasyMock.expect(cc.getProperties()).andReturn(props).anyTimes();
BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
EasyMock.expect(bc.getProperty(OpencastConstants.SERVER_URL_PROPERTY)).andReturn("http://THIS_SERVER");
EasyMock.expect(bc.getProperty("org.opencastproject.security.digest.user")).andReturn("matterhorn_system_account");
EasyMock.expect(cc.getBundleContext()).andReturn(bc).anyTimes();
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
Map<String, String> orgProps = new HashMap<String, String>();
orgProps.put(IBMWatsonTranscriptionService.ADMIN_URL_PROPERTY, "http://ADMIN_SERVER");
org = new JaxbOrganization(DefaultOrganization.DEFAULT_ORGANIZATION_ID, DefaultOrganization.DEFAULT_ORGANIZATION_NAME, null, DefaultOrganization.DEFAULT_ORGANIZATION_ADMIN, DefaultOrganization.DEFAULT_ORGANIZATION_ANONYMOUS, orgProps);
User user = new JaxbUser("admin", null, "test", org, new JaxbRole(SecurityConstants.GLOBAL_ADMIN_ROLE, org));
EasyMock.expect(securityService.getOrganization()).andReturn(org).anyTimes();
EasyMock.expect(securityService.getUser()).andReturn(user).anyTimes();
OrganizationDirectoryService orgDirectory = EasyMock.createNiceMock(OrganizationDirectoryService.class);
EasyMock.expect(orgDirectory.getOrganization((String) EasyMock.anyObject())).andReturn(org).anyTimes();
UserDirectoryService userDirectory = EasyMock.createNiceMock(UserDirectoryService.class);
EasyMock.expect(userDirectory.loadUser("admin")).andReturn(user).anyTimes();
IncidentService incident = EasyMock.createNiceMock(IncidentService.class);
smtpService = EasyMock.createNiceMock(SmtpService.class);
smtpService.send((String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject());
EasyMock.expectLastCall().once();
EasyMock.replay(bc, cc, securityService, orgDirectory, userDirectory, incident, smtpService);
// Mocks for WorkflowDispatcher test
assetManager = EasyMock.createNiceMock(AssetManager.class);
wfService = EasyMock.createNiceMock(WorkflowService.class);
workspace = EasyMock.createNiceMock(Workspace.class);
// Database
database = new TranscriptionDatabase();
database.setEntityManagerFactory(PersistenceUtil.newTestEntityManagerFactory("org.opencastproject.transcription.ibmwatson.persistence"));
database.activate(null);
httpClient = EasyMock.createNiceMock(CloseableHttpClient.class);
service = new IBMWatsonTranscriptionService() {
@Override
protected CloseableHttpClient makeHttpClient() {
return httpClient;
}
};
ServiceRegistry serviceRegistry = new ServiceRegistryInMemoryImpl(service, securityService, userDirectory, orgDirectory, incident);
service.setOrganizationDirectoryService(orgDirectory);
service.setSecurityService(securityService);
service.setServiceRegistry(serviceRegistry);
service.setUserDirectoryService(userDirectory);
service.setWorkspace(workspace);
service.setDatabase(database);
service.setAssetManager(assetManager);
service.setWorkflowService(wfService);
service.setSmtpService(smtpService);
service.activate(cc);
}
use of org.opencastproject.transcription.ibmwatson.persistence.TranscriptionDatabase in project opencast by opencast.
the class TranscriptionDatabaseTest method setUp.
@Before
public void setUp() throws Exception {
database = new TranscriptionDatabase();
database.setEntityManagerFactory(newTestEntityManagerFactory("org.opencastproject.transcription.ibmwatson.persistence"));
database.activate(null);
}
Aggregations