@Before
 public void testConnectionProfile() {
   log.step("Import test project");
   importMavenProject(PRJ);
   DatabaseConfiguration cfg = dbRequirement.getConfiguration();
   log.step("Create database driver definition");
   DriverDefinitionFactory.createDatabaseDriverDefinition(cfg);
   log.step("Create database connection profile");
   ConnectionProfileFactory.createConnectionProfile(cfg);
   // log.step("Convert project to faceted form");
   // ProjectConfigurationFactory.convertProjectToFacetsForm(PRJ);
   log.step("Set project facet for JPA");
   ProjectConfigurationFactory.setProjectFacetForDB(PRJ, cfg);
 }
  public void prepareConsoleConfiguration() {
    log.step("Create hibernate configuration file with console configuration");
    NewHibernateConfigurationWizard wizard = new NewHibernateConfigurationWizard();
    wizard.open();
    NewConfigurationLocationPage p1 = new NewConfigurationLocationPage();
    p1.setLocation(PROJECT_NAME, "src");
    wizard.next();

    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    NewConfigurationSettingPage p2 = new NewConfigurationSettingPage();
    p2.setDatabaseDialect("H2");
    p2.setDriverClass(cfg.getDriverClass());
    p2.setConnectionURL(cfg.getJdbcString());
    p2.setUsername(cfg.getUsername());
    p2.setCreateConsoleConfiguration(true);

    wizard.finish();
  }
  private void createConfigurationFileFromDatasource(String hbVersion) {
    // Create datasource
    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    log.step("Create database driver definition");
    DriverDefinitionFactory.createDatabaseDriverDefinition(cfg);
    log.step("Create database connection profile");
    ConnectionProfileFactory.createConnectionProfile(cfg);

    log.step("Create Hibernate configuration file");
    NewHibernateConfigurationWizard wizard = new NewHibernateConfigurationWizard();
    wizard.open();

    NewConfigurationLocationPage p1 = new NewConfigurationLocationPage();
    p1.setLocation(PROJECT_NAME, "src");
    wizard.next();

    // Get values from connection
    log.step("Use created database connection profile for database details");
    Link link = new DefaultLink("Get values from Connection");
    link.click();
    new WaitUntil(new ShellWithTextIsActive("Select Connection Profile"));
    new DefaultCombo().setSelection(cfg.getProfileName());
    new OkButton().click();
    new WaitWhile(new ShellWithTextIsActive("Select Connection Profile"));

    new DefaultShell("");

    // Check values
    NewConfigurationSettingPage p2 = new NewConfigurationSettingPage();
    p2.setHibernateVersion(hbVersion);
    assertTrue("jdbc must match", p2.getConnectionURL().equals(cfg.getJdbcString()));
    assertTrue("driver must match", p2.getDriveClass().equals(cfg.getDriverClass()));
    assertTrue("username must match", p2.getUsername().equals(cfg.getUsername()));

    log.step("Finish the wizard");
    wizard.finish();

    checkFile(false);
  }
  public void testCreateConfigurationFile(String hbVersion, boolean generateConsole) {

    log.step("Create Hibernate configuration file");
    NewHibernateConfigurationWizard wizard = new NewHibernateConfigurationWizard();
    wizard.open();
    NewConfigurationLocationPage p1 = new NewConfigurationLocationPage();
    p1.setLocation(PROJECT_NAME, "src");
    wizard.next();

    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    NewConfigurationSettingPage p2 = new NewConfigurationSettingPage();
    p2.setHibernateVersion(hbVersion);
    p2.setConnectionURL(cfg.getJdbcString());
    p2.setUsername(cfg.getUsername());

    if (generateConsole) {
      p2.setCreateConsoleConfiguration(generateConsole);
    }
    log.step("Finish the wizard");
    wizard.finish();

    checkFile(generateConsole);
  }
 @After
 public void cleanUp() {
   DatabaseConfiguration cfg = dbRequirement.getConfiguration();
   ConnectionProfileFactory.deleteConnectionProfile(cfg.getProfileName());
 }