1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.junit.Assert.assertTrue;
5 import java.io.IOException;
7 import javax.ws.rs.WebApplicationException;
11 public class ToJsonChoiceCaseTest extends YangAndXmlAndDataSchemaLoader {
14 public static void initialization() {
15 dataLoad("/yang-to-json-conversion/choice");
19 * Test when some data are in one case node and other in another. This isn't
20 * correct. Next Json validator should return error because nodes has to be
21 * from one case below concrete choice.
25 public void nodeSchemasOnVariousChoiceCasePathTest() {
27 TestUtils.writeCompNodeWithSchemaContextToJson(
28 TestUtils.loadCompositeNode("/yang-to-json-conversion/choice/xml/data_various_path_err.xml"),
29 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
30 } catch (WebApplicationException | IOException e) {
37 * Test when some data are in one case node and other in another.
38 * Additionally data are loadef from various choices. This isn't correct.
39 * Next Json validator should return error because nodes has to be from one
40 * case below concrete choice.
44 public void nodeSchemasOnVariousChoiceCasePathAndMultipleChoicesTest() {
47 .writeCompNodeWithSchemaContextToJson(
49 .loadCompositeNode("/yang-to-json-conversion/choice/xml/data_more_choices_same_level_various_paths_err.xml"),
50 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
51 } catch (WebApplicationException | IOException e) {
58 * Test when second level data are red first, then first and at the end
59 * third level. Level represents pass through couple choice-case
63 public void nodeSchemasWithRandomOrderAccordingLevel() {
65 TestUtils.writeCompNodeWithSchemaContextToJson(
66 TestUtils.loadCompositeNode("/yang-to-json-conversion/choice/xml/data_random_level.xml"),
67 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
69 } catch (WebApplicationException | IOException e) {
76 * Test when element from no first case is used
79 public void nodeSchemasNotInFirstCase() {
81 TestUtils.writeCompNodeWithSchemaContextToJson(
82 TestUtils.loadCompositeNode("/yang-to-json-conversion/choice/xml/data_no_first_case.xml"),
83 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
84 } catch (WebApplicationException | IOException e) {
91 * Test when element in case is list
94 public void nodeSchemaAsList() {
96 TestUtils.writeCompNodeWithSchemaContextToJson(
97 TestUtils.loadCompositeNode("/yang-to-json-conversion/choice/xml/data_list.xml"),
98 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
99 } catch (WebApplicationException | IOException e) {
100 // shouldn't end here
106 * Test when element in case is container
109 public void nodeSchemaAsContainer() {
111 TestUtils.writeCompNodeWithSchemaContextToJson(
112 TestUtils.loadCompositeNode("/yang-to-json-conversion/choice/xml/data_container.xml"),
113 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
114 } catch (WebApplicationException | IOException e) {
115 // shouldn't end here
121 * Test when element in case is leaflist
124 public void nodeSchemaAsLeafList() {
126 TestUtils.writeCompNodeWithSchemaContextToJson(
127 TestUtils.loadCompositeNode("/yang-to-json-conversion/choice/xml/data_leaflist.xml"),
128 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
129 } catch (WebApplicationException | IOException e) {
130 // shouldn't end here
139 public void nodeSchemasInMultipleChoicesTest() {
142 .writeCompNodeWithSchemaContextToJson(TestUtils
143 .loadCompositeNode("/yang-to-json-conversion/choice/xml/data_more_choices_same_level.xml"),
144 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
145 } catch (WebApplicationException | IOException e) {
146 // shouldn't end here
152 * Test whether is possible to find data schema for node which is specified
153 * as dirrect subnode of choice (case without CASE key word)
156 public void nodeSchemasInCaseNotDefinedWithCaseKeyword() {
158 TestUtils.writeCompNodeWithSchemaContextToJson(TestUtils
159 .loadCompositeNode("/yang-to-json-conversion/choice/xml/data_case_defined_without_case.xml"),
160 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
161 } catch (WebApplicationException | IOException e) {
162 // shouldn't end here
168 * Test of multiple use of choices
171 public void nodeSchemasInThreeChoicesAtSameLevel() {
173 TestUtils.writeCompNodeWithSchemaContextToJson(TestUtils
174 .loadCompositeNode("/yang-to-json-conversion/choice/xml/data_three_choices_same_level.xml"),
175 "/yang-to-json-conversion/choice/xml", modules, dataSchemaNode);
176 } catch (WebApplicationException | IOException e) {
177 // shouldn't end here