Search in sources :

Example 21 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class DbSchemaCheckerTest method testRemovedFieldAnnotation.

@Test
public void testRemovedFieldAnnotation() {
    tgtSchema = new DataObjectSchema(RemovedFieldAnnotation.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    Assert.assertFalse(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Example 22 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class DbSchemaCheckerTest method testRemovedFieldIndexAnnotation.

@Test
public void testRemovedFieldIndexAnnotation() {
    srcSchema = new DataObjectSchema(WithIndexAnnotation.class);
    srcSchema.setType(srcSchema.getType());
    srcSchemas.addSchema(srcSchema);
    tgtSchema = new DataObjectSchema(WithRemovedIndexAnnotation.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    Assert.assertFalse(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Example 23 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class DbSchemaCheckerTest method testNewPermittedFieldAnnotation.

@Test
public void testNewPermittedFieldAnnotation() {
    tgtSchema = new DataObjectSchema(NewPermittedFieldAnnotation.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    Assert.assertTrue(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
    Assert.assertTrue(diff.getNewClasses().isEmpty());
    Assert.assertTrue(diff.getNewFields().isEmpty());
    Assert.assertTrue(diff.getNewClassAnnotations().isEmpty());
    Assert.assertFalse(diff.getNewFieldAnnotations().isEmpty());
    Assert.assertEquals(diff.getNewFieldAnnotations().size(), 1);
    Assert.assertTrue(diff.getNewAnnotationValues().isEmpty());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Example 24 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class DbSchemaChecker method genGeoDiffs.

/**
 * Filter out all the non-geo db schemas from the spec and generate a diff
 * Note that some CFs might have been migrated from local db to geo db
 * So we need to grab a latest list of geo schemas from the current schema first.
 *
 * @param spec the db schema spec generated from the baseline file
 * @param geoSchemas the latest list of geo schemas from the current DbSchemas object
 * @return
 */
private static DbSchemasDiff genGeoDiffs(DbSchemas spec, List<DbSchema> geoSchemas) {
    // prepare a list of geo schema names
    List<String> geoSchemaNames = new ArrayList<>();
    for (DbSchema geoSchema : geoSchemas) {
        geoSchemaNames.add(geoSchema.getName());
    }
    List<DbSchema> specSchemaList = new ArrayList<>();
    for (DbSchema schema : spec.getSchemas()) {
        if (geoSchemaNames.contains(schema.getName())) {
            specSchemaList.add(schema);
        }
    }
    return new DbSchemasDiff(new DbSchemas(specSchemaList), new DbSchemas(geoSchemas));
}
Also used : DbSchema(com.emc.storageos.db.common.schema.DbSchema) ArrayList(java.util.ArrayList) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) DbSchemas(com.emc.storageos.db.common.schema.DbSchemas)

Aggregations

DbSchemasDiff (com.emc.storageos.db.common.diff.DbSchemasDiff)24 DataObjectSchema (com.emc.storageos.db.common.schema.DataObjectSchema)21 Test (org.junit.Test)21 DbSchema (com.emc.storageos.db.common.schema.DbSchema)6 DbSchemas (com.emc.storageos.db.common.schema.DbSchemas)3 ArrayList (java.util.ArrayList)2 MigrationStatus (com.emc.storageos.coordinator.client.model.MigrationStatus)1 FatalCoordinatorException (com.emc.storageos.coordinator.exceptions.FatalCoordinatorException)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 FatalDatabaseException (com.emc.storageos.db.exceptions.FatalDatabaseException)1 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 List (java.util.List)1 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)1