コード例 #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();
  }
コード例 #3
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 testGetSetRequirementValues() throws AlgorithmConfigurationException {
    // Set up
    TestHelper.resetDatabaseSync();

    TabWrapper tabWrapper = new TabWrapper();

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

    try {
      databaseConnectionInput.getValues();
    } catch (InputValidationException e) {
      // should throw an exception
    }

    // Cleanup
    TestHelper.resetDatabaseSync();
  }
コード例 #4
0
  /**
   * Test method for {@link DatabaseConnectionInput#DatabaseConnectionInput( boolean, boolean,
   * de.metanome.frontend.client.TabWrapper, java.util.List)}
   *
   * <p>After calling the constructor the optional parameter should be set correctly and all widgets
   * should be initialized.
   */
  public void testConstructor() {
    // Set up
    TestHelper.resetDatabaseSync();

    TabWrapper tabWrapper = new TabWrapper();

    // Expected values
    boolean expectedOptional = true;

    // Execute functionality
    DatabaseConnectionInput actualDatabaseConnectionInput =
        new DatabaseConnectionInput(expectedOptional, false, tabWrapper, new ArrayList<String>());

    // Check result
    assertEquals(expectedOptional, actualDatabaseConnectionInput.isOptional);
    assertEquals(2, actualDatabaseConnectionInput.getWidgetCount());
    assertNotNull(actualDatabaseConnectionInput.listBox);

    // Cleanup
    TestHelper.resetDatabaseSync();
  }