Package com.linkedin.data.it.IteratorTestData

Examples of com.linkedin.data.it.IteratorTestData.SimpleTestData


      };

  @Test
  public void testTransformByPredicateAtPath() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
      .filterBy(Predicates.pathMatchesPattern("foo", Wildcard.ANY_ONE, "id"))
      .transform(plusTenTransform);
   
    assertEquals(data.getValue().getDataList("foo").getDataMap(0).getInteger("id").intValue(), 11);
    assertEquals(data.getValue().getDataList("foo").getDataMap(1).getInteger("id").intValue(), 12);
    assertEquals(data.getValue().getDataList("foo").getDataMap(2).getInteger("id").intValue(), 13);
  }
View Full Code Here


  }

  @Test
  public void testReplaceByPredicateAtPath() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
    .filterBy(Predicates.and(Predicates.pathMatchesPathSpec(IteratorTestData.PATH_TO_ID), IteratorTestData.LESS_THAN_3_CONDITION))
    .replace(50);
   
    assertEquals(data.getValue().getDataList("foo").getDataMap(0).getInteger("id").intValue(), 50);
    assertEquals(data.getValue().getDataList("foo").getDataMap(1).getInteger("id").intValue(), 50);
  }
View Full Code Here

  }

  @Test
  public void testReplaceByPredicate() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
    .filterBy(Predicates.pathMatchesPathSpec(IteratorTestData.PATH_TO_ID))
    .replace(100);
   
    assertEquals(data.getValue().getDataList("foo").getDataMap(0).getInteger("id").intValue(), 100);
    assertEquals(data.getValue().getDataList("foo").getDataMap(1).getInteger("id").intValue(), 100);
    assertEquals(data.getValue().getDataList("foo").getDataMap(2).getInteger("id").intValue(), 100);
  }
View Full Code Here

  }
 
  @Test
  public void testReplaceAtPathNested() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();

    Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
    .filterBy(Predicates.pathMatchesPathSpec(new PathSpec("nested", "nested")))
    .replace(new DataMap());

    int count = Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
      .filterBy(Predicates.pathMatchesPathSpec(new PathSpec("nested", "nested", "foo")))
      .count();

    assertEquals(count, 0);
  }
View Full Code Here

   * Removes multiple nodes in a complex type, including non-leaf nodes.
   */
  @Test
  public void testReplaceByNameNested() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
    .filterBy(Predicates.nameEquals("foo"))
    .replace(new DataList());
   
    assertEquals(Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
      .filterBy(Predicates.pathMatchesPathSpec(new PathSpec("nested", "nested", "foo", PathSpec.WILDCARD)))
      .count(), 0);
   
    assertEquals(Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
      .filterBy(Predicates.pathMatchesPathSpec(new PathSpec("foo", PathSpec.WILDCARD)))
      .count(), 0);
  }
View Full Code Here

  }
 
  @Test
  public void testReplaceBySchemaNameNested() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
        .filterBy(Predicates.dataSchemaNameEquals("Bar"))
        .replace(500);
   
    List<Object> accumulate = new ArrayList<Object>(Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
        .filterBy(Predicates.pathMatchesPathSpec(new PathSpec("nested", "nested", "foo", PathSpec.WILDCARD)))
        .accumulateValues());

    assertEquals(accumulate.size(), 2);
    assertEquals(accumulate.get(0), 500);
    assertEquals(accumulate.get(1), 500);
   
    accumulate = new ArrayList<Object>(Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
        .filterBy(Predicates.pathMatchesPathSpec(new PathSpec("foo", PathSpec.WILDCARD)))
        .accumulateValues());
   
    assertEquals(accumulate.size(), 3);
    assertEquals(accumulate.get(0), 500);
View Full Code Here

  }
 
  @Test
  public void testReplaceRoot() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    Object result = Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
        .filterBy(Predicates.dataSchemaNameEquals("Foo"))
        .replace(new DataMap());
   
    assertTrue(result instanceof DataMap);
    assertEquals(((DataMap)result).size(), 0);
View Full Code Here

  }

  @Test
  public void testRemoveByPredicateAtPath() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    SimpleDataElement el = data.getDataElement();
    Builder.create(el.getValue(), el.getSchema(), IterationOrder.PRE_ORDER)
        .filterBy(Predicates.and(Predicates.pathMatchesPathSpec(IteratorTestData.PATH_TO_ID), IteratorTestData.LESS_THAN_3_CONDITION))
        .remove();
   
    assertTrue(data.getValue().getDataList("foo").getDataMap(0).getInteger("id") == null);
    assertTrue(data.getValue().getDataList("foo").getDataMap(1).getInteger("id") == null);
    assertEquals(3, data.getValue().getDataList("foo").getDataMap(2).getInteger("id").intValue());
  }
View Full Code Here

  }

  @Test
  public void testRemoveByPredicate() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    SimpleDataElement el = data.getDataElement();
    Builder.create(el.getValue(), el.getSchema(), IterationOrder.PRE_ORDER)
    .filterBy(Predicates.pathMatchesPathSpec(IteratorTestData.PATH_TO_ID))
    .remove();

    assertTrue(data.getValue().getDataList("foo").getDataMap(0).getInteger("id") == null);
    assertTrue(data.getValue().getDataList("foo").getDataMap(1).getInteger("id") == null);
    assertTrue(data.getValue().getDataList("foo").getDataMap(2).getInteger("id") == null);
  }
View Full Code Here

  }

  @Test
  public void testRemoveByPredicateWithPostOrder() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();
   
    SimpleDataElement el = data.getDataElement();
    Builder.create(el.getValue(), el.getSchema(), IterationOrder.POST_ORDER)
    .filterBy(Predicates.pathMatchesPathSpec(IteratorTestData.PATH_TO_ID))
    .remove();

    assertTrue(data.getValue().getDataList("foo").getDataMap(0).getInteger("id") == null);
    assertTrue(data.getValue().getDataList("foo").getDataMap(1).getInteger("id") == null);
    assertTrue(data.getValue().getDataList("foo").getDataMap(2).getInteger("id") == null);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.data.it.IteratorTestData.SimpleTestData

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.