示例#1
0
  @Test
  public void Initialize_RegistryProperlySet_MethodSuccesfullyInvoked() throws Exception {
    when(mockPluginDatabaseSystem.openDatabase(
            testId, IncomingExtraUserDataBaseConstants.INCOMING_EXTRA_USER_DATABASE))
        .thenReturn(mockDatabase);

    testRegistry = new IncomingExtraUserRegistry();
    testRegistry.setErrorManager(mockErrorManager);
    testRegistry.setPluginDatabaseSystem(mockPluginDatabaseSystem);
    catchException(testRegistry).initialize(testId);
    assertThat(caughtException()).isNull();
  }
示例#2
0
 @Test
 public void Initialize_CantOpenDatabase_ThrowsCantInitializeCryptoRegistryException()
     throws Exception {
   when(mockPluginDatabaseSystem.openDatabase(
           testId, IncomingExtraUserDataBaseConstants.INCOMING_EXTRA_USER_DATABASE))
       .thenThrow(new CantOpenDatabaseException("MOCK", null, null, null));
   testRegistry = new IncomingExtraUserRegistry();
   testRegistry.setErrorManager(mockErrorManager);
   testRegistry.setPluginDatabaseSystem(mockPluginDatabaseSystem);
   catchException(testRegistry).initialize(testId);
   assertThat(caughtException()).isInstanceOf(CantInitializeCryptoRegistryException.class);
 }
示例#3
0
 @Test
 public void Initialize_NoPluginDatabaseSystemSet_ThrowsCantInitializeCryptoRegistryException()
     throws Exception {
   testRegistry = new IncomingExtraUserRegistry();
   testRegistry.setErrorManager(mockErrorManager);
   catchException(testRegistry).initialize(testId);
   assertThat(caughtException()).isInstanceOf(CantInitializeCryptoRegistryException.class);
 }
示例#4
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();
 }