当前位置: 首页>>代码示例>>Java>>正文


Java Version类代码示例

本文整理汇总了Java中com.redhat.lightblue.metadata.Version的典型用法代码示例。如果您正苦于以下问题:Java Version类的具体用法?Java Version怎么用?Java Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Version类属于com.redhat.lightblue.metadata包,在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureIdFieldTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void ensureIdFieldTest() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollectionIndex2"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);
    e.getEntityInfo().setDefaultVersion("1.0.0");

    Assert.assertNull(e.getFields().getField("_id"));
    controller.beforeCreateNewSchema(null, e);

    SimpleField id = (SimpleField) e.getFields().getField("_id");
    Assert.assertNotNull(id);
    Assert.assertEquals(StringType.TYPE, id.getType());
    Assert.assertEquals(0, id.getConstraints().size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:21,代码来源:MongoCRUDControllerTest.java

示例2: ensureIdIndexTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void ensureIdIndexTest() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollectionIndex2"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);
    e.getEntityInfo().setDefaultVersion("1.0.0");

    Assert.assertEquals(0, e.getEntityInfo().getIndexes().getIndexes().size());
    controller.beforeUpdateEntityInfo(null, e.getEntityInfo(), false);

    Assert.assertEquals(1, e.getEntityInfo().getIndexes().getIndexes().size());
    Assert.assertEquals("_id", e.getEntityInfo().getIndexes().getIndexes().get(0).getFields().get(0).getField().toString());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:19,代码来源:MongoCRUDControllerTest.java

示例3: createTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void createTest() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);

    // At this point, there should not be a collectionVersion doc
    DBCollection coll = db.getCollection(MongoMetadata.DEFAULT_METADATA_COLLECTION);
    Assert.assertNull(coll.findOne(new BasicDBObject("_id", "collectionVersion")));

    md.createNewMetadata(e);

    Assert.assertNotNull(coll.findOne(new BasicDBObject("_id", "collectionVersion")));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:20,代码来源:CacheTest.java

示例4: defaultVersionTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void defaultVersionTest() throws Exception {

    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);
    e.getEntityInfo().setDefaultVersion("1.0.0");
    md.createNewMetadata(e);

    EntityMetadata g = md.getEntityMetadata("testEntity", null);
    Assert.assertEquals("1.0.0", g.getVersion().getValue());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:18,代码来源:MongoMetadataTest.java

示例5: createMd2Test

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
/**
 * Issue #13: if you create it twice, the error thrown for the second one
 * cleans up the first
 */
@Test
public void createMd2Test() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);
    md.createNewMetadata(e);
    Assert.assertNotNull(md.getEntityMetadata("testEntity", "1.0.0"));
    try {
        md.createNewMetadata(e);
        Assert.fail();
    } catch (Exception x) {
    }
    Assert.assertNotNull(md.getEntityMetadata("testEntity", "1.0.0"));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:24,代码来源:MongoMetadataTest.java

示例6: testCollectionName

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void testCollectionName() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "test-Collection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);
    try {
        md.createNewMetadata(e);
        Assert.fail();
    } catch (Error x) {
    }

    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    md.createNewMetadata(e);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:20,代码来源:MongoMetadataTest.java

示例7: updateStatusTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void updateStatusTest() throws Exception {
    EntityMetadata e2 = new EntityMetadata("testEntity");
    e2.setVersion(new Version("1.1.0", null, "some text blah blah"));
    e2.setStatus(MetadataStatus.ACTIVE);
    e2.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e2.getFields().put(new SimpleField("field1", StringType.TYPE));
    md.createNewMetadata(e2);
    EntityMetadata g = md.getEntityMetadata("testEntity", "1.1.0");
    Assert.assertEquals(MetadataStatus.ACTIVE, g.getStatus());

    md.setMetadataStatus("testEntity", "1.1.0", MetadataStatus.DEPRECATED, "disable testEntity");
    EntityMetadata g1 = md.getEntityMetadata("testEntity", "1.1.0");
    Assert.assertEquals(e2.getVersion().getValue(), g1.getVersion().getValue());
    Assert.assertEquals(MetadataStatus.DEPRECATED, g1.getStatus());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:17,代码来源:MongoMetadataTest.java

示例8: disabledDefaultUpdateTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void disabledDefaultUpdateTest() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    e.getEntityInfo().setDefaultVersion("1.0.0");
    md.createNewMetadata(e);
    EntityMetadata g1 = md.getEntityMetadata("testEntity", "1.0.0");
    Assert.assertEquals(e.getVersion().getValue(), g1.getVersion().getValue());
    Assert.assertEquals(MetadataStatus.ACTIVE, g1.getStatus());
    try {
        md.setMetadataStatus("testEntity", "1.0.0", MetadataStatus.DISABLED, "disabling the default version");
        Assert.fail("expected " + MongoMetadataConstants.ERR_DISABLED_DEFAULT_VERSION);
    } catch (Error ex) {
        Assert.assertEquals(MongoMetadataConstants.ERR_DISABLED_DEFAULT_VERSION, ex.getErrorCode());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:20,代码来源:MongoMetadataTest.java

示例9: unknownVersionTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void unknownVersionTest() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    md.createNewMetadata(e);
    try {
        md.getEntityMetadata("testEntity", "1.1.0");
        Assert.fail("expected " + MongoMetadataConstants.ERR_UNKNOWN_VERSION);
    } catch (Error ex) {
        Assert.assertEquals(MongoMetadataConstants.ERR_UNKNOWN_VERSION, ex.getErrorCode());
    }

}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:17,代码来源:MongoMetadataTest.java

示例10: updateEntityInfo

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void updateEntityInfo() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);

    md.createNewMetadata(e);

    EntityInfo ei = new EntityInfo("testEntity");
    ArrayField af = new ArrayField("arrField", new SimpleArrayElement(StringType.TYPE));
    e.getFields().put(af);
    IndexSortKey isk = new IndexSortKey(new Path("arrField.*"), true, true);
    ei.getIndexes().add(new Index(isk));
    ei.setDataStore(new MongoDataStore(null, null, "somethingelse"));
    md.updateEntityInfo(ei);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:22,代码来源:MongoMetadataTest.java

示例11: createEntityInfo_validates

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void createEntityInfo_validates() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);
    SimpleField s = new SimpleField("z", StringType.TYPE);
    ArrayList<FieldConstraint> enumsc = new ArrayList<>();
    EnumConstraint enumc = new EnumConstraint();
    enumc.setName("en");
    enumsc.add(enumc);
    s.setConstraints(enumsc);
    e.getFields().put(s);
    try {
        md.createNewMetadata(e);
        Assert.fail();
    } catch (Error x) {
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:24,代码来源:MongoMetadataTest.java

示例12: updateEntityInfo_noEntity

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void updateEntityInfo_noEntity() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollection"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);
    md.createNewMetadata(e);

    EntityInfo ei = new EntityInfo("NottestEntity");
    ei.setDataStore(new MongoDataStore(null, null, "somethingelse"));
    try {
        md.updateEntityInfo(ei);
        Assert.fail();
    } catch (Error ex) {
        Assert.assertEquals(MongoMetadataConstants.ERR_MISSING_ENTITY_INFO, ex.getErrorCode());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:22,代码来源:MongoMetadataTest.java

示例13: invalidDefaultVersionTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void invalidDefaultVersionTest() throws Exception {
    //with non-existant default.
    EntityMetadata eDefault = new EntityMetadata("testDefaultEntity");
    eDefault.setVersion(new Version("1.0.0", null, "some text blah blah"));
    eDefault.setStatus(MetadataStatus.DISABLED);
    eDefault.setDataStore(new MongoDataStore(null, null, "testCollection"));
    eDefault.getFields().put(new SimpleField("field1", StringType.TYPE));
    eDefault.getEntityInfo().setDefaultVersion("blah");
    try {
        md.createNewMetadata(eDefault);
        Assert.fail("expected " + MetadataConstants.ERR_INVALID_DEFAULT_VERSION);
    } catch (Error ex) {
        Assert.assertEquals(MetadataConstants.ERR_INVALID_DEFAULT_VERSION, ex.getErrorCode());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:17,代码来源:MongoMetadataTest.java

示例14: generateSchema

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
private EntitySchema generateSchema(BeanMirror beanMirror, Optional<EntitySchema> maybeOriginal) {
  EntitySchema schema = new EntitySchema(beanMirror.getEntityName());
  schema.setStatus(MetadataStatus.ACTIVE);

  maybeOriginal.ifPresent(original -> {
    EntityAccess access = schema.getAccess();
    EntityAccess originalAccess = original.getAccess();

    access.getDelete().setRoles(originalAccess.getDelete());
    access.getInsert().setRoles(originalAccess.getInsert());
    access.getFind().setRoles(originalAccess.getFind());
    access.getUpdate().setRoles(originalAccess.getUpdate());

    schema.setStatusChangeLog(original.getStatusChangeLog());
    schema.setStatus(original.getStatus());
  });

  beanMirror.getVersion().ifPresent(versionMirror -> {
    Collection<String> extendsVersionsCollection = versionMirror.getExtendsVersions();
    String[] extendsVersionsArr = extendsVersionsCollection.isEmpty()
        ? null
        : extendsVersionsCollection.toArray(new String[extendsVersionsCollection.size()]);

    schema.setVersion(
        new Version(versionMirror.getVersion(), extendsVersionsArr, versionMirror.getChangelog()));
  });

  addFieldsFromBeanMirror(beanMirror, schema.getFields(),
      maybeOriginal.map(EntitySchema::getFields));

  return schema;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-java-generator,代码行数:33,代码来源:MetadataGenerator.java

示例15: entityIndexCreationTest

import com.redhat.lightblue.metadata.Version; //导入依赖的package包/类
@Test
public void entityIndexCreationTest() throws Exception {
    EntityMetadata e = new EntityMetadata("testEntity");
    e.setVersion(new Version("1.0.0", null, "some text blah blah"));
    e.setStatus(MetadataStatus.ACTIVE);
    e.setDataStore(new MongoDataStore(null, null, "testCollectionIndex1"));
    e.getFields().put(new SimpleField("field1", StringType.TYPE));
    ObjectField o = new ObjectField("field2");
    o.getFields().put(new SimpleField("x", IntegerType.TYPE));
    e.getFields().put(o);
    e.getEntityInfo().setDefaultVersion("1.0.0");
    Index index = new Index();
    index.setName("testIndex");
    index.setUnique(true);
    List<IndexSortKey> indexFields = new ArrayList<>();
    //TODO actually parse $asc/$desc here
    indexFields.add(new IndexSortKey(new Path("field1"), true));
    index.setFields(indexFields);
    List<Index> indexes = new ArrayList<>();
    indexes.add(index);
    e.getEntityInfo().getIndexes().setIndexes(indexes);
    controller.afterUpdateEntityInfo(null, e.getEntityInfo(), false);

    DBCollection entityCollection = db.getCollection("testCollectionIndex1");

    boolean foundIndex = false;

    for (DBObject mongoIndex : entityCollection.getIndexInfo()) {
        if ("testIndex".equals(mongoIndex.get("name"))) {
            if (mongoIndex.get("key").toString().contains("field1")) {
                foundIndex = true;
            }
        }
    }
    Assert.assertTrue(foundIndex);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:37,代码来源:MongoCRUDControllerTest.java


注:本文中的com.redhat.lightblue.metadata.Version类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。