@Test public void replaceLobWithTable() throws StructureGraphComparisonException { ISqlSchemaFrontend frontend1 = new H2SchemaFrontend(DATABASE_FILE_PATH); ISqlSchemaFrontend frontend2 = new H2SchemaFrontend(REPLACE_LOB_WITH_TABLE_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( 33, SqlElementFactory.getSqlElementsOfType(SqlColumnVertex.class, schema2.vertexSet()).size()); for (Entry<ISqlElement, SchemaModification> entry : result.getModifications().entrySet()) { if (entry.getValue() == SchemaModification.CREATE_TABLE) { assertEquals(REPLACE_LOB_WITH_TABLE, entry.getKey().getName()); } if (entry.getValue() == SchemaModification.DELETE_COLUMN) { assertEquals(REPLACE_LOB_WITH_COLUMN, entry.getKey().getName()); } } }
@Test public void droppedTableDetectedCorrectly() throws StructureGraphComparisonException { ISqlSchemaFrontend frontend1 = new H2SchemaFrontend(DATABASE_FILE_PATH); ISqlSchemaFrontend frontend2 = new H2SchemaFrontend(DROPPED_TABLE_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( 7, SqlElementFactory.getSqlElementsOfType(SqlTableVertex.class, schema1.vertexSet()).size()); assertEquals( 6, SqlElementFactory.getSqlElementsOfType(SqlTableVertex.class, schema2.vertexSet()).size()); for (Entry<ISqlElement, SchemaModification> entry : result.getModifications().entrySet()) { if (entry.getValue() == SchemaModification.DELETE_TABLE) { assertEquals(SchemaModification.DELETE_TABLE, entry.getValue()); assertEquals(DROPPED_TABLE_NAME, entry.getKey().getName()); } } }