use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug7246Test method test.
@Test
public void test() throws Exception {
final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangResource("/bug7246/yang/rpc-test.yang");
final ContainerNode inputStructure = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(qN("my-name"))).withChild(ImmutableNodes.leafNode(new NodeIdentifier(qN("my-name")), "my-value")).build();
final SchemaPath rootPath = SchemaPath.create(true, qN("my-name"), qN("input"));
final Writer writer = new StringWriter();
final String jsonOutput = normalizedNodeToJsonStreamTransformation(schemaContext, rootPath, writer, inputStructure);
assertEquals(JsonParser.parseReader(new FileReader(new File(getClass().getResource("/bug7246/json/expected-output.json").toURI()), StandardCharsets.UTF_8)), JsonParser.parseString(jsonOutput));
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug8083Test method testInstanceIdentifierPathWithInstanceIdentifierListKey.
@Test
public void testInstanceIdentifierPathWithInstanceIdentifierListKey() throws IOException, URISyntaxException {
final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/foobar.yang");
final String inputJson = loadTextFile("/bug8083/json/foobar.json");
// deserialization
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
final JsonParserStream jsonParser = JsonParserStream.create(streamWriter, JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext));
jsonParser.parse(new JsonReader(new StringReader(inputJson)));
final NormalizedNode transformedInput = result.getResult();
assertNotNull(transformedInput);
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug8083Test method testInstanceIdentifierPathWithEmptyListKey.
@Test
public void testInstanceIdentifierPathWithEmptyListKey() throws IOException, URISyntaxException {
final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangResource("/bug8083/yang/baz.yang");
final String inputJson = loadTextFile("/bug8083/json/baz.json");
// deserialization
final NormalizedNodeResult result = new NormalizedNodeResult();
final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
final JsonParserStream jsonParser = JsonParserStream.create(streamWriter, JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext));
jsonParser.parse(new JsonReader(new StringReader(inputJson)));
final NormalizedNode transformedInput = result.getResult();
assertNotNull(transformedInput);
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug4969Test method newParserLeafRefTest.
@Test
public void newParserLeafRefTest() throws IOException, URISyntaxException {
EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/bug-4969/yang");
assertNotNull(context);
verifyNormalizedNodeResult(context);
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug4969Test method newParserLeafRefTest2.
@Test
public void newParserLeafRefTest2() throws URISyntaxException, IOException {
EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/leafref/yang");
assertNotNull(context);
parseJsonToNormalizedNodes(context);
}
Aggregations