+ } else if(!expectPresent && entityTypeEntry.isPresent()) {
+ fail("Found unexpected " + childMap.toString() + " entry for " + key);
+ }
+
+ return entityTypeEntry.isPresent() ? entityTypeEntry.get() : null;
+ }
+
+ static void verifyOwner(String expected, String entityType, YangInstanceIdentifier entityId,
+ Function<YangInstanceIdentifier,NormalizedNode<?,?>> reader) {
+ AssertionError lastError = null;
+ YangInstanceIdentifier entityPath = entityPath(entityType, entityId).node(ENTITY_OWNER_QNAME);
+ Stopwatch sw = Stopwatch.createStarted();
+ while(sw.elapsed(TimeUnit.MILLISECONDS) <= 5000) {
+ try {
+ NormalizedNode<?, ?> node = reader.apply(entityPath);
+ Assert.assertNotNull("Owner was not set for entityId: " + entityId, node);
+ Assert.assertEquals("Entity owner", expected, node.getValue().toString());
+ return;
+ } catch(AssertionError e) {
+ lastError = e;
+ Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ throw lastError;
+ }
+
+ protected void verifyNodeRemoved(YangInstanceIdentifier path,
+ Function<YangInstanceIdentifier,NormalizedNode<?,?>> reader) {
+ AssertionError lastError = null;
+ Stopwatch sw = Stopwatch.createStarted();
+ while(sw.elapsed(TimeUnit.MILLISECONDS) <= 5000) {
+ try {
+ NormalizedNode<?, ?> node = reader.apply(path);
+ Assert.assertNull("Node was not removed at path: " + path, node);
+ return;
+ } catch(AssertionError e) {
+ lastError = e;
+ Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ }