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


Java EntityMetadata类代码示例

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


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


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