本文整理汇总了Java中com.redhat.lightblue.metadata.EntityMetadata类的典型用法代码示例。如果您正苦于以下问题:Java EntityMetadata类的具体用法?Java EntityMetadata怎么用?Java EntityMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityMetadata类属于com.redhat.lightblue.metadata包,在下文中一共展示了EntityMetadata类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testTranslate_SimpleField_BigDecimalType
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_BigDecimalType() throws JSONException{
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
new Attribute("key", String.valueOf(Double.MAX_VALUE))
});
EntityMetadata md = fakeEntityMetadata("fakeMetadata",
new SimpleField("key", BigDecimalType.TYPE)
);
JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
assertNotNull(document);
JSONAssert.assertEquals(
"{\"key\":" + String.valueOf(Double.MAX_VALUE) + ",\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
document.toString(),
true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:20,代码来源:ResultTranslatorToJsonTest.java
示例2: testTranslate_SimpleArrayElement_CountNotAskedFor
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
/**
* Both the array itself and a count field should be returned even though the count was not asked for.
* @see #testTranslate_SimpleArrayElement_CountAskedFor()
*/
@Test
public void testTranslate_SimpleArrayElement_CountNotAskedFor() throws JSONException{
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
new Attribute("objectClass", Arrays.asList("top", "person", "organizationalPerson", "inetOrgPerson"))
});
EntityMetadata md = fakeEntityMetadata("fakeMetadata",
new ArrayField("objectClass", new SimpleArrayElement(StringType.TYPE))
);
JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
assertNotNull(document);
JSONAssert.assertEquals(
"{\"objectClass\":[\"top\",\"person\",\"organizationalPerson\",\"inetOrgPerson\"],\"objectClass#\":4,\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
document.toString(),
true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:24,代码来源:ResultTranslatorToJsonTest.java
示例3: testTranslate_SimpleField_Boolean
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_Boolean() throws JSONException{
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
new Attribute("key", "true")
});
EntityMetadata md = fakeEntityMetadata("fakeMetadata",
new SimpleField("key", BooleanType.TYPE)
);
JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
assertNotNull(document);
JSONAssert.assertEquals(
"{\"key\":true,\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
document.toString(),
true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:20,代码来源:ResultTranslatorToJsonTest.java
示例4: testTranslate_AttributeDoesNotExist
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void testTranslate_AttributeDoesNotExist() throws JSONException{
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{});
EntityMetadata md = fakeEntityMetadata("fakeMetadata",
new SimpleField("absentAttribute", StringType.TYPE)
);
JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
assertNotNull(document);
JSONAssert.assertEquals(
"{\"absentAttribute\":null,\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
document.toString(),
true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:18,代码来源:ResultTranslatorToJsonTest.java
示例5: testTranslate_SimpleArrayElement_CountAskedFor
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
/**
* Essentially the same, but the count is specifically asked for. The only real different is that the count field
* should be skipped over during processing.
* @see #testTranslate_SimpleArrayElement_CountNotAskedFor()
*/
@Test
public void testTranslate_SimpleArrayElement_CountAskedFor() throws JSONException{
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
new Attribute("objectClass", Arrays.asList("top", "person", "organizationalPerson", "inetOrgPerson"))
});
EntityMetadata md = fakeEntityMetadata("fakeMetadata",
new ArrayField("objectClass", new SimpleArrayElement(StringType.TYPE)),
new SimpleField("objectClass#", IntegerType.TYPE)
);
JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
assertNotNull(document);
JSONAssert.assertEquals(
"{\"objectClass\":[\"top\",\"person\",\"organizationalPerson\",\"inetOrgPerson\"],\"objectClass#\":4,\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
document.toString(),
true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:26,代码来源:ResultTranslatorToJsonTest.java
示例6: testTranslate_SimpleField_BigIntegerType
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_BigIntegerType() throws JSONException{
SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
new Attribute("key", BigInteger.ZERO.toString())
});
EntityMetadata md = fakeEntityMetadata("fakeMetadata",
new SimpleField("key", BigIntegerType.TYPE)
);
JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);
assertNotNull(document);
JSONAssert.assertEquals(
"{\"key\":" + BigInteger.ZERO + ",\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
document.toString(),
true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:20,代码来源:ResultTranslatorToJsonTest.java
示例7: addArrayIdentities
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
private Projection addArrayIdentities(Projection p,EntityMetadata md) {
// If an array is included in the projection, make sure its identity is also included
Map<Path,List<Path>> arrayIdentities=md.getEntitySchema().getArrayIdentities();
List<Projection> addFields=new ArrayList<>();
for(Map.Entry<Path,List<Path>> entry:arrayIdentities.entrySet()) {
Path array=entry.getKey();
List<Path> identities=new ArrayList<>();
for(Path x:entry.getValue())
identities.add(new Path(array,new Path(Path.ANYPATH,x)));
if(isProjected(array,p)) {
for(Path id:identities) {
if(!isProjected(id,p)) {
addFields.add(new FieldProjection(id,true,true));
}
}
}
}
if(!addFields.isEmpty()) {
LOGGER.debug("Excluded array identities are added to projection:{}",addFields);
// Need to first add the original projection, then the included fields.
// This is order sensitive
return Projection.add(p,new ProjectionList(addFields));
} else
return p;
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:27,代码来源:NotificationHook.java
示例8: compareDocs
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
/**
* Compares the pre- and post- documents after they are passed
* through the watchProjector, and returns the delta
*/
private DocComparator.Difference<JsonNode> compareDocs(EntityMetadata metadata,
JsonDoc preDoc,
JsonDoc postDoc,
Projector watchProjector)
throws Exception {
JsonDoc watchedPostDoc = watchProjector.project(postDoc, jsonNodeFactory);
JsonDoc watchedPreDoc = preDoc == null
? new JsonDoc(jsonNodeFactory.objectNode())
: watchProjector.project(preDoc, jsonNodeFactory);
// Compute diff
JsonCompare cmp=metadata.getDocComparator();
LOGGER.debug("Array identities:{}",cmp.getArrayIdentities());
LOGGER.debug("Pre:{}, Post:{}",watchedPreDoc.getRoot(),watchedPostDoc.getRoot());
DocComparator.Difference<JsonNode> diff=cmp.
compareNodes(watchedPreDoc.getRoot(),watchedPostDoc.getRoot());
LOGGER.debug("Diff: {}",diff);
return diff;
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:24,代码来源:NotificationHook.java
示例9: shouldNotCreateNotificationForFindOperations
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldNotCreateNotificationForFindOperations() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode post = loadJsonNode("userdata.json");
HookConfiguration cfg = NotificationHookConfiguration.watchingEverythingAndIncludingNothing();
List<HookDoc> docs = new ArrayList<>();
// Pre doc is null in find ops: see com.redhat.lightblue.hooks.HookManager:73
HookDoc doc = new HookDoc(md,null,new JsonDoc(post),CRUDOperation.FIND,"me");
docs.add(doc);
hook.processHook(md, cfg, docs);
Assert.assertNull(insertCapturingMediator.capturedInsert);
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:17,代码来源:NotificationHookTest.java
示例10: shouldNotCreateNotificationIfNothingChangesInWatchedFields
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldNotCreateNotificationIfNothingChangesInWatchedFields() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
HookConfiguration cfg = NotificationHookConfiguration.watchingEverythingAndIncludingNothing();
List<HookDoc> docs = new ArrayList<>();
HookDoc doc = new HookDoc(md,new JsonDoc(pre),new JsonDoc(post),CRUDOperation.UPDATE,"me");
docs.add(doc);
hook.processHook(md, cfg, docs);
Assert.assertNull(insertCapturingMediator.capturedInsert);
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:17,代码来源:NotificationHookTest.java
示例11: shouldNotCreateNotificationsIfSomethingNotWatchedChanged
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldNotCreateNotificationsIfSomethingNotWatchedChanged() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'personalInfo','recursive':1}"),
null,
false);
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("login"), JsonNodeFactory.instance.textNode("blah"), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
hook.processHook(md,cfg,docs);
Assert.assertNull(insertCapturingMediator.capturedInsert);
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:22,代码来源:NotificationHookTest.java
示例12: shouldNotCreateNotificationForInsertWhichDoesNotIncludeAnyWatchedFields
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldNotCreateNotificationForInsertWhichDoesNotIncludeAnyWatchedFields() throws Exception {
EntityMetadata md = getMd("usermd.json");
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'contactPermissions','recursive':1}"),
null,
false);
JsonNode post = loadJsonNode("userdataWithoutContactPermissions.json");
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, null, new JsonDoc(post), CRUDOperation.INSERT, "me");
docs.add(doc);
hook.processHook(md,cfg,docs);
Assert.assertNull(insertCapturingMediator.capturedInsert);
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:20,代码来源:NotificationHookTest.java
示例13: shouldCaptureWatchedNonContainerNodeChangesInEntityData
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldCaptureWatchedNonContainerNodeChangesInEntityData() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("sites.0.streetAddress.city"), JsonNodeFactory.instance.textNode("blah"), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'sites','recursive':1}"),
projection("{'field':'sites','recursive':1}"),
false);
hook.processHook(md, cfg, docs);
Assert.assertNotNull(insertCapturingMediator.capturedInsert);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
Assert.assertEquals("sites.0.streetAddress.city",data.get("updatedPaths").get(0).asText());
Assert.assertEquals(1,data.get("updatedPaths").size());
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:23,代码来源:NotificationHookTest.java
示例14: shouldOnlyIncludeWhatChangedOfArrayElementIfElementIdentityNotWatched
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldOnlyIncludeWhatChangedOfArrayElementIfElementIdentityNotWatched()
throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("sites.0.streetAddress.city"), JsonNodeFactory.instance.textNode("blah"), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'sites.*.streetAddress.city','recursive':1}"),
null,
false);
hook.processHook(md, cfg, docs);
Assert.assertNotNull(insertCapturingMediator.capturedInsert);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
Truth.assertThat(
Iterables.transform(data.get("updatedPaths"), toTextValue()))
.containsExactly("sites.0.streetAddress.city");
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:26,代码来源:NotificationHookTest.java
示例15: shouldCaptureWatchedArrayElementRemovalInRemovedEntityDataAndRemovedElements
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldCaptureWatchedArrayElementRemovalInRemovedEntityDataAndRemovedElements() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post,new Path("sites.1"),null,true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'sites','recursive':1}"),
projection("{'field':'sites','recursive':1}"),
false);
hook.processHook(md, cfg, docs);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
Assert.assertEquals(1,data.get("removedPaths").size());
Assert.assertEquals("sites.1",data.get("removedPaths").get(0).asText());
// Check we also have sites.1 contents
assertEntityDataValueEquals( (ArrayNode)data.get("removedEntityData"),"sites.1.siteId","2");
assertEntityDataValueEquals( (ArrayNode)data.get("removedEntityData"),"sites.1.siteType","billing");
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:26,代码来源:NotificationHookTest.java
示例16: shouldSetPrivilegedClientIdOnRequest
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldSetPrivilegedClientIdOnRequest() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode data = loadJsonNode("userdata.json");
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'*','recursive':1}"), null, false);
List<HookDoc> docs = new ArrayList<>();
HookDoc doc = new HookDoc(md,null,new JsonDoc(data),CRUDOperation.INSERT,"me");
docs.add(doc);
hook.processHook(md, cfg, docs);
ClientIdentification clientId = insertCapturingMediator.capturedInsert.getClientId();
Assert.assertNotNull(clientId);
Assert.assertTrue(clientId.isUserInRole("some-role-for-notification"));
Assert.assertTrue(clientId.isUserInRole("lb-notification-insert"));
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:21,代码来源:NotificationHookTest.java
示例17: shouldIncludeRemovedEntityDataForModifications
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldIncludeRemovedEntityDataForModifications() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode pre = loadJsonNode("userdata.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("sites.0.streetAddress.city"),
JsonNodeFactory.instance.textNode("new city"), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, new JsonDoc(pre), new JsonDoc(post), CRUDOperation.UPDATE, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'sites','recursive':1}"),
projection("{'field':'sites','recursive':1}"),
false);
hook.processHook(md, cfg, docs);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
Assert.assertEquals(0,data.get("removedPaths").size());
// Check we also have sites.1 contents
assertEntityDataValueEquals((ArrayNode) data.get("removedEntityData"),
"sites.0.streetAddress.city", "Denver");
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:26,代码来源:NotificationHookTest.java
示例18: shouldCaptureNullsAsNull
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
@Test
public void shouldCaptureNullsAsNull() throws Exception {
EntityMetadata md = getMd("usermd.json");
JsonNode post = loadJsonNode("userdata.json");
JsonDoc.modify(post, new Path("personalInfo.company"),
JsonNodeFactory.instance.nullNode(), true);
List<HookDoc> docs= new ArrayList<>();
HookDoc doc = new HookDoc(md, null, new JsonDoc(post), CRUDOperation.INSERT, "me");
docs.add(doc);
HookConfiguration cfg = new NotificationHookConfiguration(
projection("{'field':'personalInfo','recursive':1}"),
projection("{'field':'personalInfo','recursive':1}"),
false);
hook.processHook(md, cfg, docs);
JsonNode data=insertCapturingMediator.capturedInsert.getEntityData();
// Check we also have sites.1 contents
assertEntityDataValueEquals((ArrayNode) data.get("entityData"), "personalInfo.company", null);
}
开发者ID:esbtools,项目名称:lightblue-notification-hook,代码行数:23,代码来源:NotificationHookTest.java
示例19: generateMetadata
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的package包/类
private static EntityMetadata generateMetadata(Class classForName, Path metadataJsonPath) {
if (Files.exists(metadataJsonPath)) {
println(metadataJsonPath + " already exists, updating...");
final EntityMetadata existing;
try {
JsonNode existingJsonNode = mapper.readTree(Files.readAllBytes(metadataJsonPath));
existing = parser.parseEntityMetadata(existingJsonNode);
} catch (Exception e) {
e.printStackTrace();
println("Failed to parse existing metadata.");
println("Generating new metadata instead of updating.");
return generator.generateMetadata(classForName);
}
return generator.updateMetadata(existing, classForName);
}
return generator.generateMetadata(classForName);
}
开发者ID:lightblue-platform,项目名称:lightblue-java-generator,代码行数:24,代码来源:Main.java
示例20: updateStatusTest
import com.redhat.lightblue.metadata.EntityMetadata; //导入依赖的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
注:本文中的com.redhat.lightblue.metadata.EntityMetadata类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论