use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestTransformer method testReplaceByPredicateAtPath.
@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);
}
use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestTransformer method testReplaceAtPathNested.
@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);
}
use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestTransformer method testReplaceBySchemaNameNested.
@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);
assertEquals(accumulate.get(1), 500);
assertEquals(accumulate.get(2), 500);
}
use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestValueAccumulator method testAccumulateByPathAndFilter.
@Test
public void testAccumulateByPathAndFilter() throws Exception {
SimpleTestData data = IteratorTestData.createSimpleTestData();
List<Object> ids = new ArrayList<Object>(Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER).filterBy(Predicates.and(Predicates.pathMatchesPathSpec(IteratorTestData.PATH_TO_ID), IteratorTestData.LESS_THAN_3_CONDITION)).accumulateValues());
assertEquals(2, ids.size());
assertTrue(ids.contains(1));
assertTrue(ids.contains(2));
}
use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestValueAccumulator method testAccumulateByPath.
@Test
public void testAccumulateByPath() throws Exception {
SimpleTestData data = IteratorTestData.createSimpleTestData();
List<Object> ids = new LinkedList<Object>();
Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER).filterBy(Predicates.and(Predicates.pathMatchesPattern("foo", Wildcard.ANY_ONE, "id"))).accumulateValues(ids);
assertEquals(3, ids.size());
assertTrue(ids.contains(1));
assertTrue(ids.contains(2));
assertTrue(ids.contains(3));
}
Aggregations