use of org.opendaylight.yangtools.yang.model.api.InputSchemaNode in project yangtools by opendaylight.
the class Bug9241Test method testImplicitInputAndOutputInAction.
@Test
public void testImplicitInputAndOutputInAction() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug9241/foo.yang");
assertNotNull(schemaContext);
final Module fooModule = schemaContext.findModule("foo", Revision.of("2017-10-13")).get();
final ContainerSchemaNode actionCont = (ContainerSchemaNode) fooModule.getDataChildByName(QName.create(fooModule.getQNameModule(), "action-cont"));
final ActionDefinition actionInCont = actionCont.getActions().iterator().next();
final InputSchemaNode input = actionInCont.getInput();
assertNotNull(input);
assertEquals(1, input.getChildNodes().size());
assertEquals(StatementOrigin.CONTEXT, ((EffectiveStatement<?, ?>) input).statementOrigin());
final OutputSchemaNode output = actionInCont.getOutput();
assertNotNull(output);
assertEquals(1, output.getChildNodes().size());
assertEquals(StatementOrigin.CONTEXT, ((EffectiveStatement<?, ?>) output).statementOrigin());
}
use of org.opendaylight.yangtools.yang.model.api.InputSchemaNode in project yangtools by opendaylight.
the class OperationAsContainer method getChildNodes.
@Override
public final Collection<? extends DataSchemaNode> getChildNodes() {
final List<DataSchemaNode> ret = new ArrayList<>();
final InputSchemaNode input = getInput();
if (input != null) {
ret.add(input);
}
final OutputSchemaNode output = getOutput();
if (output != null) {
ret.add(output);
}
return ret;
}
use of org.opendaylight.yangtools.yang.model.api.InputSchemaNode in project yangtools by opendaylight.
the class RpcStmtTest method testImplicitInputAndOutput.
@Test
public void testImplicitInputAndOutput() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rpc-stmt-test/bar.yang");
assertNotNull(schemaContext);
final Module barModule = schemaContext.findModule("bar", Revision.of("2016-11-25")).get();
final Collection<? extends RpcDefinition> rpcs = barModule.getRpcs();
assertEquals(1, rpcs.size());
final RpcDefinition barRpc = rpcs.iterator().next();
final InputSchemaNode input = barRpc.getInput();
assertNotNull(input);
assertEquals(2, input.getChildNodes().size());
assertEquals(StatementOrigin.CONTEXT, ((EffectiveStatement<?, ?>) input).statementOrigin());
final OutputSchemaNode output = barRpc.getOutput();
assertNotNull(output);
assertEquals(2, output.getChildNodes().size());
assertEquals(StatementOrigin.CONTEXT, ((EffectiveStatement<?, ?>) output).statementOrigin());
}
use of org.opendaylight.yangtools.yang.model.api.InputSchemaNode in project yangtools by opendaylight.
the class RpcStmtTest method rpcTest.
@Test
public void rpcTest() throws ReactorException {
final EffectiveModelContext result = RFC7950Reactors.defaultReactor().newBuild().addSource(sourceForResource("/model/baz.yang")).addSource(sourceForResource("/model/bar.yang")).addSource(sourceForResource("/rpc-stmt-test/foo.yang")).buildEffective();
assertNotNull(result);
final Module testModule = result.findModules("baz").iterator().next();
assertEquals(1, testModule.getRpcs().size());
final RpcDefinition rpc = testModule.getRpcs().iterator().next();
assertEquals("get-config", rpc.getQName().getLocalName());
final InputSchemaNode input = rpc.getInput();
assertNotNull(input);
assertEquals(2, input.getChildNodes().size());
final ContainerSchemaNode container = (ContainerSchemaNode) input.getDataChildByName(QName.create(testModule.getQNameModule(), "source"));
assertNotNull(container);
AnyxmlSchemaNode anyXml = (AnyxmlSchemaNode) input.getDataChildByName(QName.create(testModule.getQNameModule(), "filter"));
assertNotNull(anyXml);
final OutputSchemaNode output = rpc.getOutput();
assertNotNull(output);
assertEquals(1, output.getChildNodes().size());
anyXml = (AnyxmlSchemaNode) output.getDataChildByName(QName.create(testModule.getQNameModule(), "data"));
assertNotNull(anyXml);
final Module fooModule = result.findModule("foo", Revision.of("2016-09-23")).get();
final Collection<? extends RpcDefinition> rpcs = fooModule.getRpcs();
assertEquals(2, rpcs.size());
RpcDefinition fooRpc1 = null;
RpcDefinition fooRpc2 = null;
for (RpcDefinition rpcDefinition : rpcs) {
if ("foo-rpc-1".equals(rpcDefinition.getQName().getLocalName())) {
fooRpc1 = rpcDefinition;
} else if ("foo-rpc-2".equals(rpcDefinition.getQName().getLocalName())) {
fooRpc2 = rpcDefinition;
}
}
assertFalse(fooRpc1.equals(null));
assertFalse(fooRpc1.equals("str"));
assertFalse(fooRpc1.equals(fooRpc2));
assertNotEquals(fooRpc1.getInput().hashCode(), fooRpc2.getInput().hashCode());
assertNotEquals(fooRpc1.getOutput().hashCode(), fooRpc2.getOutput().hashCode());
assertTrue(fooRpc1.getInput().equals(fooRpc1.getInput()));
assertFalse(fooRpc1.getInput().equals(null));
assertFalse(fooRpc1.getInput().equals("str"));
assertFalse(fooRpc1.getInput().equals(fooRpc2.getInput()));
assertTrue(fooRpc1.getOutput().equals(fooRpc1.getOutput()));
assertFalse(fooRpc1.getOutput().equals(null));
assertFalse(fooRpc1.getOutput().equals("str"));
assertFalse(fooRpc1.getOutput().equals(fooRpc2.getOutput()));
}
use of org.opendaylight.yangtools.yang.model.api.InputSchemaNode in project yangtools by opendaylight.
the class DeviationResolutionTest method testDeviateAdd.
@Test
public void testDeviateAdd() throws Exception {
final EffectiveModelContext schemaContext = TestUtils.parseYangSource("/deviation-resolution-test/deviation-add/foo.yang", "/deviation-resolution-test/deviation-add/bar.yang");
assertNotNull(schemaContext);
final Module barModule = schemaContext.findModule("bar", Revision.of("2017-01-20")).get();
final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "my-leaf-list"));
assertNotNull(myLeafList);
assertEquals(Optional.of(Boolean.FALSE), myLeafList.effectiveConfig());
assertEquals(3, myLeafList.getDefaults().size());
final ElementCountConstraint constraint = myLeafList.getElementCountConstraint().get();
assertEquals((Object) 10, constraint.getMaxElements());
assertEquals((Object) 5, constraint.getMinElements());
assertNotNull(myLeafList.getType().getUnits());
final ListSchemaNode myList = (ListSchemaNode) barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "my-list"));
assertNotNull(myList);
assertEquals(2, myList.getUniqueConstraints().size());
final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "my-choice"));
assertNotNull(myChoice);
assertEquals("c2", myChoice.getDefaultCase().get().getQName().getLocalName());
final RpcDefinition myRpc = barModule.getRpcs().iterator().next();
final InputSchemaNode input = myRpc.getInput();
assertEquals(2, input.getMustConstraints().size());
final OutputSchemaNode output = myRpc.getOutput();
assertEquals(2, output.getMustConstraints().size());
final NotificationDefinition myNotification = barModule.getNotifications().iterator().next();
assertEquals(2, myNotification.getMustConstraints().size());
final AnyxmlSchemaNode myAnyxml = (AnyxmlSchemaNode) barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "my-anyxml"));
assertNotNull(myAnyxml);
assertTrue(myAnyxml.isMandatory());
final AnydataSchemaNode myAnyData = (AnydataSchemaNode) barModule.findDataChildByName(QName.create(barModule.getQNameModule(), "my-anydata")).orElse(null);
assertNotNull(myAnyData);
assertTrue(myAnyData.isMandatory());
}
Aggregations