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


Java JsonDoc类代码示例

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


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

示例1: testTranslate_AttributeDoesNotExist

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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

示例2: testTranslate_ObjectType

import com.redhat.lightblue.util.JsonDoc; //导入依赖的package包/类
@Test
public void testTranslate_ObjectType() throws JSONException{
    SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{});

    EntityMetadata md = fakeEntityMetadata("fakeMetadata",
            new SimpleField("objectType", StringType.TYPE)
            );

    JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);

    assertNotNull(document);

    JSONAssert.assertEquals(
            "{\"objectType\":\"fakeMetadata\",\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
            document.toString(),
            true);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:18,代码来源:ResultTranslatorToJsonTest.java

示例3: testTranslate_SimpleField_Date

import com.redhat.lightblue.util.JsonDoc; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_Date() throws JSONException{
    Attribute keyAttribute = new Attribute("key", "20150109201731.570Z");

    //Note in and out data are formatted differently
    SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
            keyAttribute
    });

    EntityMetadata md = fakeEntityMetadata(
            "fakeMetadata",
            new SimpleField("key", DateType.TYPE)
            );

    JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);

    assertNotNull(document);

    String lbDate = Constants.getDateFormat().format(keyAttribute.getValueAsDate());
    JSONAssert.assertEquals(
            "{\"key\":\"" + lbDate + "\",\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
            document.toString(),
            true);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:25,代码来源:ResultTranslatorToJsonTest.java

示例4: testTranslate_SimpleArrayElement_CountNotAskedFor

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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

示例5: testTranslate_SimpleField_String

import com.redhat.lightblue.util.JsonDoc; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_String() throws JSONException{
    SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
            new Attribute("uid", "john.doe")
    });

    EntityMetadata md = fakeEntityMetadata("fakeMetadata",
            new SimpleField("uid", StringType.TYPE)
            );

    JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);

    assertNotNull(document);

    JSONAssert.assertEquals(
            "{\"uid\":\"john.doe\",\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
            document.toString(),
            true);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:20,代码来源:ResultTranslatorToJsonTest.java

示例6: testTranslate_SimpleArrayElement_CountAskedFor

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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

示例7: testTranslate_SimpleField_Boolean

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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

示例8: testTranslate_SimpleField_BigDecimalType

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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

示例9: testTranslate_SimpleField_BigIntegerType

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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

示例10: testTranslate_SimpleField_DoubleType

import com.redhat.lightblue.util.JsonDoc; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_DoubleType() 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", DoubleType.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

示例11: testTranslate_SimpleField_UIDType

import com.redhat.lightblue.util.JsonDoc; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_UIDType() throws JSONException{
    String uuid = UUID.randomUUID().toString();

    SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
            new Attribute("key", uuid)
    });

    EntityMetadata md = fakeEntityMetadata("fakeMetadata",
            new SimpleField("key", UIDType.TYPE)
            );

    JsonDoc document = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);

    assertNotNull(document);

    JSONAssert.assertEquals(
            "{\"key\":" + uuid + ",\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
            document.toString(),
            true);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:22,代码来源:ResultTranslatorToJsonTest.java

示例12: testTranslate_SimpleField_BinaryType

import com.redhat.lightblue.util.JsonDoc; //导入依赖的package包/类
@Test
public void testTranslate_SimpleField_BinaryType() throws Exception{
    byte[] bite = new byte[]{1, 2, 3, 'a', 'b', 'c'};

    SearchResultEntry result = new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
            new Attribute("key", bite)
    });

    EntityMetadata md = fakeEntityMetadata("fakeMetadata",
            new SimpleField("key", BinaryType.TYPE)
            );

    JsonDoc jsonDocument = new ResultTranslatorToJson(factory, md, new TrivialLdapFieldNameTranslator()).translate(result);

    JsonNode keyNode = jsonDocument.get(new Path("key"));
    assertEquals(bite, keyNode.binaryValue());

    JSONAssert.assertEquals(
            "{\"key\":\"" + keyNode.asText() + "\",\"dn\":\"uid=john.doe,dc=example,dc=com\"}",
            jsonDocument.toString(),
            true);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:23,代码来源:ResultTranslatorToJsonTest.java

示例13: compareDocs

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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

示例14: shouldNotCreateNotificationForFindOperations

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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

示例15: shouldNotCreateNotificationIfNothingChangesInWatchedFields

import com.redhat.lightblue.util.JsonDoc; //导入依赖的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


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