本文整理汇总了Java中com.redhat.lightblue.metadata.EntityMetadata.setVersion方法的典型用法代码示例。如果您正苦于以下问题:Java EntityMetadata.setVersion方法的具体用法?Java EntityMetadata.setVersion怎么用?Java EntityMetadata.setVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.lightblue.metadata.EntityMetadata
的用法示例。
在下文中一共展示了EntityMetadata.setVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unknownVersionTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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());
}
}
示例2: ensureIdIndexTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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());
}
示例3: invalidDefaultVersionTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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());
}
}
示例4: defaultVersionTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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());
}
示例5: createMd2Test
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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"));
}
示例6: testCollectionName
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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);
}
示例7: createEntityInfo_validates
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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) {
}
}
示例8: snapshotUpdates
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
@Test
public void snapshotUpdates() throws Exception {
EntityMetadata e = new EntityMetadata("testEntity");
e.setVersion(new Version("1.0.0-SNAPSHOT", 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);
EntityMetadata g = md.getEntityMetadata("testEntity", "1.0.0-SNAPSHOT");
Assert.assertNotNull("Can't retrieve entity", g);
Assert.assertEquals(e.getName(), g.getName());
Assert.assertEquals(e.getVersion().getValue(), g.getVersion().getValue());
Version[] v = md.getEntityVersions("testEntity");
Assert.assertEquals(1, v.length);
Assert.assertEquals("1.0.0-SNAPSHOT", v[0].getValue());
e.setVersion(new Version("1.0.0-SNAPSHOT", null, "blahblahyadayada"));
md.createNewSchema(e);
v = md.getEntityVersions("testEntity");
Assert.assertEquals(1, v.length);
try {
md.createNewMetadata(e);
Assert.fail();
} catch (Exception x) {
}
}
示例9: entityIndexCreationTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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);
}
示例10: multipleVersions
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
@Test
public void multipleVersions() 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);
EntityMetadata g = md.getEntityMetadata("testEntity", "1.0.0");
Assert.assertNotNull("Can't retrieve entity", g);
Assert.assertEquals(e.getName(), g.getName());
Assert.assertEquals(e.getVersion().getValue(), g.getVersion().getValue());
Version[] v = md.getEntityVersions("testEntity");
Assert.assertEquals(1, v.length);
Assert.assertEquals("1.0.0", v[0].getValue());
e.setVersion(new Version("2.0.0", null, "blahblahyadayada"));
md.createNewSchema(e);
v = md.getEntityVersions("testEntity");
Assert.assertEquals(2, v.length);
try {
md.createNewMetadata(e);
Assert.fail();
} catch (Exception x) {
}
}
示例11: disabledDefaultCreationTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
@Test
public void disabledDefaultCreationTest() throws Exception {
EntityMetadata e = new EntityMetadata("testEntity");
e.setVersion(new Version("1.0.0", null, "some text blah blah"));
e.setStatus(MetadataStatus.DISABLED);
e.setDataStore(new MongoDataStore(null, null, "testCollection"));
e.getFields().put(new SimpleField("field1", StringType.TYPE));
e.getEntityInfo().setDefaultVersion("1.0.0");
try {
md.createNewMetadata(e);
Assert.fail("expected " + MongoMetadataConstants.ERR_DISABLED_DEFAULT_VERSION);
} catch (Error ex) {
Assert.assertEquals(MongoMetadataConstants.ERR_DISABLED_DEFAULT_VERSION, ex.getErrorCode());
}
}
示例12: nonsnapshotUpdateFails
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
@Test
public void nonsnapshotUpdateFails() 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);
EntityMetadata g = md.getEntityMetadata("testEntity", "1.0.0");
Assert.assertNotNull("Can't retrieve entity", g);
Assert.assertEquals(e.getName(), g.getName());
Assert.assertEquals(e.getVersion().getValue(), g.getVersion().getValue());
Version[] v = md.getEntityVersions("testEntity");
Assert.assertEquals(1, v.length);
Assert.assertEquals("1.0.0", v[0].getValue());
e.setVersion(new Version("1.0.0", null, "blahblahyadayada"));
try {
md.createNewSchema(e);
Assert.fail();
} catch (Exception x) {
}
v = md.getEntityVersions("testEntity");
Assert.assertEquals(1, v.length);
}
示例13: cacheTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
@Test
public void cacheTest() 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);
DBCollection coll = db.getCollection(MongoMetadata.DEFAULT_METADATA_COLLECTION);
// Lookup should fail
Assert.assertNull(cache.lookup(coll, "testEntity", "1.0.0"));
md.getEntityMetadata("testEntity", "1.0.0");
// Lookup should not fail
Assert.assertNotNull(cache.lookup(coll, "testEntity", "1.0.0"));
Thread.sleep(51);
// Lookup shoult not fail
Assert.assertNotNull(cache.lookup(coll, "testEntity", "1.0.0"));
// Update the version in db
coll.update(new BasicDBObject("_id", "collectionVersion"), new BasicDBObject("$inc", new BasicDBObject("collectionVersion", 1)));
Thread.sleep(51);
// Lookup will fail, detect change
Assert.assertNull(cache.lookup(coll, "testEntity", "1.0.0"));
}
示例14: createMdTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
@Test
public void createMdTest() 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.setDescription("description");
o.getFields().put(new SimpleField("x", IntegerType.TYPE));
e.getFields().put(o);
md.createNewMetadata(e);
EntityMetadata g = md.getEntityMetadata("testEntity", "1.0.0");
Assert.assertNotNull("Can't retrieve entity", g);
Assert.assertEquals(e.getName(), g.getName());
Assert.assertEquals(e.getVersion().getValue(), g.getVersion().getValue());
Assert.assertEquals(e.getVersion().getChangelog(), g.getVersion().getChangelog());
Assert.assertEquals(e.getStatus(), g.getStatus());
Assert.assertEquals((e.resolve(new Path("field1"))).getType(),
(g.resolve(new Path("field1"))).getType());
Assert.assertEquals((e.resolve(new Path("field2.x"))).getType(),
(g.resolve(new Path("field2.x"))).getType());
Assert.assertEquals("description not set", o.getDescription(), e.getFields().getField(o.getName()).getDescription());
Version[] v = md.getEntityVersions("testEntity");
Assert.assertEquals(1, v.length);
Assert.assertEquals("1.0.0", v[0].getValue());
String[] names = md.getEntityNames();
Assert.assertEquals(1, names.length);
Assert.assertEquals("testEntity", names[0]);
}
示例15: createMetadata
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
private EntityMetadata createMetadata() {
EntityMetadata e = new EntityMetadata("testEntity");
e.setVersion(new Version("1.0.0", null, "some text blah blah"));
e.setStatus(MetadataStatus.ACTIVE);
e.getFields().put(new SimpleField("_id", StringType.TYPE));
e.getFields().put(new SimpleField("objectType", StringType.TYPE));
e.setDataStore(new MongoDataStore(null, null, "testCollectionIndex1"));
e.getFields().put(new SimpleField("field1", StringType.TYPE));
e.getFields().put(new SimpleField("field3", StringType.TYPE));
ObjectField o = new ObjectField("field2");
o.getFields().put(new SimpleField("x", StringType.TYPE));
SimpleArrayElement saSub = new SimpleArrayElement(StringType.TYPE);
ArrayField afSub = new ArrayField("subArrayField", saSub);
o.getFields().put(afSub);
ObjectArrayElement oaObject = new ObjectArrayElement();
oaObject.getFields().put(new SimpleField("x", StringType.TYPE));
SimpleArrayElement saSubSub = new SimpleArrayElement(StringType.TYPE);
ArrayField afSubSub = new ArrayField("arraySubObj", saSubSub);
oaObject.getFields().put(afSubSub);
ObjectArrayElement objSubSub = new ObjectArrayElement();
objSubSub.getFields().put(new SimpleField("y", StringType.TYPE));
ArrayField objSubSubField = new ArrayField("arraySubObj2", objSubSub);
oaObject.getFields().put(objSubSubField);
ArrayField afObject = new ArrayField("arrayObj", oaObject);
e.getFields().put(afObject);
e.getFields().put(o);
SimpleArrayElement sa = new SimpleArrayElement(StringType.TYPE);
ArrayField af = new ArrayField("arrayField", sa);
e.getFields().put(af);
e.getEntityInfo().setDefaultVersion("1.0.0");
e.getEntitySchema().getAccess().getInsert().setRoles("anyone");
e.getEntitySchema().getAccess().getFind().setRoles("anyone");
e.getEntitySchema().getAccess().getUpdate().setRoles("anyone");
return e;
}