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 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 testReplaceByNameNested.
/**
* 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);
}
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<>(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<>(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 TestCounter method testCountByPredicateAtPathWithFilter.
@Test
public void testCountByPredicateAtPathWithFilter() throws Exception {
SimpleTestData data = IteratorTestData.createSimpleTestData();
int count = Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER).filterBy(Predicates.and(Predicates.pathMatchesPathSpec(IteratorTestData.PATH_TO_ID), IteratorTestData.LESS_THAN_3_CONDITION)).count();
assertEquals(2, count);
}
Aggregations