Search in sources :

Example 21 with DataObjectSchema

use of com.emc.storageos.db.common.schema.DataObjectSchema 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 22 with DataObjectSchema

use of com.emc.storageos.db.common.schema.DataObjectSchema 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 23 with DataObjectSchema

use of com.emc.storageos.db.common.schema.DataObjectSchema in project coprhd-controller by CoprHD.

the class DbSchemaScanner method processClass.

@Override
protected void processClass(Class clazz) {
    DbSchema schema = null;
    if (DataObject.class.isAssignableFrom(clazz)) {
        if (_scannerInterceptor != null && _scannerInterceptor.isClassIgnored(clazz.getSimpleName())) {
            log.info("{} is ignored in schema due to interceptor", clazz.getSimpleName());
            return;
        }
        schema = new DataObjectSchema(clazz, _scannerInterceptor);
        if (clazz.isAnnotationPresent(DbKeyspace.class)) {
            DbKeyspace anno = (DbKeyspace) clazz.getAnnotation(DbKeyspace.class);
            if (DbKeyspace.Keyspaces.GLOBAL.equals(anno.value())) {
                geoSchemas.add(schema);
            }
        }
    } else if (TimeSeries.class.isAssignableFrom(clazz)) {
        schema = new TimeSeriesSchema(clazz);
    } else if (TimeSeriesSerializer.DataPoint.class.isAssignableFrom(clazz)) {
        schema = new DataPointSchema(clazz);
    } else {
        return;
    }
    schemas.addSchema(schema);
}
Also used : DbKeyspace(com.emc.storageos.db.client.model.DbKeyspace) DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) TimeSeries(com.emc.storageos.db.client.model.TimeSeries) DbSchema(com.emc.storageos.db.common.schema.DbSchema) TimeSeriesSchema(com.emc.storageos.db.common.schema.TimeSeriesSchema) DataPointSchema(com.emc.storageos.db.common.schema.DataPointSchema) TimeSeriesSerializer(com.emc.storageos.db.client.model.TimeSeriesSerializer)

Aggregations

DataObjectSchema (com.emc.storageos.db.common.schema.DataObjectSchema)23 DbSchemasDiff (com.emc.storageos.db.common.diff.DbSchemasDiff)21 Test (org.junit.Test)21 DbSchema (com.emc.storageos.db.common.schema.DbSchema)6 DbKeyspace (com.emc.storageos.db.client.model.DbKeyspace)1 TimeSeries (com.emc.storageos.db.client.model.TimeSeries)1 TimeSeriesSerializer (com.emc.storageos.db.client.model.TimeSeriesSerializer)1 DataPointSchema (com.emc.storageos.db.common.schema.DataPointSchema)1 DbSchemas (com.emc.storageos.db.common.schema.DbSchemas)1 TimeSeriesSchema (com.emc.storageos.db.common.schema.TimeSeriesSchema)1 Before (org.junit.Before)1