@Test
  public void replaceColumnDetectedCorrectly() throws StructureGraphComparisonException {
    ISqlSchemaFrontend frontend1 = new H2SchemaFrontend(DATABASE_FILE_PATH);
    ISqlSchemaFrontend frontend2 = new H2SchemaFrontend(REPLACE_COLUMN_DATABASE_FILE_PATH);
    DirectedGraph<IStructureElement, DefaultEdge> schema1 = frontend1.createSqlSchema();
    DirectedGraph<IStructureElement, DefaultEdge> schema2 = frontend2.createSqlSchema();
    SqlSchemaComparer comparer = new SqlSchemaComparer(schema1, schema2);
    SqlSchemaComparisonResult result = comparer.comparisonResult;

    assertEquals(
        29,
        SqlElementFactory.getSqlElementsOfType(SqlColumnVertex.class, schema1.vertexSet()).size());
    assertEquals(
        29,
        SqlElementFactory.getSqlElementsOfType(SqlColumnVertex.class, schema2.vertexSet()).size());

    Entry<ISqlElement, SchemaModification> renameColumnEntry =
        TestHelper.getModificationOfType(result, SchemaModification.RENAME_COLUMN);
    Entry<ISqlElement, SchemaModification> replaceColumnTypeEntry =
        TestHelper.getModificationOfType(result, SchemaModification.CHANGE_COLUMN_TYPE);

    assertNotNull(renameColumnEntry);
    assertEquals(REPLACE_COLUMN_NAME, renameColumnEntry.getKey().getName());
    assertNotNull(replaceColumnTypeEntry);
    assertEquals(
        REPLACE_COLUMN_TYPE, ((ColumnTypeVertex) replaceColumnTypeEntry.getKey()).getColumnType());
  }
  @Test
  public void databaseConnectionEstablishedCorrectly() {
    ISqlSchemaFrontend frontend = new H2SchemaFrontend(DATABASE_FILE_PATH);
    DirectedGraph<IStructureElement, DefaultEdge> schema = frontend.createSqlSchema();
    Set<ISqlElement> tables =
        SqlElementFactory.getSqlElementsOfType(SqlTableVertex.class, schema.vertexSet());
    Set<ISqlElement> columns =
        SqlElementFactory.getSqlElementsOfType(SqlColumnVertex.class, schema.vertexSet());
    ArrayList<ISqlElement> mandatoryColumns = new ArrayList<>();
    int tableCount = tables.size();
    int columnCount = columns.size();

    for (ISqlElement column : columns) {
      if (column.isMandatory() && !isPrimaryKey(schema, column)) {
        mandatoryColumns.add(column);
      }
    }

    assertNotNull(schema);
    assertEquals(7, tableCount);
    assertEquals(29, columnCount);
    assertEquals(
        7,
        TestHelper.getColumnWithConstraint(schema, IColumnConstraint.ConstraintType.PRIMARY_KEY)
            .size());
    assertEquals(1, mandatoryColumns.size());
    assertEquals("[Column] DEPARTMENTS.NAME", mandatoryColumns.get(0).toString());
  }
  @Test
  public void droppedColumnDetectedCorrectly() throws StructureGraphComparisonException {
    ISqlSchemaFrontend frontend1 = new H2SchemaFrontend(DATABASE_FILE_PATH);
    ISqlSchemaFrontend frontend2 = new H2SchemaFrontend(DROPPED_COLUMN_DATABASE_FILE_PATH);
    DirectedGraph<IStructureElement, DefaultEdge> schema1 = frontend1.createSqlSchema();
    DirectedGraph<IStructureElement, DefaultEdge> schema2 = frontend2.createSqlSchema();
    SqlSchemaComparer comparer = new SqlSchemaComparer(schema1, schema2);
    SqlSchemaComparisonResult result = comparer.comparisonResult;

    assertEquals(
        29,
        SqlElementFactory.getSqlElementsOfType(SqlColumnVertex.class, schema1.vertexSet()).size());
    assertEquals(
        28,
        SqlElementFactory.getSqlElementsOfType(SqlColumnVertex.class, schema2.vertexSet()).size());

    Entry<ISqlElement, SchemaModification> entry =
        TestHelper.getModificationOfType(result, SchemaModification.DELETE_COLUMN);

    assertNotNull(entry);
    assertEquals(DROPPED_COLUMN_NAME, entry.getKey().getName());
  }