use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList in project mdsal by opendaylight.
the class LazyBindingListTest method testLazyList.
@Test
public void testLazyList() {
final List<NestedList> nested = new ArrayList<>();
for (int i = 0; i < 2 * LazyBindingList.LAZY_CUTOFF; ++i) {
nested.add(new NestedListBuilder().setName(String.valueOf(i)).build());
}
final TopLevelList expected = new TopLevelListBuilder().setName("test").setNestedList(nested).build();
final TopLevelList actual = thereAndBackAgain(InstanceIdentifier.create(Top.class).child(TopLevelList.class, expected.key()), expected);
final List<NestedList> list = actual.getNestedList();
assertThat(list, instanceOf(LazyBindingList.class));
// Equality does all the right things to check happy paths
assertEquals(expected.getNestedList(), list);
assertEquals(expected.getNestedList().hashCode(), list.hashCode());
// Make sure the list performs proper caching
assertSame(list.get(LazyBindingList.LAZY_CUTOFF), list.get(LazyBindingList.LAZY_CUTOFF));
// Test throws, just for completeness' sake
assertThrows(UnsupportedOperationException.class, () -> list.add(null));
assertThrows(UnsupportedOperationException.class, () -> list.addAll(null));
assertThrows(UnsupportedOperationException.class, () -> list.addAll(0, null));
assertThrows(UnsupportedOperationException.class, () -> list.remove(null));
assertThrows(UnsupportedOperationException.class, () -> list.removeAll(null));
assertThrows(UnsupportedOperationException.class, () -> list.replaceAll(null));
assertThrows(UnsupportedOperationException.class, () -> list.retainAll(null));
assertThrows(UnsupportedOperationException.class, () -> list.sort(null));
assertThrows(UnsupportedOperationException.class, () -> list.clear());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList in project mdsal by opendaylight.
the class LazyBindingListTest method testSingletonList.
@Test
public void testSingletonList() {
final TopLevelList expected = new TopLevelListBuilder().setName("test").setNestedList(List.of(new NestedListBuilder().setName(String.valueOf("one")).build())).build();
final TopLevelList actual = thereAndBackAgain(InstanceIdentifier.create(Top.class).child(TopLevelList.class, expected.key()), expected);
final List<NestedList> list = actual.getNestedList();
assertThat(list, not(instanceOf(LazyBindingList.class)));
assertEquals(expected.getNestedList(), list);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList in project mdsal by opendaylight.
the class QueryBuilderTest method bar.
@Test
public void bar() {
final Stopwatch sw = Stopwatch.createStarted();
final QueryExpression<TopLevelList> query = factory.querySubtree(InstanceIdentifier.create(Top.class)).extractChild(TopLevelList.class).matching().childObject(NestedList.class).leaf(NestedList::getName).contains("foo").and().leaf(TopLevelList::getName).valueEquals("bar").build();
LOG.info("Query built in {}", sw);
assertEquals(0, execute(query).getItems().size());
}
Aggregations