X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Fjson%2Fto%2Fcnsn%2Ftest%2FJsonToCnSnTest.java;h=7b71e42ab8ed669516c4e724231628c8d6bd4908;hb=refs%2Fchanges%2F27%2F8927%2F3;hp=47e329cc3ef11a4cdfc8842c9a1285a445989517;hpb=e3b0eb3bd7f61ab9f54a61d8b8e2d37685262e2c;p=controller.git
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonToCnSnTest.java
index 47e329cc3e..7b71e42ab8 100644
--- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonToCnSnTest.java
+++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonToCnSnTest.java
@@ -17,7 +17,6 @@ import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider;
@@ -82,8 +81,8 @@ public class JsonToCnSnTest {
}
/**
- * List contains 4 items and in every item are other elements. It is
- * supposed that there should be: lf11, lflst11, cont11, lst11
+ * List contains 4 items and in every item are other elements. It is supposed that there should be: lf11, lflst11,
+ * cont11, lst11
*/
@Test
public void multipleItemsInListTest() {
@@ -116,14 +115,19 @@ public class JsonToCnSnTest {
public void incorrectTopLevelElementsTest() {
RestconfDocumentedException cause1 = null;
try {
- TestUtils.readInputToCnSn("/json-to-cnsn/wrong-top-level1.json", true, JsonToCompositeNodeProvider.INSTANCE);
+ TestUtils
+ .readInputToCnSn("/json-to-cnsn/wrong-top-level1.json", true, JsonToCompositeNodeProvider.INSTANCE);
} catch (RestconfDocumentedException e) {
cause1 = e;
}
assertNotNull(cause1);
- assertTrue(cause1.getErrors().get( 0 ).getErrorMessage().contains(
- "First element in Json Object has to be \"Object\" or \"Array with one Object element\". Other scenarios are not supported yet."));
+ assertTrue(cause1
+ .getErrors()
+ .get(0)
+ .getErrorMessage()
+ .contains(
+ "First element in Json Object has to be \"Object\" or \"Array with one Object element\". Other scenarios are not supported yet."));
RestconfDocumentedException cause2 = null;
try {
@@ -133,26 +137,29 @@ public class JsonToCnSnTest {
cause2 = e;
}
assertNotNull(cause2);
- assertTrue(cause2.getErrors().get( 0 ).getErrorMessage().contains(
- "Json Object should contain one element"));
+ assertTrue(cause2.getErrors().get(0).getErrorMessage().contains("Json Object should contain one element"));
RestconfDocumentedException cause3 = null;
try {
TestUtils
- .readInputToCnSn("/json-to-cnsn/wrong-top-level3.json", true, JsonToCompositeNodeProvider.INSTANCE);
+ .readInputToCnSn("/json-to-cnsn/wrong-top-level3.json", true, JsonToCompositeNodeProvider.INSTANCE);
} catch (RestconfDocumentedException e) {
cause3 = e;
}
assertNotNull(cause3);
- assertTrue(cause3.getErrors().get( 0 ).getErrorMessage().contains(
- "First element in Json Object has to be \"Object\" or \"Array with one Object element\". Other scenarios are not supported yet."));
+ assertTrue(cause3
+ .getErrors()
+ .get(0)
+ .getErrorMessage()
+ .contains(
+ "First element in Json Object has to be \"Object\" or \"Array with one Object element\". Other scenarios are not supported yet."));
}
/**
- * if leaf list with no data is in json then no corresponding data is
- * created in composite node. if leaf with no data then exception is raised
+ * if leaf list with no data is in json then no corresponding data is created in composite node. if leaf with no
+ * data then exception is raised
*/
@Test
public void emptyDataReadTest() {
@@ -172,7 +179,7 @@ public class JsonToCnSnTest {
try {
TestUtils.readInputToCnSn("/json-to-cnsn/empty-data1.json", true, JsonToCompositeNodeProvider.INSTANCE);
} catch (RestconfDocumentedException e) {
- reason = e.getErrors().get( 0 ).getErrorMessage();
+ reason = e.getErrors().get(0).getErrorMessage();
}
assertTrue(reason.contains("Expected value at line"));
@@ -180,17 +187,16 @@ public class JsonToCnSnTest {
}
@Test
- public void testJsonBlankInput() throws Exception{
- InputStream inputStream = new ByteArrayInputStream( "".getBytes() );
- CompositeNode compositeNode =
- JsonToCompositeNodeProvider.INSTANCE.readFrom(null, null, null, null, null, inputStream);
- assertNull( compositeNode );
+ public void testJsonBlankInput() throws Exception {
+ InputStream inputStream = new ByteArrayInputStream("".getBytes());
+ CompositeNode compositeNode = JsonToCompositeNodeProvider.INSTANCE.readFrom(null, null, null, null, null,
+ inputStream);
+ assertNull(compositeNode);
}
/**
- * Tests whether namespace stay unchanged if concrete values are
- * present in composite or simple node and if the method for update is
- * called.
+ * Tests whether namespace stay unchanged if concrete values are present in composite or simple node and if
+ * the method for update is called.
*
*/
@Test
@@ -284,13 +290,14 @@ public class JsonToCnSnTest {
}
- private void simpleTest(final String jsonPath, final String yangPath, final String topLevelElementName, final String namespace,
- final String moduleName) {
+ private void simpleTest(final String jsonPath, final String yangPath, final String topLevelElementName,
+ final String namespace, final String moduleName) {
CompositeNode compNode = loadAndNormalizeData(jsonPath, yangPath, topLevelElementName, moduleName);
verifyCompositeNode(compNode, namespace);
}
- private CompositeNode loadAndNormalizeData(final String jsonPath, final String yangPath, final String topLevelElementName, final String moduleName) {
+ private CompositeNode loadAndNormalizeData(final String jsonPath, final String yangPath,
+ final String topLevelElementName, final String moduleName) {
CompositeNode compositeNode = TestUtils.readInputToCnSn(jsonPath, false, JsonToCompositeNodeProvider.INSTANCE);
assertNotNull(compositeNode);
@@ -395,7 +402,7 @@ public class JsonToCnSnTest {
TestUtils.readInputToCnSn("/json-to-cnsn/unsupported-json-format.json", true,
JsonToCompositeNodeProvider.INSTANCE);
} catch (RestconfDocumentedException e) {
- exceptionMessage = e.getErrors().get( 0 ).getErrorMessage();
+ exceptionMessage = e.getErrors().get(0).getErrorMessage();
}
assertTrue(exceptionMessage.contains("Root element of Json has to be Object"));
}