Package com.linkedin.data

Examples of com.linkedin.data.DataMap


  @Test
  public void testCompositionOfIncorrectRanges() throws JsonParseException,
      IOException,
      DataProcessingException
  {
    DataMap f1 = dataMapFromString("{ 'a': { '$start': -2, '$count': -3}}".replace('\'', '"'));
    DataMap f2 = dataMapFromString("{ 'a': { '$start': 0}}".replace('\'', '"'));
    DataComplexProcessor processor = new DataComplexProcessor(new MaskComposition(), f2, f1);
    boolean thrown = false;
    try {
      processor.run(false);
    } catch (DataProcessingException e) {
View Full Code Here


  private static void generateClassAnnotations(JDefinedClass clazz, RecordTemplate schema)
  {
    if(schema.data().containsKey("annotations"))
    {
      DataMap annotations = schema.data().getDataMap("annotations");
      if(annotations.containsKey(ResourceModelEncoder.DEPRECATED_ANNOTATION_NAME))
      {
        clazz.annotate(Deprecated.class);

        DataMap deprecated = annotations.getDataMap(ResourceModelEncoder.DEPRECATED_ANNOTATION_NAME);
        if(deprecated.containsKey(ResourceModelEncoder.DEPRECATED_ANNOTATION_DOC_FIELD))
        {
          clazz.javadoc().addDeprecated().append(deprecated.getString(ResourceModelEncoder.DEPRECATED_ANNOTATION_DOC_FIELD));
        }
      }
    }
  }
View Full Code Here

  private static void generateFactoryMethodJavadoc(JMethod method, RecordTemplate schema)
  {
    StringBuilder docString = new StringBuilder();
    if(schema.data().containsKey("annotations"))
    {
      DataMap annotations = schema.data().getDataMap("annotations");
      if(annotations.containsKey("testMethod"))
      {
        DataMap testMethod = annotations.getDataMap("testMethod");
        docString.append("<b>Test Method");

        String testMethodDoc = testMethod.getString("doc");
        if(testMethodDoc !=  null)
        {
          docString.append(": ");
          docString.append(testMethodDoc);
        }

        docString.append("</b>\n");
      }
    }
    final String doc = schema.data().getString("doc");
    if (doc != null)
    {
      docString.append(doc);
    }

    if(docString.length() > 0)
    {
      method.javadoc().append(docString.toString());
      method.javadoc().addReturn().add("builder for the resource method");
    }

    if(schema.data().containsKey("annotations"))
    {
      DataMap annotations = schema.data().getDataMap("annotations");
      if(annotations.containsKey(ResourceModelEncoder.DEPRECATED_ANNOTATION_NAME))
      {
        method.annotate(Deprecated.class);

        DataMap deprecated = annotations.getDataMap(ResourceModelEncoder.DEPRECATED_ANNOTATION_NAME);
        if(deprecated.containsKey(ResourceModelEncoder.DEPRECATED_ANNOTATION_DOC_FIELD))
        {
          method.javadoc().addDeprecated().append(deprecated.getString(ResourceModelEncoder.DEPRECATED_ANNOTATION_DOC_FIELD));
        }
      }
    }
  }
View Full Code Here

public class TestDataAssert
{
  @Test
  public void testEqualDataMaps()
  {
    DataMap d1 = new DataMap();
    DataMap d2 = new DataMap();

    d1.put("key1", "value1");
    d1.put("key2", "value2");

    d2.put("key1", "value1");
    d2.put("key2", "value2");

    DataAssert.assertDataMapsEqual(d1, d2, Collections.<String>emptySet(), false);
  }
View Full Code Here

  }

  @Test
  public void testUnequalDataMaps()
  {
    DataMap actual = new DataMap();
    DataMap expected = new DataMap();

    actual.put("key1", "value1");
    actual.put("key2", "value2");

    expected.put("key1", "value11");
    expected.put("key2", "value22");

    String expectedKey1ErrorMessage = "Mismatch on property \"key1\", expected:<value11> but was:<value1>";
    String expectedKey2ErrorMessage = "Mismatch on property \"key2\", expected:<value22> but was:<value2>";

    try
View Full Code Here

  }

  @Test
  public void testIgnoreKeysInDataMapChecking()
  {
    DataMap actual = new DataMap();
    DataMap expected = new DataMap();

    actual.put("key1", "value1");
    actual.put("key2", "value2");
    actual.put("key3", "value3");

    expected.put("key1", "value1");
    expected.put("key2", "value2");
    expected.put("key3", "value33");

    // values are different at "key3"
    DataAssert.assertDataMapsEqual(actual, expected, new HashSet<String>(Collections.singletonList("key3")), false);
  }
View Full Code Here

  @Test
  public void testPathIncludedInError() throws JsonParseException,
      IOException,
      DataProcessingException
  {
    DataMap data = dataMapFromString("{ 'a': { 'x': 'a'}}".replace('\'', '"'));
    DataMap filter = dataMapFromString("{ 'a': { 'x': { 'y': 1}}}".replace('\'', '"'));
    DataComplexProcessor processor = new DataComplexProcessor(new Filter(), filter, data);
    boolean thrown = false;
    try {
      processor.run(true);
    } catch (DataProcessingException e) {
View Full Code Here

  @Test
  public void testFastFailError() throws JsonParseException,
      IOException,
      DataProcessingException
  {
    DataMap data = dataMapFromString("{ 'a': { 'x': 'a'}, 'b': 'b'}".replace('\'', '"'));
    DataMap filter = dataMapFromString("{ 'a': { 'x': { 'y': 1}}, 'b': { 'z': 1}}".replace('\'', '"'));
    DataComplexProcessor processor = new DataComplexProcessor(new Filter(), filter, data);
    boolean thrown = false;
    try {
      processor.run(true);
    } catch (DataProcessingException e) {
View Full Code Here

  @Test
  public void testNonFastFailError() throws JsonParseException,
      IOException,
      DataProcessingException
  {
    DataMap data = dataMapFromString("{ 'a': { 'x': 'a'}, 'b': 'b'}".replace('\'', '"'));
    DataMap filter = dataMapFromString("{ 'a': { 'x': { 'y': 1}}, 'b': { 'z': 1}}".replace('\'', '"'));
    DataComplexProcessor processor = new DataComplexProcessor(new Filter(), filter, data);
    boolean thrown = false;
    try {
      processor.run(false);
    } catch (DataProcessingException e) {
View Full Code Here

  }

  @Test
  public void testDataMapsWithDifferentNullCheckOptions()
  {
    DataMap actual = new DataMap();
    actual.put("key1", "value1");

    DataMap expected = new DataMap();
    expected.put("key1", "value1");
    expected.put("key2", new DataList());
    expected.put("key3", new DataMap());

    try
    {
      DataAssert.assertDataMapsEqual(actual, expected, Collections.<String>emptySet(), false);
      Assert.fail("Assertion should have failed as the data maps are not equal!");
View Full Code Here

TOP

Related Classes of com.linkedin.data.DataMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.