@Before public void setUp() throws Exception { clientConfiguration = new DefaultClientConfiguration(); diContainer.put("clientConfiguration", clientConfiguration); diContainer.put("dropUrlGenerator", new DropUrlGenerator("http://localhost:5000")); identityBuilderFactory = new IdentityBuilderFactory((DropUrlGenerator) diContainer.get("dropUrlGenerator")); diContainer.put("identityBuilderFactory", identityBuilderFactory); diContainer.put("account", new Account("a", "b", "c")); diContainer.put("identityRepository", identityRepository); diContainer.put("contactRepository", contactRepository); boxVolumeFactory = new BoxVolumeFactoryStub(); diContainer.put("boxVolumeFactory", boxVolumeFactory); loadManager = new DefaultTransferManager(); diContainer.put("loadManager", loadManager); diContainer.put("dropMessageRepository", dropMessageRepository); diContainer.put("dropConnector", httpDropConnector); diContainer.put("transferManager", new DefaultTransferManager()); diContainer.put("sharingService", sharingService); diContainer.put("reportHandler", crashReportHandler); MessageRendererFactory messageRendererFactory = new MessageRendererFactory(); messageRendererFactory.setFallbackRenderer(new PlaintextMessageRenderer()); diContainer.put("messageRendererFactory", messageRendererFactory); Injector.setConfigurationSource(diContainer::get); Injector.setInstanceSupplier(new RecursiveInjectionInstanceSupplier(diContainer)); identity = identityBuilderFactory.factory().withAlias("TestAlias").build(); clientConfiguration.selectIdentity(identity); }
private void addShareMessageRenderer(Identity arg) { executorService.submit( () -> { ShareNotificationRenderer renderer = new ShareNotificationRenderer( ((BoxVolumeFactory) customProperties.get("boxVolumeFactory")) .getVolume(config.getAccount(), arg) .getReadBackend(), sharingService); rendererFactory.addRenderer( DropMessageRepository.PAYLOAD_TYPE_SHARE_NOTIFICATION, renderer); }); }
private ClientConfiguration initDiContainer() throws Exception { if (!Files.exists(DATABASE_FILE) && !Files.exists(DATABASE_FILE.getParent())) { Files.createDirectories(DATABASE_FILE.getParent()); } Persistence<String> persistence = new SQLitePersistence(DATABASE_FILE.toFile().getAbsolutePath()); transferManager = new MonitoredTransferManager(new DefaultTransferManager()); customProperties.put("loadManager", transferManager); customProperties.put("transferManager", transferManager); customProperties.put("persistence", persistence); customProperties.put("dropUrlGenerator", new DropUrlGenerator("https://qdrop.prae.me")); identityRepository = new PersistenceIdentityRepository(persistence); customProperties.put("identityRepository", identityRepository); PersistenceAccountRepository accountRepository = new PersistenceAccountRepository(persistence); customProperties.put("accountRepository", accountRepository); contactRepository = new PersistenceContactRepository(persistence); customProperties.put("contactRepository", contactRepository); dropMessageRepository = new PersistenceDropMessageRepository(persistence); customProperties.put("dropMessageRepository", dropMessageRepository); customProperties.put("dropConnector", dropConnector); customProperties.put("reportHandler", new HockeyApp()); ClientConfiguration clientConfig = getClientConfiguration(persistence, identityRepository, accountRepository); if (!clientConfig.hasDeviceId()) { clientConfig.setDeviceId(generateDeviceId()); } PersistenceContactRepository contactRepository = new PersistenceContactRepository(persistence); customProperties.put("contactRepository", contactRepository); customProperties.put("clientConfiguration", clientConfig); customProperties.put("primaryStage", primaryStage); rendererFactory.setFallbackRenderer(new PlaintextMessageRenderer()); customProperties.put("messageRendererFactory", rendererFactory); Injector.setConfigurationSource(customProperties::get); Injector.setInstanceSupplier(new RecursiveInjectionInstanceSupplier(customProperties)); return clientConfig; }