X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-rfc7950%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FYangParserSimpleTest.java;h=f042691e31bef32223b594f300400cef4fd7a63c;hb=7d1461b8704a4fa5f8865f6abd0fa5830bbdf980;hp=328ac01b3d2541cfc580314f0b6aea4987bf44e9;hpb=c8668229ad6e73d5ae03a52f4b87e8e4d2a67c6e;p=yangtools.git diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java index 328ac01b3d..f042691e31 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; -import java.util.Set; import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -58,8 +57,8 @@ public class YangParserSimpleTest { QName.create(testModule.getQNameModule(), "data")); assertNotNull("'anyxml data not found'", data); assertFalse(data.equals(null)); - assertEquals("AnyxmlEffectiveStatementImpl[qname=(urn:opendaylight:simple-nodes?revision=2013-07-30)data, " - + "path=AbsoluteSchemaPath{path=[(urn:opendaylight:simple-nodes?revision=2013-07-30)data]}]", + assertEquals("RegularAnyxmlEffectiveStatement{qname=(urn:opendaylight:simple-nodes?revision=2013-07-30)data, " + + "path=AbsoluteSchemaPath{path=[(urn:opendaylight:simple-nodes?revision=2013-07-30)data]}}", data.toString()); // test SchemaNode args @@ -70,11 +69,11 @@ public class YangParserSimpleTest { assertEquals(0, data.getUnknownSchemaNodes().size()); // test DataSchemaNode args assertFalse(data.isAugmenting()); - assertFalse(data.isConfiguration()); + assertEquals(Optional.of(Boolean.FALSE), data.effectiveConfig()); assertTrue(data.isMandatory()); - assertEquals("class != 'wheel'", data.getWhenCondition().get().getOriginalString()); - final Collection mustConstraints = data.getMustConstraints(); + assertEquals("class != 'wheel'", data.getWhenCondition().orElseThrow().toString()); + final Collection mustConstraints = data.getMustConstraints(); assertEquals(2, mustConstraints.size()); final String must1 = "ifType != 'ethernet' or (ifType = 'ethernet' and ifMTU = 1500)"; @@ -83,10 +82,10 @@ public class YangParserSimpleTest { boolean found1 = false; boolean found2 = false; for (final MustDefinition must : mustConstraints) { - if (must1.equals(must.toString())) { + if (must1.equals(must.getXpath().toString())) { found1 = true; assertEquals(Optional.of("An ethernet MTU must be 1500"), must.getErrorMessage()); - } else if (must2.equals(must.toString())) { + } else if (must2.equals(must.getXpath().toString())) { found2 = true; assertEquals(Optional.of("An atm MTU must be 64 .. 17966"), must.getErrorMessage()); assertEquals(Optional.of("anyxml data error-app-tag"), must.getErrorAppTag()); @@ -104,7 +103,7 @@ public class YangParserSimpleTest { QName.create(testModule.getQNameModule(), "data2")).orElse(null); assertNotNull("'anydata data not found'", anydata); - assertEquals("AnydataEffectiveStatementImpl{qname=(urn:opendaylight:simple-nodes?revision=2013-07-30)data2, " + assertEquals("RegularAnydataEffectiveStatement{qname=(urn:opendaylight:simple-nodes?revision=2013-07-30)data2, " + "path=AbsoluteSchemaPath{path=[(urn:opendaylight:simple-nodes?revision=2013-07-30)data2]}}", anydata.toString()); @@ -116,12 +115,12 @@ public class YangParserSimpleTest { assertEquals(0, anydata.getUnknownSchemaNodes().size()); // test DataSchemaNode args assertFalse(anydata.isAugmenting()); - assertFalse(anydata.isConfiguration()); + assertEquals(Optional.of(Boolean.FALSE), anydata.effectiveConfig()); assertTrue(anydata.isMandatory()); assertTrue(anydata.getWhenCondition().isPresent()); - assertEquals("class != 'wheel'", anydata.getWhenCondition().get().getOriginalString()); - final Collection mustConstraints = anydata.getMustConstraints(); + assertEquals("class != 'wheel'", anydata.getWhenCondition().orElseThrow().toString()); + final Collection mustConstraints = anydata.getMustConstraints(); assertEquals(2, mustConstraints.size()); final String must1 = "ifType != 'ethernet' or (ifType = 'ethernet' and ifMTU = 1500)"; @@ -130,10 +129,10 @@ public class YangParserSimpleTest { boolean found1 = false; boolean found2 = false; for (final MustDefinition must : mustConstraints) { - if (must1.equals(must.toString())) { + if (must1.equals(must.getXpath().toString())) { found1 = true; assertEquals(Optional.of("An ethernet MTU must be 1500"), must.getErrorMessage()); - } else if (must2.equals(must.toString())) { + } else if (must2.equals(must.getXpath().toString())) { found2 = true; assertEquals(Optional.of("An atm MTU must be 64 .. 17966"), must.getErrorMessage()); assertEquals(Optional.of("anydata data error-app-tag"), must.getErrorAppTag()); @@ -158,11 +157,11 @@ public class YangParserSimpleTest { assertEquals(0, nodes.getUnknownSchemaNodes().size()); // test DataSchemaNode args assertFalse(nodes.isAugmenting()); - assertFalse(nodes.isConfiguration()); + assertEquals(Optional.of(Boolean.FALSE), nodes.effectiveConfig()); // constraints - assertEquals("class != 'wheel'", nodes.getWhenCondition().get().getOriginalString()); - final Collection mustConstraints = nodes.getMustConstraints(); + assertEquals("class != 'wheel'", nodes.getWhenCondition().orElseThrow().toString()); + final Collection mustConstraints = nodes.getMustConstraints(); assertEquals(2, mustConstraints.size()); final String must1 = "ifType != 'atm' or (ifType = 'atm' and ifMTU <= 17966 and ifMTU >= 64)"; @@ -172,10 +171,10 @@ public class YangParserSimpleTest { boolean found1 = false; boolean found2 = false; for (final MustDefinition must : mustConstraints) { - if (must1.equals(must.toString())) { + if (must1.equals(must.getXpath().toString())) { found1 = true; assertEquals(Optional.of(errMsg1), must.getErrorMessage()); - } else if (must2.equals(must.toString())) { + } else if (must2.equals(must.getXpath().toString())) { found2 = true; assertFalse(must.getErrorMessage().isPresent()); assertFalse(must.getErrorAppTag().isPresent()); @@ -189,12 +188,11 @@ public class YangParserSimpleTest { assertTrue(nodes.isPresenceContainer()); // typedef - final Set> typedefs = nodes.getTypeDefinitions(); + final Collection> typedefs = nodes.getTypeDefinitions(); assertEquals(1, typedefs.size()); final TypeDefinition nodesType = typedefs.iterator().next(); final QName typedefQName = QName.create(SN, "nodes-type"); assertEquals(typedefQName, nodesType.getQName()); - assertEquals(SN_NODES_PATH.createChild(QName.create(SN, "nodes-type")), nodesType.getPath()); assertFalse(nodesType.getDescription().isPresent()); assertFalse(nodesType.getReference().isPresent()); assertEquals(Status.CURRENT, nodesType.getStatus()); @@ -206,24 +204,21 @@ public class YangParserSimpleTest { final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create( testModule.getQNameModule(), "added")); assertEquals(createPath("nodes", "added"), added.getPath()); - assertEquals(createPath("mytype"), added.getType().getPath()); + assertEquals(createPath("mytype").getLastComponent(), added.getType().getQName()); final ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName(QName.create( testModule.getQNameModule(), "links")); assertFalse(links.isUserOrdered()); - final Set groupings = nodes.getGroupings(); + final Collection groupings = nodes.getGroupings(); assertEquals(1, groupings.size()); final GroupingDefinition nodeGroup = groupings.iterator().next(); - final QName groupQName = QName.create(SN, "node-group"); - assertEquals(groupQName, nodeGroup.getQName()); - final SchemaPath nodeGroupPath = SN_NODES_PATH.createChild(groupQName); - assertEquals(nodeGroupPath, nodeGroup.getPath()); + assertEquals(QName.create(SN, "node-group"), nodeGroup.getQName()); - final Set uses = nodes.getUses(); + final Collection uses = nodes.getUses(); assertEquals(1, uses.size()); final UsesNode use = uses.iterator().next(); - assertEquals(nodeGroupPath, use.getGroupingPath()); + assertEquals(nodeGroup, use.getSourceGrouping()); }