private void setUpMockitoGeneralRules() throws Exception {
   when(mockPluginDatabaseSystem.createDatabase(
           pluginId, IntraWalletUserActorDatabaseConstants.INTRA_WALLET_USER_DATABASE_NAME))
       .thenReturn(mockDatabase);
   when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory);
   when(mockDatabaseFactory.newTableFactory(
           pluginId, IntraWalletUserActorDatabaseConstants.INTRA_WALLET_USER_TABLE_NAME))
       .thenReturn(mockIntraUserTableFactory);
   when(mockDatabase.getTable(IntraWalletUserActorDatabaseConstants.INTRA_WALLET_USER_TABLE_NAME))
       .thenReturn(mockTable);
   when(mockTable.getEmptyRecord()).thenReturn(mockTableRecord);
 }
Beispiel #2
0
 @Test
 public void
     testInitialize_DatabaseNotFoundAndCreateDatabaseFailed_ThrowsCantInitializeCryptoRegistryException()
         throws Exception {
   when(mockPluginDatabaseSystem.openDatabase(
           testId, IncomingExtraUserDataBaseConstants.INCOMING_EXTRA_USER_DATABASE))
       .thenThrow(new DatabaseNotFoundException("MOCK", null, null, null));
   when(mockPluginDatabaseSystem.createDatabase(
           testId, IncomingExtraUserDataBaseConstants.INCOMING_EXTRA_USER_DATABASE))
       .thenThrow(new CantCreateDatabaseException("MOCK", null, null, null));
   testRegistry = new IncomingExtraUserRegistry();
   testRegistry.setErrorManager(mockErrorManager);
   testRegistry.setPluginDatabaseSystem(mockPluginDatabaseSystem);
   catchException(testRegistry).initialize(testId);
   assertThat(caughtException()).isInstanceOf(CantInitializeCryptoRegistryException.class);
 }
Beispiel #3
0
 @Test
 public void Initialize_DatabaseNotFound_MethodSuccesfullyInvoked() throws Exception {
   when(mockPluginDatabaseSystem.openDatabase(
           testId, IncomingExtraUserDataBaseConstants.INCOMING_EXTRA_USER_DATABASE))
       .thenThrow(
           new DatabaseNotFoundException(
               DatabaseNotFoundException.DEFAULT_MESSAGE, null, null, null));
   when(mockPluginDatabaseSystem.createDatabase(
           testId, IncomingExtraUserDataBaseConstants.INCOMING_EXTRA_USER_DATABASE))
       .thenReturn(mockDatabase);
   when(mockDatabase.getDatabaseFactory()).thenReturn(mockDatabaseFactory);
   when(mockDatabaseFactory.newTableFactory(any(UUID.class), anyString()))
       .thenReturn(mockTableFactory);
   testRegistry = new IncomingExtraUserRegistry();
   testRegistry.setErrorManager(mockErrorManager);
   testRegistry.setPluginDatabaseSystem(mockPluginDatabaseSystem);
   catchException(testRegistry).initialize(testId);
   assertThat(caughtException()).isNull();
 }