use of org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer in project controller by opendaylight.
the class MockDataTreeChangeListener method waitForChangeEvents.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void waitForChangeEvents(final YangInstanceIdentifier... expPaths) {
boolean done = Uninterruptibles.awaitUninterruptibly(changeLatch, 5, TimeUnit.SECONDS);
if (!done) {
fail(String.format("Missing change notifications. Expected: %d. Actual: %d", expChangeEventCount, expChangeEventCount - changeLatch.getCount()));
}
for (int i = 0; i < expPaths.length; i++) {
final DataTreeCandidate candidate = changeList.get(i);
final Optional<NormalizedNode<?, ?>> maybeDataAfter = candidate.getRootNode().getDataAfter();
if (!maybeDataAfter.isPresent()) {
fail(String.format("Change %d does not contain data after. Actual: %s", i + 1, candidate.getRootNode()));
}
final NormalizedNode<?, ?> dataAfter = maybeDataAfter.get();
final Optional<YangInstanceIdentifier> relativePath = expPaths[i].relativeTo(candidate.getRootPath());
if (!relativePath.isPresent()) {
assertEquals(String.format("Change %d does not contain %s. Actual: %s", i + 1, expPaths[i], dataAfter), expPaths[i].getLastPathArgument(), dataAfter.getIdentifier());
} else {
NormalizedNode<?, ?> nextChild = dataAfter;
for (PathArgument pathArg : relativePath.get().getPathArguments()) {
boolean found = false;
if (nextChild instanceof NormalizedNodeContainer) {
Optional<NormalizedNode<?, ?>> maybeChild = ((NormalizedNodeContainer) nextChild).getChild(pathArg);
if (maybeChild.isPresent()) {
found = true;
nextChild = maybeChild.get();
}
}
if (!found) {
fail(String.format("Change %d does not contain %s. Actual: %s", i + 1, expPaths[i], dataAfter));
}
}
}
}
}
use of org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer in project controller by opendaylight.
the class ResolveDataChangeEventsTask method resolveSameEventRecursivelly.
private void resolveSameEventRecursivelly(final ResolveDataChangeState state, final NormalizedNode<PathArgument, ?> node, final SimpleEventFactory eventFactory) {
if (!state.needsProcessing()) {
LOG.trace("Skipping child {}", state.getPath());
return;
}
// to do additional processing
if (node instanceof NormalizedNodeContainer<?, ?, ?>) {
LOG.trace("Resolving subtree recursive event for {}, type {}", state.getPath(), eventFactory);
// Node has children, so we will try to resolve it's children
// changes.
@SuppressWarnings("unchecked") NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>> container = (NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>>) node;
for (NormalizedNode<PathArgument, ?> child : container.getValue()) {
final PathArgument childId = child.getIdentifier();
LOG.trace("Resolving event for child {}", childId);
resolveSameEventRecursivelly(state.child(childId), child, eventFactory);
}
}
final DOMImmutableDataChangeEvent event = eventFactory.create(state.getPath(), node);
LOG.trace("Adding event {} at path {}", event, state.getPath());
state.addEvent(event);
state.collectEvents(event.getOriginalSubtree(), event.getUpdatedSubtree(), collectedEvents);
}
Aggregations