コード例 #1
0
  /**
   * Test method for {@link
   * de.metanome.frontend.client.input_fields.DatabaseConnectionInput#handleSuccess(java.util.List)}
   */
  public void testHandleSuccessWithNotListedDbSystem() {
    // Set up
    DatabaseConnection dbConnection1 = new DatabaseConnection();
    dbConnection1.setUrl("url1");
    dbConnection1.setPassword("password1");
    dbConnection1.setUsername("username1");
    dbConnection1.setSystem(DbSystem.DB2);

    DatabaseConnection dbConnection2 = new DatabaseConnection();
    dbConnection2.setUrl("url2");
    dbConnection2.setPassword("password2");
    dbConnection2.setUsername("username2");
    dbConnection2.setSystem(DbSystem.Oracle);

    List<DatabaseConnection> databaseConnectionList = new ArrayList<>();
    databaseConnectionList.add(dbConnection1);
    databaseConnectionList.add(dbConnection2);

    List<String> acceptedSystems = new ArrayList<>();
    acceptedSystems.add(DbSystem.HANA.name());

    DatabaseConnectionInput databaseConnectionInput =
        new DatabaseConnectionInput(false, false, new TabWrapper(), acceptedSystems);

    // Expected
    // Execute
    databaseConnectionInput.handleSuccess(databaseConnectionList);

    // Check
    assertEquals(1, databaseConnectionInput.listBox.getValues().size());
    assertFalse(
        databaseConnectionInput.listBox.getValues().contains(dbConnection2.getIdentifier()));
    assertFalse(
        databaseConnectionInput.listBox.getValues().contains(dbConnection1.getIdentifier()));
  }
コード例 #2
0
  /**
   * Test method for {@link DatabaseConnectionInput#getValues()} and {@link
   * DatabaseConnectionInput#setValues(ConfigurationSettingDatabaseConnection)}
   *
   * <p>The getValue and setValue methods should set and retrieve settings.
   */
  public void testGetSetValues() throws AlgorithmConfigurationException {
    // Set up
    TestHelper.resetDatabaseSync();

    TabWrapper tabWrapper = new TabWrapper();

    DatabaseConnection dbConnection = new DatabaseConnection();
    dbConnection.setUrl("url");
    dbConnection.setPassword("password");
    dbConnection.setUsername("username");
    dbConnection.setSystem(DbSystem.DB2);

    // Expected values
    ConfigurationSettingDatabaseConnection expectedSetting =
        new ConfigurationSettingDatabaseConnection("url", "username", "password", DbSystem.DB2);

    // Initialize DatabaseConnectionInput (waiting for fetching all current database connections)
    DatabaseConnectionInput databaseConnectionInput =
        new DatabaseConnectionInput(false, false, tabWrapper, new ArrayList<String>());

    databaseConnectionInput.databaseConnections.put("url", dbConnection);
    databaseConnectionInput.listBox.addValue("--");
    databaseConnectionInput.listBox.addValue("url");

    // Execute functionality
    databaseConnectionInput.setValues(expectedSetting);

    ConfigurationSettingDatabaseConnection actualSetting = null;
    try {
      actualSetting = databaseConnectionInput.getValues();
    } catch (InputValidationException e) {
      fail();
    }

    // Check result
    assertEquals(expectedSetting.getDbUrl(), actualSetting.getDbUrl());
    assertEquals(expectedSetting.getPassword(), actualSetting.getPassword());
    assertEquals(expectedSetting.getUsername(), actualSetting.getUsername());
    assertEquals(expectedSetting.getSystem(), actualSetting.getSystem());

    // Cleanup
    TestHelper.resetDatabaseSync();
  }