Search in sources :

Example 16 with DbSchemasDiff

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

the class DbSchemaCheckerTest method testGeoNewAnnotationOnExistingField.

@Test
public void testGeoNewAnnotationOnExistingField() {
    DbSchema srcGeoSchema = new DataObjectSchema(GeoClassUT.class);
    srcSchemas.addSchema(srcGeoSchema);
    tgtSchema = new DataObjectSchema(GeoNewAnnotationOnExistingField.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    tgtSchemas.addSchema(srcSchema);
    DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    // Adding index on existing field of Geo object is not allowed
    Assert.assertFalse(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchema(com.emc.storageos.db.common.schema.DbSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Example 17 with DbSchemasDiff

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

the class DbSchemaCheckerTest method testDuplicateCF.

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

Example 18 with DbSchemasDiff

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

the class DbSchemaCheckerTest method testRemoveNamedRelationIndex.

@Test
public void testRemoveNamedRelationIndex() {
    srcSchema = new DataObjectSchema(WithNamedRelationIndex.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 19 with DbSchemasDiff

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

the class DbSchemaCheckerTest method testNewFieldAnnotation.

@Test
public void testNewFieldAnnotation() {
    tgtSchema = new DataObjectSchema(NewFieldAnnotation.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 20 with DbSchemasDiff

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

the class DbSchemaCheckerTest method testRemovedField.

@Test
public void testRemovedField() {
    tgtSchema = new DataObjectSchema(RemovedField.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)

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