Remove NormalizedNodePruner 85/89485/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Apr 2020 09:19:05 +0000 (11:19 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Apr 2020 09:52:50 +0000 (11:52 +0200)
This one-shot class has been deprecated, remove it now.

Change-Id: I4a94e7ef191febcb76aa014b0175529ceee47e96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/AbstractNormalizedNodePruner.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/ReusableNormalizedNodePruner.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java

index ae6950df6fcf8291893c357e25de72b86815ec0c..f0ef49645a66954b4e15f5d393c1abe40be9ec7a 100644 (file)
@@ -64,12 +64,10 @@ abstract class AbstractNormalizedNodePruner implements NormalizedNodeStreamWrite
     private final DataSchemaContextTree tree;
 
     private DataSchemaContextNode<?> nodePathSchemaNode;
+    private NormalizedNode<?, ?> normalizedNode;
     private State state = State.UNITIALIZED;
     private int unknown;
 
-    // FIXME: package-private to support unguarded NormalizedNodePruner access
-    NormalizedNode<?, ?> normalizedNode;
-
     AbstractNormalizedNodePruner(final DataSchemaContextTree tree) {
         this.tree = requireNonNull(tree);
     }
@@ -92,17 +90,17 @@ abstract class AbstractNormalizedNodePruner implements NormalizedNodeStreamWrite
     }
 
     @Override
-    public void startLeafNode(final NodeIdentifier name) throws IOException {
+    public final void startLeafNode(final NodeIdentifier name) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startLeafNode, name);
     }
 
     @Override
-    public void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
+    public final void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startLeafSet, name, childSizeHint);
     }
 
     @Override
-    public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
+    public final void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startOrderedLeafSet, name, childSizeHint);
     }
 
@@ -112,28 +110,28 @@ abstract class AbstractNormalizedNodePruner implements NormalizedNodeStreamWrite
     }
 
     @Override
-    public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
+    public final void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startContainerNode, name, childSizeHint);
     }
 
     @Override
-    public void startYangModeledAnyXmlNode(final NodeIdentifier nodeIdentifier, final int count) {
+    public final void startYangModeledAnyXmlNode(final NodeIdentifier nodeIdentifier, final int count) {
         // FIXME: implement this
         throw new UnsupportedOperationException("Not implemented yet");
     }
 
     @Override
-    public void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException {
+    public final void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startUnkeyedList, name, childSizeHint);
     }
 
     @Override
-    public void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
+    public final void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startUnkeyedListItem, name, childSizeHint);
     }
 
     @Override
-    public void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
+    public final void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startMapNode, name, childSizeHint);
     }
 
@@ -144,22 +142,22 @@ abstract class AbstractNormalizedNodePruner implements NormalizedNodeStreamWrite
     }
 
     @Override
-    public void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
+    public final void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startOrderedMapNode, name, childSizeHint);
     }
 
     @Override
-    public void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
+    public final void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startChoiceNode, name, childSizeHint);
     }
 
     @Override
-    public void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException {
+    public final void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException {
         enter(ReusableImmutableNormalizedNodeStreamWriter::startAugmentationNode, identifier);
     }
 
     @Override
-    public boolean startAnyxmlNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
+    public final  boolean startAnyxmlNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
         if (enter(name)) {
             verify(delegate.startAnyxmlNode(name, objectModel),
                 "Unexpected failure to stream DOMSource node %s model %s", name, objectModel);
@@ -168,13 +166,13 @@ abstract class AbstractNormalizedNodePruner implements NormalizedNodeStreamWrite
     }
 
     @Override
-    public boolean startAnydataNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
+    public final boolean startAnydataNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
         // FIXME: we do not support anydata nodes yet
         return false;
     }
 
     @Override
-    public void domSourceValue(final DOMSource value) throws IOException {
+    public final  void domSourceValue(final DOMSource value) throws IOException {
         checkNotSealed();
         if (unknown == 0) {
             delegate.domSourceValue(value);
@@ -182,7 +180,7 @@ abstract class AbstractNormalizedNodePruner implements NormalizedNodeStreamWrite
     }
 
     @Override
-    public void scalarValue(final Object value) throws IOException {
+    public final void scalarValue(final Object value) throws IOException {
         checkNotSealed();
         if (unknown == 0) {
             delegate.scalarValue(translateScalar(currentSchema(), value));
@@ -195,7 +193,7 @@ abstract class AbstractNormalizedNodePruner implements NormalizedNodeStreamWrite
     }
 
     @Override
-    public void endNode() throws IOException {
+    public final void endNode() throws IOException {
         checkNotSealed();
 
         if (unknown == 0) {
@@ -220,14 +218,14 @@ abstract class AbstractNormalizedNodePruner implements NormalizedNodeStreamWrite
     }
 
     @Override
-    public void close() throws IOException {
+    public final void close() throws IOException {
         state = State.CLOSED;
         stack.clear();
         delegate.close();
     }
 
     @Override
-    public void flush() throws IOException {
+    public final void flush() throws IOException {
         delegate.flush();
     }
 
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java
deleted file mode 100644 (file)
index ba1b85f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.cluster.datastore.node.utils.transformer;
-
-import java.net.URI;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-/**
- * The NormalizedNodePruner removes all nodes from the input NormalizedNode that do not have a corresponding
- * schema element in the passed in SchemaContext.
- *
- * @deprecated Use {@link AbstractNormalizedNodePruner} instead.
- */
-@Deprecated(forRemoval = true)
-public class NormalizedNodePruner extends AbstractNormalizedNodePruner {
-    public static final URI BASE_NAMESPACE = URI.create("urn:ietf:params:xml:ns:netconf:base:1.0");
-
-    public NormalizedNodePruner(final YangInstanceIdentifier nodePath, final SchemaContext schemaContext) {
-        super(schemaContext);
-        initialize(nodePath);
-    }
-
-    public NormalizedNode<?, ?> normalizedNode() {
-        return normalizedNode;
-    }
-}
index f4e5133586563726fa09cd57bfc65908c0891bd1..d9563235b765dd96f3ec051fb8e31e6ddd24dceb 100644 (file)
@@ -15,11 +15,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
  * The NormalizedNodePruner removes all nodes from the input NormalizedNode that do not have a corresponding
- * schema element in the passed in SchemaContext.
- *
- * <p>
- * Unlike {@link NormalizedNodePruner}, this class can be reused multiple times and must be initialized before each use
- * through {@link #initializeForPath(YangInstanceIdentifier)}.
+ * schema element in the passed in SchemaContext. Instances of this class can be reused multiple times and must be
+ * initialized before each use through {@link #initializeForPath(YangInstanceIdentifier)}.
  */
 @Beta
 public abstract class ReusableNormalizedNodePruner extends AbstractNormalizedNodePruner {
index 50ade7875f8383366a327ccfcfc89f908fb780f7..422b9ce9c57ea8014af746dd83d555558e6a8bd1 100644 (file)
@@ -5,11 +5,10 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore.node.utils.transformer;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
@@ -18,12 +17,12 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.ma
 
 import com.google.common.collect.Sets;
 import java.io.IOException;
+import java.util.Optional;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.xml.transform.dom.DOMSource;
-import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
-import org.mockito.MockitoAnnotations;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator;
 import org.opendaylight.controller.cluster.datastore.util.TestModel;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -42,31 +41,33 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLe
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class NormalizedNodePrunerTest {
     private static final SchemaContext NO_TEST_SCHEMA = TestModel.createTestContextWithoutTestSchema();
     private static final SchemaContext NO_AUG_SCHEMA = TestModel.createTestContextWithoutAugmentationSchema();
     private static final SchemaContext FULL_SCHEMA = TestModel.createTestContext();
 
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-    }
-
-    private static NormalizedNodePruner prunerFullSchema(final YangInstanceIdentifier path) {
-        return new NormalizedNodePruner(path, FULL_SCHEMA);
+    private static AbstractNormalizedNodePruner prunerFullSchema(final YangInstanceIdentifier path) {
+        final ReusableNormalizedNodePruner pruner = ReusableNormalizedNodePruner.forSchemaContext(FULL_SCHEMA);
+        pruner.initializeForPath(path);
+        return pruner;
     }
 
-    private static NormalizedNodePruner prunerNoAugSchema(final YangInstanceIdentifier path) {
-        return new NormalizedNodePruner(path, NO_AUG_SCHEMA);
+    private static AbstractNormalizedNodePruner prunerNoAugSchema(final YangInstanceIdentifier path) {
+        final ReusableNormalizedNodePruner pruner = ReusableNormalizedNodePruner.forSchemaContext(NO_AUG_SCHEMA);
+        pruner.initializeForPath(path);
+        return pruner;
     }
 
-    private static NormalizedNodePruner prunerNoTestSchema(final YangInstanceIdentifier path) {
-        return new NormalizedNodePruner(path, NO_TEST_SCHEMA);
+    private static AbstractNormalizedNodePruner prunerNoTestSchema(final YangInstanceIdentifier path) {
+        final ReusableNormalizedNodePruner pruner = ReusableNormalizedNodePruner.forSchemaContext(NO_TEST_SCHEMA);
+        pruner.initializeForPath(path);
+        return pruner;
     }
 
     @Test
     public void testNodesNotPrunedWhenSchemaPresent() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
 
         NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
 
@@ -74,7 +75,7 @@ public class NormalizedNodePrunerTest {
 
         normalizedNodeWriter.write(expected);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
 
         assertEquals(expected, actual);
 
@@ -82,7 +83,7 @@ public class NormalizedNodePrunerTest {
 
     @Test(expected = IllegalStateException.class)
     public void testReusePruner() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
 
         NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
 
@@ -90,7 +91,7 @@ public class NormalizedNodePrunerTest {
 
         normalizedNodeWriter.write(expected);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
 
         assertEquals(expected, actual);
 
@@ -101,7 +102,7 @@ public class NormalizedNodePrunerTest {
 
     @Test
     public void testNodesPrunedWhenAugmentationSchemaMissing() throws IOException {
-        NormalizedNodePruner pruner = prunerNoAugSchema(TestModel.TEST_PATH);
+        AbstractNormalizedNodePruner pruner = prunerNoAugSchema(TestModel.TEST_PATH);
 
         NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
 
@@ -109,9 +110,9 @@ public class NormalizedNodePrunerTest {
 
         normalizedNodeWriter.write(expected);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
 
-        Assert.assertNotEquals(expected, actual);
+        assertNotEquals(expected, actual);
 
         // Asserting true here instead of checking actual value because I don't want this assertion to be fragile
         assertTrue(countNodes(expected, "store:aug") > 0);
@@ -122,7 +123,7 @@ public class NormalizedNodePrunerTest {
 
     @Test
     public void testNodesPrunedWhenTestSchemaMissing() throws IOException {
-        NormalizedNodePruner pruner = prunerNoTestSchema(TestModel.TEST_PATH);
+        AbstractNormalizedNodePruner pruner = prunerNoTestSchema(TestModel.TEST_PATH);
 
         NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
 
@@ -130,10 +131,8 @@ public class NormalizedNodePrunerTest {
 
         normalizedNodeWriter.write(expected);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
-
-        // Since top level schema is missing null is returned
-        assertNull(actual);
+        // Since top level schema is missing empty is returned
+        assertEquals(Optional.empty(), pruner.getResult());
 
         // Asserting true here instead of checking actual value because I don't want this assertion to be fragile
         assertTrue(countNodes(expected, "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test") > 0);
@@ -158,19 +157,18 @@ public class NormalizedNodePrunerTest {
 
     @Test
     public void testLeafNodeNotPrunedWhenHasNoParent() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.DESC_QNAME));
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.DESC_QNAME));
         NormalizedNode<?, ?> input = Builders.leafBuilder().withNodeIdentifier(
                 new NodeIdentifier(TestModel.DESC_QNAME)).withValue("test").build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
-        assertEquals("normalizedNode", input, actual);
+        assertEquals("normalizedNode", input, pruner.getResult().orElseThrow());
     }
 
     @Test
     public void testLeafNodePrunedWhenHasAugmentationParentAndSchemaMissing() throws IOException {
         AugmentationIdentifier augId = new AugmentationIdentifier(Sets.newHashSet(TestModel.AUG_CONT_QNAME));
-        NormalizedNodePruner pruner = prunerFullSchema(YangInstanceIdentifier.builder()
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(YangInstanceIdentifier.builder()
                 .node(TestModel.TEST_QNAME).node(TestModel.AUGMENTED_LIST_QNAME)
                         .node(TestModel.AUGMENTED_LIST_QNAME).node(augId).build());
         LeafNode<Object> child = Builders.leafBuilder().withNodeIdentifier(
@@ -178,104 +176,98 @@ public class NormalizedNodePrunerTest {
         NormalizedNode<?, ?> input = Builders.augmentationBuilder().withNodeIdentifier(augId).withChild(child).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", Builders.augmentationBuilder().withNodeIdentifier(augId).build(), actual);
     }
 
     @Test
     public void testLeafNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
         NormalizedNode<?, ?> input = Builders.leafBuilder().withNodeIdentifier(
                 new NodeIdentifier(TestModel.INVALID_QNAME)).withValue("test").build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
-        assertNull(actual);
+        assertEquals(Optional.empty(), pruner.getResult());
     }
 
-
     @Test
     public void testLeafSetEntryNodeNotPrunedWhenHasNoParent() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
         NormalizedNode<?, ?> input = Builders.leafSetEntryBuilder().withValue("puma").withNodeIdentifier(
                 new NodeWithValue<>(TestModel.SHOE_QNAME, "puma")).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", input, actual);
     }
 
     @Test
     public void testLeafSetEntryNodeNotPrunedWhenHasParent() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
         LeafSetEntryNode<Object> child = Builders.leafSetEntryBuilder().withValue("puma").withNodeIdentifier(
                 new NodeWithValue<>(TestModel.SHOE_QNAME, "puma")).build();
         NormalizedNode<?, ?> input = Builders.leafSetBuilder().withNodeIdentifier(
                 new NodeIdentifier(TestModel.SHOE_QNAME)).withChild(child).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", input, actual);
     }
 
     @Test
     public void testLeafSetEntryNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
         NormalizedNode<?, ?> input = Builders.leafSetEntryBuilder().withValue("test").withNodeIdentifier(
                 new NodeWithValue<>(TestModel.INVALID_QNAME, "test")).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
-        assertNull(actual);
+        assertEquals(Optional.empty(), pruner.getResult());
     }
 
     @Test
     public void testLeafSetEntryNodePrunedWhenHasParentAndSchemaMissing() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
         LeafSetEntryNode<Object> child = Builders.leafSetEntryBuilder().withValue("test").withNodeIdentifier(
                 new NodeWithValue<>(TestModel.INVALID_QNAME, "test")).build();
         NormalizedNode<?, ?> input = Builders.leafSetBuilder().withNodeIdentifier(
                 new NodeIdentifier(TestModel.INVALID_QNAME)).withChild(child).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
-        assertNull(actual);
+        assertEquals(Optional.empty(), pruner.getResult());
     }
 
     @Test
     public void testAnyXMLNodeNotPrunedWhenHasNoParent() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.ANY_XML_QNAME));
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.ANY_XML_QNAME));
         NormalizedNode<?, ?> input = Builders.anyXmlBuilder().withNodeIdentifier(
                 new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", input, actual);
     }
 
-
     @Test
     public void testAnyXMLNodeNotPrunedWhenHasParent() throws IOException {
-        NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
         DOMSourceAnyxmlNode child = Builders.anyXmlBuilder().withNodeIdentifier(
                 new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build();
         NormalizedNode<?, ?> input = Builders.containerBuilder().withNodeIdentifier(
                 new NodeIdentifier(TestModel.TEST_QNAME)).withChild(child).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", input, actual);
     }
 
     @Test
     public void testAnyXmlNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
-        NormalizedNodePruner pruner = prunerNoTestSchema(TestModel.TEST_PATH.node(TestModel.ANY_XML_QNAME));
+        AbstractNormalizedNodePruner pruner = prunerNoTestSchema(TestModel.TEST_PATH.node(TestModel.ANY_XML_QNAME));
         NormalizedNode<?, ?> input = Builders.anyXmlBuilder().withNodeIdentifier(
                 new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
-        assertNull(actual);
+        assertEquals(Optional.empty(), pruner.getResult());
     }
 
     @Test
@@ -284,12 +276,12 @@ public class NormalizedNodePrunerTest {
                 .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
                 .node(TestModel.INNER_LIST_QNAME).nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one")
                 .node(TestModel.INNER_CONTAINER_QNAME).build();
-        NormalizedNodePruner pruner = prunerFullSchema(path);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
 
         NormalizedNode<?, ?> input = ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME);
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", input, actual);
     }
 
@@ -299,13 +291,12 @@ public class NormalizedNodePrunerTest {
                 .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
                 .node(TestModel.INNER_LIST_QNAME).nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one")
                 .node(TestModel.INVALID_QNAME).build();
-        NormalizedNodePruner pruner = prunerFullSchema(path);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
 
         NormalizedNode<?, ?> input = ImmutableNodes.containerNode(TestModel.INVALID_QNAME);
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
-        assertNull(actual);
+        assertEquals(Optional.empty(), pruner.getResult());
     }
 
     @Test
@@ -313,7 +304,7 @@ public class NormalizedNodePrunerTest {
         YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(TestModel.TEST_QNAME)
                 .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
                 .build();
-        NormalizedNodePruner pruner = prunerFullSchema(path);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
 
         MapNode innerList = mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder(
                 TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").withChild(
@@ -325,7 +316,7 @@ public class NormalizedNodePrunerTest {
         NormalizedNode<?, ?> expected = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
                 .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder(
                     TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").build()).build()).build();
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", expected, actual);
     }
 
@@ -334,14 +325,14 @@ public class NormalizedNodePrunerTest {
         YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(TestModel.TEST_QNAME)
                 .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
                 .node(TestModel.INNER_LIST_QNAME).build();
-        NormalizedNodePruner pruner = prunerFullSchema(path);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
 
         MapNode input = mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder(
                 TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").withChild(
                         ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME)).build()).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", input, actual);
     }
 
@@ -350,15 +341,14 @@ public class NormalizedNodePrunerTest {
         YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(TestModel.TEST_QNAME)
                 .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
                 .node(TestModel.INVALID_QNAME).build();
-        NormalizedNodePruner pruner = prunerFullSchema(path);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
 
         MapNode input = mapNodeBuilder(TestModel.INVALID_QNAME).withChild(mapEntryBuilder(
                 TestModel.INVALID_QNAME, TestModel.NAME_QNAME, "one").withChild(
                         ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME)).build()).build();
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
-        assertNull(actual);
+        assertEquals(Optional.empty(), pruner.getResult());
     }
 
     @Test
@@ -366,7 +356,7 @@ public class NormalizedNodePrunerTest {
         YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(TestModel.TEST_QNAME)
                 .node(TestModel.OUTER_LIST_QNAME).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
                 .build();
-        NormalizedNodePruner pruner = prunerFullSchema(path);
+        AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
 
         MapNode innerList = mapNodeBuilder(TestModel.INVALID_QNAME).withChild(mapEntryBuilder(
                 TestModel.INVALID_QNAME, TestModel.NAME_QNAME, "one").withChild(
@@ -376,7 +366,7 @@ public class NormalizedNodePrunerTest {
         NormalizedNodeWriter.forStreamWriter(pruner).write(input);
 
         NormalizedNode<?, ?> expected = mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
-        NormalizedNode<?, ?> actual = pruner.normalizedNode();
+        NormalizedNode<?, ?> actual = pruner.getResult().orElseThrow();
         assertEquals("normalizedNode", expected, actual);
     }