本文整理汇总了Java中com.redhat.lightblue.metadata.EntityMetadata.setStatus方法的典型用法代码示例。如果您正苦于以下问题:Java EntityMetadata.setStatus方法的具体用法?Java EntityMetadata.setStatus怎么用?Java EntityMetadata.setStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.lightblue.metadata.EntityMetadata
的用法示例。
在下文中一共展示了EntityMetadata.setStatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: 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());
}
}
示例3: createTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的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")));
}
示例4: 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) {
}
}
示例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: 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);
}
示例8: 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());
}
}
示例9: saneIndex
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
@Test
public void saneIndex() 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");
Index index = new Index();
index.setName("testIndex1");
index.setUnique(true);
List<IndexSortKey> indexFields = new ArrayList<>();
indexFields.add(new IndexSortKey(new Path("field1"), true));
index.setFields(indexFields);
List<Index> indexes = new ArrayList<>();
indexes.add(index);
index = new Index();
index.setName("testIndex2");
index.setUnique(false);
indexFields = new ArrayList<>();
indexFields.add(new IndexSortKey(new Path("field1"), true));
index.setFields(indexFields);
indexes.add(index);
e.getEntityInfo().getIndexes().setIndexes(indexes);
try {
controller.beforeUpdateEntityInfo(null, e.getEntityInfo(), false);
Assert.fail();
} catch (Exception x) {
}
}
示例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: 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"));
}
示例12: 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]);
}
示例13: 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) {
}
}
示例14: 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;
}
示例15: createMetadataWithDocVer
import com.redhat.lightblue.metadata.EntityMetadata; //导入方法依赖的package包/类
private EntityMetadata createMetadataWithDocVer() {
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));
SimpleField f=new SimpleField("docver",StringType.TYPE);
f.getProperties().put(ResultMetadata.MD_PROPERTY_DOCVER,Boolean.TRUE);
e.getFields().put(f);
ObjectField x=new ObjectField("resultMetadata");
x.getProperties().put(ResultMetadata.MD_PROPERTY_RESULT_METADATA,Boolean.TRUE);
e.getFields().put(x);
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;
}