Bug 2358 - Changed modifier of method in AbstractBodyReaderTest to protected 87/19287/7
authorary <jatoth@cisco.com>
Wed, 29 Apr 2015 10:00:31 +0000 (12:00 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 8 Jun 2015 11:33:15 +0000 (11:33 +0000)
Tests of codecs are included in codecs yangtools yang-data-codec-gson and yang-data-impl but we test codec on input data and also with presentation of Rest path.

* changed modifier of method getMediaType() to protected
* fix tests with method getMediaType()
* remove additional assertions

Change-Id: I211c2dc43690b663cada31deb3942e10fcc95366
Signed-off-by: ary <jatoth@cisco.com>
(cherry picked from commit 90aed8ac03ee3496178bdc3ec4b46f5c98dd78fc)

opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyWriter.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java

index 7aef39b2b4b54cef202a6caef6015509d382e2ab..35a6162c95faaa9b4bf1ed4e5db4e4173c8e9076 100644 (file)
@@ -11,13 +11,16 @@ package org.opendaylight.controller.sal.rest.impl.test.providers;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import java.lang.reflect.Field;
 import java.util.Collections;
+
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Request;
 import javax.ws.rs.core.UriInfo;
+
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
 import org.opendaylight.controller.sal.rest.api.RestconfConstants;
 import org.opendaylight.controller.sal.rest.impl.AbstractIdentifierAwareJaxRsProvider;
@@ -26,42 +29,49 @@ import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
- * sal-rest-connector
- * org.opendaylight.controller.sal.rest.impl.test.providers
+ * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
  *
  *
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
  *
- * Created: Mar 7, 2015
+ *         Created: Mar 7, 2015
  */
 public abstract class AbstractBodyReaderTest {
 
-    protected final static ControllerContext controllerContext = ControllerContext.getInstance();
+    protected final static ControllerContext controllerContext = ControllerContext
+            .getInstance();
     protected final MediaType mediaType;
     private static Field uriField;
     private static Field requestField;
 
-    public AbstractBodyReaderTest () throws NoSuchFieldException, SecurityException {
-        uriField = AbstractIdentifierAwareJaxRsProvider.class.getDeclaredField("uriInfo");
+    public AbstractBodyReaderTest() throws NoSuchFieldException,
+            SecurityException {
+        uriField = AbstractIdentifierAwareJaxRsProvider.class
+                .getDeclaredField("uriInfo");
         uriField.setAccessible(true);
-        requestField = AbstractIdentifierAwareJaxRsProvider.class.getDeclaredField("request");
+        requestField = AbstractIdentifierAwareJaxRsProvider.class
+                .getDeclaredField("request");
         requestField.setAccessible(true);
         mediaType = getMediaType();
     }
 
-    abstract MediaType getMediaType();
+    protected abstract MediaType getMediaType();
 
-    protected static SchemaContext schemaContextLoader(final String yangPath, final SchemaContext schemaContext) {
+    protected static SchemaContext schemaContextLoader(final String yangPath,
+            final SchemaContext schemaContext) {
         return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext);
     }
 
     protected static <T extends AbstractIdentifierAwareJaxRsProvider> void mockBodyReader(
-            final String identifier, final T normalizedNodeProvider, final boolean isPost) throws NoSuchFieldException,
+            final String identifier, final T normalizedNodeProvider,
+            final boolean isPost) throws NoSuchFieldException,
             SecurityException, IllegalArgumentException, IllegalAccessException {
         final UriInfo uriInfoMock = mock(UriInfo.class);
-        final MultivaluedMap<String, String> pathParm = new MultivaluedHashMap<>(1);
-        pathParm.put(RestconfConstants.IDENTIFIER, Collections.singletonList(identifier));
+        final MultivaluedMap<String, String> pathParm = new MultivaluedHashMap<>(
+                1);
+        pathParm.put(RestconfConstants.IDENTIFIER,
+                Collections.singletonList(identifier));
         when(uriInfoMock.getPathParameters()).thenReturn(pathParm);
         when(uriInfoMock.getPathParameters(false)).thenReturn(pathParm);
         when(uriInfoMock.getPathParameters(true)).thenReturn(pathParm);
@@ -75,17 +85,19 @@ public abstract class AbstractBodyReaderTest {
         requestField.set(normalizedNodeProvider, request);
     }
 
-    protected static void checkMountPointNormalizedNodeContext(final NormalizedNodeContext nnContext) {
+    protected static void checkMountPointNormalizedNodeContext(
+            final NormalizedNodeContext nnContext) {
         checkNormalizedNodeContext(nnContext);
         assertNotNull(nnContext.getInstanceIdentifierContext().getMountPoint());
     }
 
-    protected static void checkNormalizedNodeContext(final NormalizedNodeContext nnContext) {
-        assertNotNull(nnContext);
+    protected static void checkNormalizedNodeContext(
+            final NormalizedNodeContext nnContext) {
         assertNotNull(nnContext.getData());
-        assertNotNull(nnContext.getInstanceIdentifierContext());
-        assertNotNull(nnContext.getInstanceIdentifierContext().getInstanceIdentifier());
-        assertNotNull(nnContext.getInstanceIdentifierContext().getSchemaContext());
+        assertNotNull(nnContext.getInstanceIdentifierContext()
+                .getInstanceIdentifier());
+        assertNotNull(nnContext.getInstanceIdentifierContext()
+                .getSchemaContext());
         assertNotNull(nnContext.getInstanceIdentifierContext().getSchemaNode());
     }
 }
index d233d9a3c99828c9f8a2b34b2023b8dc9d4043a0..36ce29b893bc30bea5ba93ee769908156687826f 100644 (file)
@@ -10,9 +10,11 @@ package org.opendaylight.controller.sal.rest.impl.test.providers;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import com.google.common.base.Optional;
+
 import java.io.InputStream;
+
 import javax.ws.rs.core.MediaType;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader;
@@ -27,34 +29,37 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
+import com.google.common.base.Optional;
+
 /**
- * sal-rest-connector
- * org.opendaylight.controller.sal.rest.impl.test.providers
+ * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
  *
  *
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
  *
- * Created: Mar 11, 2015
+ *         Created: Mar 11, 2015
  */
 public class TestJsonBodyReader extends AbstractBodyReaderTest {
 
     private final JsonNormalizedNodeBodyReader jsonBodyReader;
     private static SchemaContext schemaContext;
 
-    public TestJsonBodyReader () throws NoSuchFieldException, SecurityException {
+    public TestJsonBodyReader() throws NoSuchFieldException, SecurityException {
         super();
         jsonBodyReader = new JsonNormalizedNodeBodyReader();
     }
 
     @Override
-    MediaType getMediaType() {
+    protected MediaType getMediaType() {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
     @BeforeClass
-    public static void initialization() throws NoSuchFieldException, SecurityException {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
+    public static void initialization() throws NoSuchFieldException,
+            SecurityException {
+        schemaContext = schemaContextLoader("/instanceidentifier/yang",
+                schemaContext);
         schemaContext = schemaContextLoader("/modules", schemaContext);
         schemaContext = schemaContextLoader("/invoke-rpc", schemaContext);
         controllerContext.setSchemas(schemaContext);
@@ -62,39 +67,43 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
 
     @Test
     public void moduleDataTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont";
         mockBodyReader(uri, jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/jsondata.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
 
     @Test
     public void moduleSubContainerDataPutTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont/cont1";
         mockBodyReader(uri, jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
-        checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, "cont1");
+        checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue,
+                "cont1");
     }
 
     @Test
     public void moduleSubContainerDataPostTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont";
         mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -105,37 +114,51 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
         mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/invoke-rpc/json/rpc-input.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         final ContainerNode inputNode = (ContainerNode) returnValue.getData();
-        final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(inputNode.getNodeType(), "cont"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNode = inputNode.getChild(yangCont.getLastPathArgument());
+        final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName
+                .create(inputNode.getNodeType(), "cont"));
+        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNode = inputNode
+                .getChild(yangCont.getLastPathArgument());
         assertTrue(contDataNode.isPresent());
         assertTrue(contDataNode.get() instanceof ContainerNode);
-        final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName.create(inputNode.getNodeType(), "lf"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = ((ContainerNode)contDataNode.get()).getChild(yangleaf.getLastPathArgument());
+        final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName
+                .create(inputNode.getNodeType(), "lf"));
+        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = ((ContainerNode) contDataNode
+                .get()).getChild(yangleaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
-        assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
+        assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue()
+                .toString()));
     }
 
-    private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    private void checkExpectValueNormalizeNodeContext(
+            final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext) {
         checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null);
     }
 
-    private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    private void checkExpectValueNormalizeNodeContext(
+            final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext, final String localQname) {
-        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier.of(dataSchemaNode.getQName());
+        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier
+                .of(dataSchemaNode.getQName());
 
         if (localQname != null && dataSchemaNode instanceof DataNodeContainer) {
-            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode).getDataChildByName(localQname);
-            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent).node(child.getQName()).build();
-            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(child));
+            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
+                    .getDataChildByName(localQname);
+            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
+                    .node(child.getQName()).build();
+            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode()
+                    .equals(child));
         } else {
-            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(dataSchemaNode));
+            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode()
+                    .equals(dataSchemaNode));
         }
-        assertTrue(nnContext.getInstanceIdentifierContext().getInstanceIdentifier().equals(dataNodeIdent));
-        assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent));
+        assertTrue(nnContext.getInstanceIdentifierContext()
+                .getInstanceIdentifier().equals(dataNodeIdent));
+        assertNotNull(NormalizedNodes.findNode(nnContext.getData(),
+                dataNodeIdent));
     }
 }
index 25f752590c2a5888b271595def00c664b5972e9a..9a6a3ff0ef062e55cd9ddf4bbc8d049dbabc380a 100644 (file)
@@ -13,9 +13,11 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import com.google.common.base.Optional;
+
 import java.io.InputStream;
+
 import javax.ws.rs.core.MediaType;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
@@ -33,40 +35,45 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
+import com.google.common.base.Optional;
+
 /**
- * sal-rest-connector
- * org.opendaylight.controller.sal.rest.impl.test.providers
+ * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
  *
  *
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
  *
- * Created: Mar 11, 2015
+ *         Created: Mar 11, 2015
  */
 public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
 
     private final JsonNormalizedNodeBodyReader jsonBodyReader;
     private static SchemaContext schemaContext;
 
-    public TestJsonBodyReaderMountPoint () throws NoSuchFieldException, SecurityException {
+    public TestJsonBodyReaderMountPoint() throws NoSuchFieldException,
+            SecurityException {
         super();
         jsonBodyReader = new JsonNormalizedNodeBodyReader();
     }
 
     @Override
-    MediaType getMediaType() {
+    protected MediaType getMediaType() {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
     @BeforeClass
-    public static void initialization() throws NoSuchFieldException, SecurityException {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
+    public static void initialization() throws NoSuchFieldException,
+            SecurityException {
+        schemaContext = schemaContextLoader("/instanceidentifier/yang",
+                schemaContext);
         schemaContext = schemaContextLoader("/modules", schemaContext);
         schemaContext = schemaContextLoader("/invoke-rpc", schemaContext);
         final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
         when(mountInstance.getSchemaContext()).thenReturn(schemaContext);
         final DOMMountPointService mockMountService = mock(DOMMountPointService.class);
-        when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance));
+        when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class)))
+                .thenReturn(Optional.of(mountInstance));
 
         ControllerContext.getInstance().setMountService(mockMountService);
         controllerContext.setSchemas(schemaContext);
@@ -74,39 +81,43 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
 
     @Test
     public void moduleDataTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
         mockBodyReader(uri, jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/jsondata.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
 
     @Test
     public void moduleSubContainerDataPutTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1";
         mockBodyReader(uri, jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
-        checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, "cont1");
+        checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue,
+                "cont1");
     }
 
     @Test
     public void moduleSubContainerDataPostTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
         mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -117,39 +128,53 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/invoke-rpc/json/rpc-input.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         final ContainerNode inputNode = (ContainerNode) returnValue.getData();
-        final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(inputNode.getNodeType(), "cont"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNode = inputNode.getChild(yangCont.getLastPathArgument());
+        final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName
+                .create(inputNode.getNodeType(), "cont"));
+        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNode = inputNode
+                .getChild(yangCont.getLastPathArgument());
         assertTrue(contDataNode.isPresent());
         assertTrue(contDataNode.get() instanceof ContainerNode);
-        final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName.create(inputNode.getNodeType(), "lf"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = ((ContainerNode)contDataNode.get()).getChild(yangleaf.getLastPathArgument());
+        final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName
+                .create(inputNode.getNodeType(), "lf"));
+        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = ((ContainerNode) contDataNode
+                .get()).getChild(yangleaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
-        assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
+        assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue()
+                .toString()));
     }
 
-    private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    private void checkExpectValueNormalizeNodeContext(
+            final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext) {
         checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null);
     }
 
-    protected void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    protected void checkExpectValueNormalizeNodeContext(
+            final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext, final String localQname) {
-        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier.of(dataSchemaNode.getQName());
-        final DOMMountPoint mountPoint = nnContext.getInstanceIdentifierContext().getMountPoint();
-        final DataSchemaNode mountDataSchemaNode =
-                mountPoint.getSchemaContext().getDataChildByName(dataSchemaNode.getQName());
+        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier
+                .of(dataSchemaNode.getQName());
+        final DOMMountPoint mountPoint = nnContext
+                .getInstanceIdentifierContext().getMountPoint();
+        final DataSchemaNode mountDataSchemaNode = mountPoint
+                .getSchemaContext().getDataChildByName(
+                        dataSchemaNode.getQName());
         assertNotNull(mountDataSchemaNode);
         if (localQname != null && dataSchemaNode instanceof DataNodeContainer) {
-            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode).getDataChildByName(localQname);
-            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent).node(child.getQName()).build();
-            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(child));
+            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
+                    .getDataChildByName(localQname);
+            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
+                    .node(child.getQName()).build();
+            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode()
+                    .equals(child));
         } else {
             assertTrue(mountDataSchemaNode.equals(dataSchemaNode));
         }
-        assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent));
+        assertNotNull(NormalizedNodes.findNode(nnContext.getData(),
+                dataNodeIdent));
     }
 }
index aea0d479d06f637ca51cd37e26034a56c3abb3e8..e5cda6c94d12a81edb61815dc4eac4679a7980aa 100644 (file)
@@ -9,10 +9,13 @@
 package org.opendaylight.controller.sal.rest.impl.test.providers;
 
 import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
+
 import javax.ws.rs.core.MediaType;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader;
@@ -21,14 +24,13 @@ import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
- * sal-rest-connector
- * org.opendaylight.controller.sal.rest.impl.test.providers
+ * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
  *
  *
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
  *
- * Created: Mar 12, 2015
+ *         Created: Mar 12, 2015
  */
 public class TestJsonBodyWriter extends AbstractBodyReaderTest {
 
@@ -36,20 +38,22 @@ public class TestJsonBodyWriter extends AbstractBodyReaderTest {
     private final NormalizedNodeJsonBodyWriter jsonBodyWriter;
     private static SchemaContext schemaContext;
 
-    public TestJsonBodyWriter () throws NoSuchFieldException, SecurityException {
+    public TestJsonBodyWriter() throws NoSuchFieldException, SecurityException {
         super();
         jsonBodyWriter = new NormalizedNodeJsonBodyWriter();
         jsonBodyReader = new JsonNormalizedNodeBodyReader();
     }
 
     @Override
-    MediaType getMediaType() {
+    protected MediaType getMediaType() {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
     @BeforeClass
-    public static void initialization() throws NoSuchFieldException, SecurityException {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
+    public static void initialization() throws NoSuchFieldException,
+            SecurityException {
+        schemaContext = schemaContextLoader("/instanceidentifier/yang",
+                schemaContext);
         schemaContext = schemaContextLoader("/modules", schemaContext);
         schemaContext = schemaContextLoader("/invoke-rpc", schemaContext);
         controllerContext.setSchemas(schemaContext);
@@ -61,10 +65,11 @@ public class TestJsonBodyWriter extends AbstractBodyReaderTest {
         mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyWriter.class
                 .getResourceAsStream("/invoke-rpc/json/rpc-output.json");
-        final NormalizedNodeContext returnValue = jsonBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         final OutputStream output = new ByteArrayOutputStream();
-        jsonBodyWriter.writeTo(returnValue, null, null, null, mediaType, null, output);
+        jsonBodyWriter.writeTo(returnValue, null, null, null, mediaType, null,
+                output);
         assertTrue(output.toString().contains("lf-test"));
     }
 }
index 146d971c95b4d0660e9cb22910661c0f340b71c5..46bea7a75c817cdf63c6dfa8596afa641daafd8e 100644 (file)
@@ -10,9 +10,11 @@ package org.opendaylight.controller.sal.rest.impl.test.providers;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import com.google.common.base.Optional;
+
 import java.io.InputStream;
+
 import javax.ws.rs.core.MediaType;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.sal.rest.impl.XmlNormalizedNodeBodyReader;
@@ -27,34 +29,37 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
+import com.google.common.base.Optional;
+
 /**
- * sal-rest-connector
- * org.opendaylight.controller.sal.rest.impl.test.providers
+ * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
  *
  *
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
  *
- * Created: Mar 7, 2015
+ *         Created: Mar 7, 2015
  */
 public class TestXmlBodyReader extends AbstractBodyReaderTest {
 
     private final XmlNormalizedNodeBodyReader xmlBodyReader;
     private static SchemaContext schemaContext;
 
-    public TestXmlBodyReader () throws NoSuchFieldException, SecurityException {
+    public TestXmlBodyReader() throws NoSuchFieldException, SecurityException {
         super();
         xmlBodyReader = new XmlNormalizedNodeBodyReader();
     }
 
     @Override
-    MediaType getMediaType() {
+    protected MediaType getMediaType() {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
     @BeforeClass
-    public static void initialization() throws NoSuchFieldException, SecurityException {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
+    public static void initialization() throws NoSuchFieldException,
+            SecurityException {
+        schemaContext = schemaContextLoader("/instanceidentifier/yang",
+                schemaContext);
         schemaContext = schemaContextLoader("/modules", schemaContext);
         schemaContext = schemaContextLoader("/invoke-rpc", schemaContext);
         controllerContext.setSchemas(schemaContext);
@@ -62,39 +67,43 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
 
     @Test
     public void moduleDataTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont";
         mockBodyReader(uri, xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
 
     @Test
     public void moduleSubContainerDataPutTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont/cont1";
         mockBodyReader(uri, xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
-        checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, "cont1");
+        checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue,
+                "cont1");
     }
 
     @Test
     public void moduleSubContainerDataPostTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont";
         mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -105,33 +114,45 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/invoke-rpc/xml/rpc-input.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
-        final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "lf"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contNode.getChild(yangleaf.getLastPathArgument());
+        final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName
+                .create(contNode.getNodeType(), "lf"));
+        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contNode
+                .getChild(yangleaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
-        assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
+        assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue()
+                .toString()));
     }
 
-    private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    private void checkExpectValueNormalizeNodeContext(
+            final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext) {
         checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null);
     }
 
-    private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    private void checkExpectValueNormalizeNodeContext(
+            final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext, final String localQname) {
-        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier.of(dataSchemaNode.getQName());
+        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier
+                .of(dataSchemaNode.getQName());
 
         if (localQname != null && dataSchemaNode instanceof DataNodeContainer) {
-            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode).getDataChildByName(localQname);
-            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent).node(child.getQName()).build();
-            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(child));
+            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
+                    .getDataChildByName(localQname);
+            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
+                    .node(child.getQName()).build();
+            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode()
+                    .equals(child));
         } else {
-            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(dataSchemaNode));
+            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode()
+                    .equals(dataSchemaNode));
         }
-        assertTrue(nnContext.getInstanceIdentifierContext().getInstanceIdentifier().equals(dataNodeIdent));
-        assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent));
+        assertTrue(nnContext.getInstanceIdentifierContext()
+                .getInstanceIdentifier().equals(dataNodeIdent));
+        assertNotNull(NormalizedNodes.findNode(nnContext.getData(),
+                dataNodeIdent));
     }
 }
index a31d198aa6d30c5a846dd4060045d21795f2bf0b..f1be296c4dc642542fa5bdd4c63c5c2d1db7bac4 100644 (file)
@@ -13,9 +13,11 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import com.google.common.base.Optional;
+
 import java.io.InputStream;
+
 import javax.ws.rs.core.MediaType;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
@@ -33,40 +35,45 @@ import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
+import com.google.common.base.Optional;
+
 /**
- * sal-rest-connector
- * org.opendaylight.controller.sal.rest.impl.test.providers
+ * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
  *
  *
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
  *
- * Created: Mar 9, 2015
+ *         Created: Mar 9, 2015
  */
 public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
 
     private final XmlNormalizedNodeBodyReader xmlBodyReader;
     private static SchemaContext schemaContext;
 
-    public TestXmlBodyReaderMountPoint () throws NoSuchFieldException, SecurityException {
+    public TestXmlBodyReaderMountPoint() throws NoSuchFieldException,
+            SecurityException {
         super();
         xmlBodyReader = new XmlNormalizedNodeBodyReader();
     }
 
     @Override
-    MediaType getMediaType() {
+    protected MediaType getMediaType() {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
     @BeforeClass
-    public static void initialization() throws NoSuchFieldException, SecurityException {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
+    public static void initialization() throws NoSuchFieldException,
+            SecurityException {
+        schemaContext = schemaContextLoader("/instanceidentifier/yang",
+                schemaContext);
         schemaContext = schemaContextLoader("/modules", schemaContext);
         schemaContext = schemaContextLoader("/invoke-rpc", schemaContext);
         final DOMMountPoint mountInstance = mock(DOMMountPoint.class);
         when(mountInstance.getSchemaContext()).thenReturn(schemaContext);
         final DOMMountPointService mockMountService = mock(DOMMountPointService.class);
-        when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class))).thenReturn(Optional.of(mountInstance));
+        when(mockMountService.getMountPoint(any(YangInstanceIdentifier.class)))
+                .thenReturn(Optional.of(mountInstance));
 
         ControllerContext.getInstance().setMountService(mockMountService);
         controllerContext.setSchemas(schemaContext);
@@ -74,39 +81,43 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
 
     @Test
     public void moduleDataTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
         mockBodyReader(uri, xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
 
     @Test
     public void moduleSubContainerDataPutTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1";
         mockBodyReader(uri, xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
-        checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, "cont1");
+        checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue,
+                "cont1");
     }
 
     @Test
     public void moduleSubContainerDataPostTest() throws Exception {
-        final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName("cont");
+        final DataSchemaNode dataSchemaNode = schemaContext
+                .getDataChildByName("cont");
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
         mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -117,35 +128,47 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/invoke-rpc/xml/rpc-input.xml");
-        final NormalizedNodeContext returnValue = xmlBodyReader
-                .readFrom(null, null, null, mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
-        final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "lf"));
-        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contNode.getChild(yangleaf.getLastPathArgument());
+        final YangInstanceIdentifier yangleaf = YangInstanceIdentifier.of(QName
+                .create(contNode.getNodeType(), "lf"));
+        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contNode
+                .getChild(yangleaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
-        assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
+        assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue()
+                .toString()));
     }
 
-    private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    private void checkExpectValueNormalizeNodeContext(
+            final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext) {
         checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null);
     }
 
-    protected void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    protected void checkExpectValueNormalizeNodeContext(
+            final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext, final String localQname) {
-        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier.of(dataSchemaNode.getQName());
-        final DOMMountPoint mountPoint = nnContext.getInstanceIdentifierContext().getMountPoint();
-        final DataSchemaNode mountDataSchemaNode =
-                mountPoint.getSchemaContext().getDataChildByName(dataSchemaNode.getQName());
+        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier
+                .of(dataSchemaNode.getQName());
+        final DOMMountPoint mountPoint = nnContext
+                .getInstanceIdentifierContext().getMountPoint();
+        final DataSchemaNode mountDataSchemaNode = mountPoint
+                .getSchemaContext().getDataChildByName(
+                        dataSchemaNode.getQName());
         assertNotNull(mountDataSchemaNode);
         if (localQname != null && dataSchemaNode instanceof DataNodeContainer) {
-            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode).getDataChildByName(localQname);
-            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent).node(child.getQName()).build();
-            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(child));
+            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
+                    .getDataChildByName(localQname);
+            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
+                    .node(child.getQName()).build();
+            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode()
+                    .equals(child));
         } else {
             assertTrue(mountDataSchemaNode.equals(dataSchemaNode));
         }
-        assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent));
+        assertNotNull(NormalizedNodes.findNode(nnContext.getData(),
+                dataNodeIdent));
     }
 }
index edd41e5978efa84d3b5471f1c40e6a4c6ab8b1b5..8eac4511f15a4d694914c3a158c50238e6376f09 100644 (file)
@@ -9,9 +9,12 @@
 package org.opendaylight.controller.sal.rest.impl.test.providers;
 
 import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
+
 import javax.ws.rs.core.MediaType;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
@@ -20,33 +23,34 @@ import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
- * sal-rest-connector
- * org.opendaylight.controller.sal.rest.impl.test.providers
+ * sal-rest-connector org.opendaylight.controller.sal.rest.impl.test.providers
  *
  *
  *
  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
  *
- * Created: Mar 12, 2015
+ *         Created: Mar 12, 2015
  */
 public class TestXmlBodyWriter extends AbstractBodyReaderTest {
 
     private final NormalizedNodeXmlBodyWriter xmlBodyWriter;
     private static SchemaContext schemaContext;
 
-    public TestXmlBodyWriter () throws NoSuchFieldException, SecurityException {
+    public TestXmlBodyWriter() throws NoSuchFieldException, SecurityException {
         super();
         xmlBodyWriter = new NormalizedNodeXmlBodyWriter();
     }
 
     @Override
-    MediaType getMediaType() {
+    protected MediaType getMediaType() {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
     @BeforeClass
-    public static void initialization() throws NoSuchFieldException, SecurityException {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
+    public static void initialization() throws NoSuchFieldException,
+            SecurityException {
+        schemaContext = schemaContextLoader("/instanceidentifier/yang",
+                schemaContext);
         schemaContext = schemaContextLoader("/modules", schemaContext);
         schemaContext = schemaContextLoader("/invoke-rpc", schemaContext);
         controllerContext.setSchemas(schemaContext);
@@ -56,10 +60,11 @@ public class TestXmlBodyWriter extends AbstractBodyReaderTest {
     public void rpcModuleInputTest() throws Exception {
         final String uri = "invoke-rpc-module:rpc-test";
         final String pathToInputFile = "/invoke-rpc/xml/rpc-output.xml";
-        final NormalizedNodeContext nnContext =
-                TestRestconfUtils.loadNormalizedContextFromXmlFile(pathToInputFile, uri);
+        final NormalizedNodeContext nnContext = TestRestconfUtils
+                .loadNormalizedContextFromXmlFile(pathToInputFile, uri);
         final OutputStream output = new ByteArrayOutputStream();
-        xmlBodyWriter.writeTo(nnContext, null, null, null, mediaType, null, output);
+        xmlBodyWriter.writeTo(nnContext, null, null, null, mediaType, null,
+                output);
         assertTrue(output.toString().contains("lf-test"));
     }
 }
\ No newline at end of file