Search in sources :

Example 1 with LeafEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement in project yangtools by opendaylight.

the class EffectiveStatementTypeTest method testBoolean.

@Test
public void testBoolean() {
    currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-boolean"));
    assertNotNull(currentLeaf.getType());
    final BooleanTypeDefinition booleanEff = (BooleanTypeDefinition) ((TypeEffectiveStatement<?>) ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next()).getTypeDefinition();
    assertNull(booleanEff.getBaseType());
    assertEquals(Optional.empty(), booleanEff.getUnits());
    assertEquals(Optional.empty(), booleanEff.getDefaultValue());
    assertEquals("boolean", booleanEff.getQName().getLocalName());
    assertNotNull(booleanEff.getUnknownSchemaNodes());
    assertFalse(booleanEff.getDescription().isPresent());
    assertFalse(booleanEff.getReference().isPresent());
    assertEquals(Status.CURRENT, booleanEff.getStatus());
    assertNotNull(booleanEff.toString());
}
Also used : LeafEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement) BooleanTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition) Test(org.junit.Test)

Example 2 with LeafEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement in project yangtools by opendaylight.

the class EffectiveStatementTypeTest method testLeafrefWithDeref.

@Test
public void testLeafrefWithDeref() {
    currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-leafref-deref"));
    assertNotNull(currentLeaf.getType());
    final LeafrefTypeDefinition leafrefEff = (LeafrefTypeDefinition) ((TypeDefinitionAware) ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next()).getTypeDefinition();
    assertEquals("deref(../container-test)/leaf-test", leafrefEff.getPathStatement().getOriginalString());
    assertNull(leafrefEff.getBaseType());
    assertEquals(Optional.empty(), leafrefEff.getUnits());
    assertEquals(Optional.empty(), leafrefEff.getDefaultValue());
    assertNotNull(leafrefEff.toString());
    assertEquals("leafref", leafrefEff.getQName().getLocalName());
    assertEquals(Status.CURRENT, leafrefEff.getStatus());
    assertNotNull(leafrefEff.getUnknownSchemaNodes());
    assertFalse(leafrefEff.getDescription().isPresent());
    assertFalse(leafrefEff.getReference().isPresent());
    assertNotNull(leafrefEff.hashCode());
    assertFalse(leafrefEff.equals(null));
    assertFalse(leafrefEff.equals("test"));
    assertTrue(leafrefEff.equals(leafrefEff));
}
Also used : LeafrefTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition) LeafEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement) Test(org.junit.Test)

Example 3 with LeafEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement in project yangtools by opendaylight.

the class EffectiveStatementTypeTest method testInstanceIdentifier.

@Test
public void testInstanceIdentifier() {
    currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-instance-identifier"));
    assertNotNull(currentLeaf.getType());
    final InstanceIdentifierTypeDefinition instanceIdentEff = (InstanceIdentifierTypeDefinition) ((TypeEffectiveStatement<?>) ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next()).getTypeDefinition();
    assertNotNull(instanceIdentEff.toString());
    assertFalse(instanceIdentEff.requireInstance());
    assertEquals("instance-identifier", instanceIdentEff.getQName().getLocalName());
    assertNull(instanceIdentEff.getBaseType());
    assertEquals(Optional.empty(), instanceIdentEff.getDefaultValue());
    assertNotNull(instanceIdentEff.getUnknownSchemaNodes());
    assertFalse(instanceIdentEff.getDescription().isPresent());
    assertFalse(instanceIdentEff.getReference().isPresent());
    assertEquals(Optional.empty(), instanceIdentEff.getUnits());
    assertEquals(Status.CURRENT, instanceIdentEff.getStatus());
    assertNotNull(instanceIdentEff.hashCode());
    assertFalse(instanceIdentEff.equals(null));
    assertFalse(instanceIdentEff.equals("test"));
    assertTrue(instanceIdentEff.equals(instanceIdentEff));
}
Also used : LeafEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement) InstanceIdentifierTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition) Test(org.junit.Test)

Example 4 with LeafEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement in project yangtools by opendaylight.

the class EffectiveStatementTypeTest method testString.

@Test
public void testString() {
    currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-string"));
    assertNotNull(currentLeaf.getType());
    final StringTypeDefinition stringEff = (StringTypeDefinition) ((TypeEffectiveStatement<?>) ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next()).getTypeDefinition();
    assertEquals("string", stringEff.getQName().getLocalName());
    assertEquals(Status.CURRENT, stringEff.getStatus());
    assertEquals(Optional.empty(), stringEff.getUnits());
    assertEquals(Optional.empty(), stringEff.getDefaultValue());
    assertNotNull(stringEff.getUnknownSchemaNodes());
    assertNull(stringEff.getBaseType());
    assertFalse(stringEff.getDescription().isPresent());
    assertFalse(stringEff.getReference().isPresent());
    assertNotNull(stringEff.toString());
    assertNotNull(stringEff.hashCode());
    assertFalse(stringEff.equals(null));
    assertFalse(stringEff.equals("test"));
    assertTrue(stringEff.equals(stringEff));
    assertFalse(stringEff.getLengthConstraint().isPresent());
    assertNotNull(stringEff.getPatternConstraints());
}
Also used : StringTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition) LeafEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement) Test(org.junit.Test)

Example 5 with LeafEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement in project yangtools by opendaylight.

the class EffectiveStatementTypeTest method testLeafref.

@Test
public void testLeafref() {
    currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-leafref"));
    assertNotNull(currentLeaf.getType());
    final LeafrefTypeDefinition leafrefEff = (LeafrefTypeDefinition) ((TypeDefinitionAware) ((LeafEffectiveStatement) currentLeaf).effectiveSubstatements().iterator().next()).getTypeDefinition();
    assertEquals("/container-test/leaf-test", leafrefEff.getPathStatement().getOriginalString());
    assertNull(leafrefEff.getBaseType());
    assertEquals(Optional.empty(), leafrefEff.getUnits());
    assertEquals(Optional.empty(), leafrefEff.getDefaultValue());
    assertNotNull(leafrefEff.toString());
    assertEquals("leafref", leafrefEff.getQName().getLocalName());
    assertEquals(Status.CURRENT, leafrefEff.getStatus());
    assertNotNull(leafrefEff.getUnknownSchemaNodes());
    assertFalse(leafrefEff.getDescription().isPresent());
    assertFalse(leafrefEff.getReference().isPresent());
    assertNotNull(leafrefEff.hashCode());
    assertFalse(leafrefEff.equals(null));
    assertFalse(leafrefEff.equals("test"));
    assertTrue(leafrefEff.equals(leafrefEff));
}
Also used : LeafrefTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition) LeafEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement) Test(org.junit.Test)

Aggregations

LeafEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement)16 Test (org.junit.Test)15 GroupingEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement)3 ModuleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)3 LeafrefTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition)2 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)1 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)1 ContainerEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement)1 NotificationEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement)1 UnitsEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.UnitsEffectiveStatement)1 BinaryTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition)1 BitsTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition)1 Bit (org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit)1 BooleanTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition)1 DecimalTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition)1 EmptyTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition)1 EnumTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition)1 EnumPair (org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair)1 IdentityrefTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition)1 InstanceIdentifierTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition)1