use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug5830Test method testPresenceContainer.
private static void testPresenceContainer() throws DataValidationFailedException {
final EffectiveModelContext schemaContext = TestModel.createTestContext("/bug-5830/foo-presence.yang");
assertNotNull("Schema context must not be null.", schemaContext);
testContainerIsNotPresent(schemaContext);
try {
testContainerIsPresent(schemaContext);
fail("Should fail due to missing mandatory node under present presence container.");
} catch (IllegalArgumentException e) {
assertEquals("Node (foo?revision=2016-05-17)task-data is missing mandatory descendant /(foo?revision=2016-05-17)" + "mandatory-data", e.getMessage());
}
testMandatoryDataLeafIsPresent(schemaContext);
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug6856Test method testImplicitInputAndOutputInRpc.
@Test
public void testImplicitInputAndOutputInRpc() throws Exception {
final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangResources(Bug6856Test.class, "/bugs/bug-6856/foo.yang");
assertNotNull(schemaContext);
final OutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream);
final Module fooModule = schemaContext.findModule("foo", Revision.of("2017-02-28")).get();
YinExportUtils.writeModuleAsYinText(fooModule.asEffectiveStatement(), bufferedOutputStream);
final String output = byteArrayOutputStream.toString();
assertNotNull(output);
assertFalse(output.isEmpty());
assertFalse(output.contains("<input>"));
assertFalse(output.contains("<output>"));
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class SimpleModuleTest method testSetOfModules.
private void testSetOfModules(final Collection<SourceIdentifier> source) throws Exception {
final EffectiveModelContext schemaContext = schemaContextFactory.createEffectiveModelContext(source).get();
final File outDir = new File("target/collection");
outDir.mkdirs();
for (final Module module : schemaContext.getModules()) {
exportModule(module, outDir);
}
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class YT588Test method test.
@Test
public void test() {
EffectiveModelContext context = YangParserTestUtils.parseYangResource("/yt588.yang");
QName root = QName.create(NS, REV, "root");
QName leafRef2 = QName.create(NS, REV, "leaf-ref-2");
QName conGrp = QName.create(NS, REV, "con-grp");
QName leafRef = QName.create(NS, REV, "leaf-ref");
SchemaNode findDataSchemaNode = context.findDataTreeChild(root, conGrp, leafRef).get();
SchemaNode findDataSchemaNode2 = context.findDataTreeChild(root, leafRef2).get();
assertThat(findDataSchemaNode, isA(LeafSchemaNode.class));
assertThat(findDataSchemaNode2, isA(LeafSchemaNode.class));
LeafSchemaNode leafRefNode = (LeafSchemaNode) findDataSchemaNode;
LeafSchemaNode leafRefNode2 = (LeafSchemaNode) findDataSchemaNode2;
assertThat(leafRefNode.getType(), isA(LeafrefTypeDefinition.class));
assertThat(leafRefNode2.getType(), isA(LeafrefTypeDefinition.class));
EffectiveStatement<?, ?> found = SchemaInferenceStack.ofDataTreePath(context, root, conGrp, leafRef).resolvePathExpression(((LeafrefTypeDefinition) leafRefNode.getType()).getPathStatement());
assertThat(((TypedDataSchemaNode) found).getType(), isA(BinaryTypeDefinition.class));
found = SchemaInferenceStack.ofDataTreePath(context, root, leafRef2).resolvePathExpression(((LeafrefTypeDefinition) leafRefNode2.getType()).getPathStatement());
assertThat(((TypedDataSchemaNode) found).getType(), isA(Int16TypeDefinition.class));
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class MultipleRevImportBug6875Test method testYang10.
@Test
public void testYang10() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("shared-schema-repo-multiple-rev-import-test");
final SettableSchemaProvider<IRSchemaSource> foo = getSourceProvider("/rfc7950/bug6875/yang1-0/foo.yang");
final SettableSchemaProvider<IRSchemaSource> bar1 = getSourceProvider("/rfc7950/bug6875/yang1-0/bar@1999-01-01.yang");
final SettableSchemaProvider<IRSchemaSource> bar2 = getSourceProvider("/rfc7950/bug6875/yang1-0/bar@2017-02-06.yang");
setAndRegister(sharedSchemaRepository, foo);
setAndRegister(sharedSchemaRepository, bar1);
setAndRegister(sharedSchemaRepository, bar2);
final ListenableFuture<EffectiveModelContext> schemaContextFuture = sharedSchemaRepository.createEffectiveModelContextFactory().createEffectiveModelContext(foo.getId(), bar1.getId(), bar2.getId());
assertTrue(schemaContextFuture.isDone());
final ExecutionException ex = assertThrows(ExecutionException.class, schemaContextFuture::get);
final Throwable cause = ex.getCause();
assertThat(cause, instanceOf(IllegalArgumentException.class));
assertThat(cause.getMessage(), startsWith("Module:bar imported twice with different revisions"));
}
Aggregations