private void setUpEventListeners() { FermatEventListener fermatEventListenerNewNotification = eventManager.getNewListener(EventType.INCOMING_MONEY_NOTIFICATION); FermatEventHandler fermatEventHandlerNewNotification = new IncomingMoneyNotificationHandler(this); fermatEventListenerNewNotification.setEventHandler(fermatEventHandlerNewNotification); eventManager.addListener(fermatEventListenerNewNotification); listenersAdded.add(fermatEventListenerNewNotification); FermatEventListener fermatEventListenerCloudClientConnectedNotification = eventManager.getNewListener( P2pEventType.COMPLETE_CLIENT_COMPONENT_REGISTRATION_NOTIFICATION); FermatEventHandler CloudClietNotificationHandler = new com.bitdubai.fermat_pip_plugin.layer.sub_app_module.notification.developer.bitdubai .version_1.event_handlers.CloudClietNotificationHandler(this); fermatEventListenerCloudClientConnectedNotification.setEventHandler( CloudClietNotificationHandler); eventManager.addListener(fermatEventListenerCloudClientConnectedNotification); listenersAdded.add(fermatEventListenerCloudClientConnectedNotification); FermatEventListener fermatEventListenerIncomingRequestConnectionNotification = eventManager.getNewListener( EventType.INCOMING_INTRA_ACTOR_REQUUEST_CONNECTION_NOTIFICATION); FermatEventHandler incomingRequestConnectionNotificationHandler = new com.bitdubai.fermat_pip_plugin.layer.sub_app_module.notification.developer.bitdubai .version_1.event_handlers.IncomingRequestConnectionNotificationHandler(this); fermatEventListenerIncomingRequestConnectionNotification.setEventHandler( incomingRequestConnectionNotificationHandler); eventManager.addListener(fermatEventListenerIncomingRequestConnectionNotification); listenersAdded.add(fermatEventListenerIncomingRequestConnectionNotification); }
@Override public void start() throws CantStartPluginException { try { FermatEventListener fermatEventListener; FermatEventHandler fermatEventHandler; this.cryptoCustomerActorDao = new CryptoCustomerActorDao(pluginDatabaseSystem, pluginFileSystem, pluginId); this.cryptoCustomerActorDao.initializeDatabase(); fermatManager = new CustomerActorManager( this.cryptoCustomerActorDao, cryptoBrokerANSManager, errorManager, getPluginVersionReference()); ActorCustomerExtraDataEventActions handlerAction = new ActorCustomerExtraDataEventActions( cryptoBrokerANSManager, cryptoCustomerActorDao, cryptoBrokerActorConnectionManager); fermatEventListener = eventManager.getNewListener(EventType.CRYPTO_BROKER_QUOTES_REQUEST_UPDATES); fermatEventHandler = new CryptoCustomerExtraDataEventHandler(handlerAction, this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); fermatEventListener = eventManager.getNewListener(EventType.CRYPTO_BROKER_ACTOR_CONNECTION_NEW_CONNECTION); fermatEventHandler = new CryptoBrokerNewConnectionEventHandler(handlerAction, this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); agente = new CryptoBrokerExtraDataUpdateAgent( cryptoBrokerANSManager, cryptoCustomerActorDao, errorManager, getPluginVersionReference()); agente.start(); this.serviceStatus = ServiceStatus.STARTED; } catch (CantStartAgentException | CantInitializeCryptoCustomerActorDatabaseException e) { errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); throw new CantStartPluginException(e, this.getPluginVersionReference()); } }
private void setUpMockitoRules() throws Exception { when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory); when(mockDatabaseTable.getEmptyRecord()).thenReturn(mockDatabaseTableRecord); when(mockDatabase.getTable( AssetIssuingTransactionDatabaseConstants.DIGITAL_ASSET_TRANSACTION_TABLE_NAME)) .thenReturn(mockDatabaseTable); when(mockDatabase.getTable( AssetIssuingTransactionDatabaseConstants .DIGITAL_ASSET_TRANSACTION_ASSET_ISSUING_TABLE_NAME)) .thenReturn(mockDatabaseTable2); when(mockDatabaseTable2.getEmptyRecord()).thenReturn(mockDatabaseTableRecord); when(mockDatabaseTable2.getRecords()).thenReturn(records); when(pluginDatabaseSystem.openDatabase( pluginId, AssetIssuingTransactionDatabaseConstants.DIGITAL_ASSET_TRANSACTION_DATABASE)) .thenReturn(mockDatabase); when(deviceUser.getPublicKey()).thenReturn("myPublicKey"); when(deviceUserManager.getLoggedInDeviceUser()).thenReturn(deviceUser); when(actorAssetIssuerManager.getActorAssetIssuer()).thenReturn(actorAssetIssuer); when(eventManager.getNewListener( EventType.INCOMING_ASSET_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener1); when(eventManager.getNewListener( EventType.INCOMING_ASSET_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener2); when(eventManager.getNewListener( EventType.INCOMING_ASSET_REVERSED_ON_BLOCKCHAIN_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener3); when(eventManager.getNewListener( EventType.INCOMING_ASSET_REVERSED_ON_CRYPTO_NETWORK_WAITING_TRANSFERENCE_ASSET_ISSUER)) .thenReturn(fermatEventListener4); when(pluginFileSystem.createTextFile( this.pluginId, "digital-asset-issuing/publicKey", "name.xml", FilePrivacy.PUBLIC, FileLifeSpan.PERMANENT)) .thenReturn(pluginTextFile); when(bitcoinWalletManager.loadWallet(this.walletPublicKey)).thenReturn(bitcoinWalletWallet); when(bitcoinWalletWallet.getBalance(BalanceType.AVAILABLE)).thenReturn(bitcoinWalletBalance); when(bitcoinWalletBalance.getBalance()).thenReturn(bitcoinWalletAvailableBalance); when(assetVaultManager.getNewAssetVaultCryptoAddress(this.blockchainNetworkType)) .thenReturn(cryptoAddress); // doNothing().when(assetIssuingPluginRoot).issueAssets(digitalAsset, 1, walletPublicKey, // blockchainNetworkType); }
@Override public void start() throws CantStartServiceException { try { /** I will initialize the handling of com.bitdubai.platform events. */ FermatEventListener fermatEventListener; FermatEventHandler fermatEventHandler; fermatEventListener = eventManager.getNewListener(EventType.INCOMING_NEW_CONTRACT_STATUS_UPDATE); fermatEventHandler = new IncomingNewContractStatusUpdateEventHandler(); ((IncomingNewContractStatusUpdateEventHandler) fermatEventHandler) .setBrokerSubmitOfflineMerchandiseRecorderService(this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); fermatEventListener = eventManager.getNewListener(EventType.INCOMING_CONFIRM_BUSINESS_TRANSACTION_RESPONSE); fermatEventHandler = new IncomingConfirmBusinessTransactionResponseEventHandler(); ((IncomingConfirmBusinessTransactionResponseEventHandler) fermatEventHandler) .setBrokerSubmitOfflineMerchandiseRecorderService(this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); this.serviceStatus = ServiceStatus.STARTED; } catch (CantSetObjectException exception) { this.errorManager.reportUnexpectedPluginException( Plugins.BROKER_SUBMIT_OFFLINE_MERCHANDISE, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, exception); throw new CantStartServiceException( exception, "Starting the BrokerSubmitOfflineMerchandiseRecorderService", "The BrokerSubmitOfflineMerchandiseRecorderService is probably null"); } catch (Exception exception) { this.errorManager.reportUnexpectedPluginException( Plugins.BROKER_SUBMIT_OFFLINE_MERCHANDISE, UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, exception); throw new CantStartServiceException( CantStartServiceException.DEFAULT_MESSAGE, exception, "Starting the CustomerOnlinePaymentRecorderService", "Unexpected error"); } }
@Override public void start() throws CantStartServiceException { try { /** I will initialize the handling of com.bitdubai.platform events. */ FermatEventListener fermatEventListener; FermatEventHandler fermatEventHandler; fermatEventListener = eventManager.getNewListener(EventType.INCOMING_CHAT); fermatEventHandler = new IncomingChatEventHandler(); ((IncomingChatEventHandler) fermatEventHandler).setChatMiddlewareRecorderService(this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); fermatEventListener = eventManager.getNewListener(EventType.OUTGOING_CHAT); fermatEventHandler = new OutgoingChatEventHandler(); ((OutgoingChatEventHandler) fermatEventHandler).setChatMiddlewareRecorderService(this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); fermatEventListener = eventManager.getNewListener(EventType.INCOMING_STATUS); fermatEventHandler = new IncomingNewChatStatusUpdateEventHandler(); ((IncomingNewChatStatusUpdateEventHandler) fermatEventHandler) .setChatMiddlewareRecorderService(this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); this.serviceStatus = ServiceStatus.STARTED; } catch (CantSetObjectException exception) { throw new CantStartServiceException( exception, "Starting the ChatMiddlewareRecorderService", "The ChatMiddlewareRecorderService is probably null"); } catch (Exception exception) { errorManager.reportUnexpectedPluginException( Plugins.CHAT_MIDDLEWARE, UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN, FermatException.wrapException(exception)); throw new CantStartServiceException( exception, "Starting the ChatMiddlewareRecorderService", "Unexpected Exception"); } }
@Before public void setUp() throws Exception { subAppResourcesNetworkServicePluginRoot = new SubAppResourcesNetworkServicePluginRoot(); subAppResourcesNetworkServicePluginRoot.setPluginFileSystem(pluginFileSystem); subAppResourcesNetworkServicePluginRoot.setEventManager(mockEventManager); subAppResourcesNetworkServicePluginRoot.setErrorManager(errorManager); subAppResourcesNetworkServicePluginRoot.setPluginDatabaseSystem(mockPluginDatabaseSystem); when(mockPluginDatabaseSystem.openDatabase(any(UUID.class), anyString())) .thenReturn(mockDatabase); when(gitHubConnection.getFile(anyString())).thenReturn(repoManifest); when(pluginFileSystem.createTextFile( any(UUID.class), anyString(), anyString(), any(FilePrivacy.class), any(FileLifeSpan.class))) .thenReturn(layoutFile); when(pluginFileSystem.createBinaryFile( any(UUID.class), anyString(), anyString(), any(FilePrivacy.class), any(FileLifeSpan.class))) .thenReturn(imageFile); when(mockEventManager.getNewListener(EventType.BEGUN_WALLET_INSTALLATION)) .thenReturn(mockFermatEventListener); when(pluginFileSystem.getTextFile( any(UUID.class), anyString(), anyString(), any(FilePrivacy.class), any(FileLifeSpan.class))) .thenReturn(mockPluginTextFile); setUpDataBase(); }
private void initializeListener() { /* * Listen and handle Complete Component Registration Notification Event */ FermatEventListener fermatEventListener = eventManager.getNewListener(P2pEventType.COMPLETE_COMPONENT_REGISTRATION_NOTIFICATION); fermatEventListener.setEventHandler( new CompleteComponentRegistrationNotificationEventHandler(this)); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); /* * Listen and handle Complete Request List Component Registered Notification Event */ fermatEventListener = eventManager.getNewListener( P2pEventType.COMPLETE_REQUEST_LIST_COMPONENT_REGISTERED_NOTIFICATION); // fermatEventListener.setEventHandler(new // CompleteRequestListComponentRegisteredNotificationEventHandler(this)); // eventManager.addListener(fermatEventListener); // listenersAdded.add(fermatEventListener); /* * Listen and handle Complete Request List Component Registered Notification Event */ fermatEventListener = eventManager.getNewListener( P2pEventType.COMPLETE_COMPONENT_CONNECTION_REQUEST_NOTIFICATION); fermatEventListener.setEventHandler( new CompleteComponentConnectionRequestNotificationEventHandler(this)); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); /** failure connection */ fermatEventListener = eventManager.getNewListener(P2pEventType.FAILURE_COMPONENT_CONNECTION_REQUEST_NOTIFICATION); fermatEventListener.setEventHandler( new FailureComponentConnectionRequestNotificationEventHandler(this)); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); /** close connection */ fermatEventListener = eventManager.getNewListener(P2pEventType.CLIENT_CONNECTION_CLOSE); fermatEventListener.setEventHandler(new ClientConnectionCloseNotificationEventHandler(this)); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); /* * Listen and handle VPN Connection Close Notification Event */ fermatEventListener = eventManager.getNewListener(P2pEventType.VPN_CONNECTION_CLOSE); fermatEventListener.setEventHandler(new VPNConnectionCloseNotificationEventHandler(this)); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); /** new message */ fermatEventListener = eventManager.getNewListener(P2pEventType.NEW_NETWORK_SERVICE_MESSAGE_RECEIVE_NOTIFICATION); fermatEventListener.setEventHandler(new NewReceiveMessagesNotificationEventHandler(this)); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); /* * Listen and handle Client Connection Loose Notification Event */ fermatEventListener = eventManager.getNewListener(P2pEventType.CLIENT_CONNECTION_LOOSE); fermatEventListener.setEventHandler(new ClientConnectionLooseNotificationEventHandler(this)); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); /* * Listen and handle Client Connection Success Reconnect Notification Event */ fermatEventListener = eventManager.getNewListener(P2pEventType.CLIENT_SUCCESS_RECONNECT); fermatEventListener.setEventHandler( new ClientSuccessfullReconnectNotificationEventHandler(this)); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); }