use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestCounter method testCountByPredicateAtPath.
@Test
public void testCountByPredicateAtPath() throws Exception {
SimpleTestData data = IteratorTestData.createSimpleTestData();
int count = Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER).filterBy(Predicates.pathMatchesPathSpec(IteratorTestData.PATH_TO_ID)).count();
assertEquals(3, count);
}
use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestTransformer method testReplaceByPredicate.
@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);
}
use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestTransformer method testReplaceRoot.
@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);
}
use of com.linkedin.data.it.IteratorTestData.SimpleTestData in project rest.li by linkedin.
the class TestTransformer method testTransformByPredicateAtPath.
@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);
}
Aggregations