--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.model.api;
+
+import com.google.common.annotations.Beta;
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Interface describing YANG 'deviate' statement
+ *
+ * The 'deviate' statement defines how the device's implementation of
+ * the target node deviates from its original definition.
+ * The argument is one of the strings "not-supported", "add", "replace", or "delete".
+ */
+@Beta
+public interface DeviateDefinition {
+
+ /**
+ *
+ * @return enum which describes the type of this deviate statement
+ */
+ DeviateKind getDeviateType();
+
+ /**
+ *
+ * @return value of the deviated config statement or null if it is not deviated
+ */
+ Boolean getDeviatedConfig();
+
+ /**
+ *
+ * @return value of the deviated default statement or null if it is not deviated
+ */
+ String getDeviatedDefault();
+
+ /**
+ *
+ * @return value of the deviated mandatory statement or null if it is not deviated
+ */
+ Boolean getDeviatedMandatory();
+
+ /**
+ *
+ * @return value of the deviated max-elements statement or null if it is not deviated
+ */
+ Integer getDeviatedMaxElements();
+
+ /**
+ *
+ * @return value of the deviated min-elements statement or null if it is not deviated
+ */
+ Integer getDeviatedMinElements();
+
+ /**
+ *
+ * @return set of the deviated must statements
+ */
+ Set<MustDefinition> getDeviatedMusts();
+
+ /**
+ *
+ * @return deviated type statement or null if it is not deviated
+ */
+ TypeDefinition<?> getDeviatedType();
+
+ /**
+ *
+ * @return collection of the deviated unique statements
+ */
+ Collection<UniqueConstraint> getDeviatedUniques();
+
+ /**
+ *
+ * @return value of the deviated units statement or null if it is not deviated
+ */
+ String getDeviatedUnits();
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.model.api;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * Enum describing YANG deviation 'deviate' statement. It defines how the
+ * device's implementation of the target node deviates from its original
+ * definition.
+ */
+public enum DeviateKind {
+
+ NOT_SUPPORTED("not-supported"), ADD("add"), REPLACE("replace"), DELETE("delete");
+
+ private final String keyword;
+
+ DeviateKind(final String keyword) {
+ this.keyword = Preconditions.checkNotNull(keyword);
+ }
+
+ /**
+ * @return String that corresponds to the yang keyword.
+ */
+ public String getKeyword() {
+ return keyword;
+ }
+}
*/
package org.opendaylight.yangtools.yang.model.api;
-import com.google.common.base.Preconditions;
import java.util.List;
/**
*/
public interface Deviation {
- /**
- * Enum describing YANG deviation 'deviate' statement. It defines how the
- * device's implementation of the target node deviates from its original
- * definition.
- */
- enum Deviate {
- NOT_SUPPORTED("not-supported"), ADD("add"), REPLACE("replace"), DELETE("delete");
-
- private final String keyword;
-
- Deviate(final String keyword) {
- this.keyword = Preconditions.checkNotNull(keyword);
- }
-
- /**
- * @return String that corresponds to the yang keyword.
- */
- public String getKeyword() {
- return keyword;
- }
- }
-
/**
* @return SchemaPath that identifies the node in the schema tree where a
* deviation from the module occurs.
SchemaPath getTargetPath();
/**
- * @return deviate statement of this deviation
+ *
+ * @return List of all deviate statements defined in this deviation
+ */
+ List<DeviateDefinition> getDeviates();
+
+ /**
+ *
+ * @return textual description of this deviation
*/
- Deviate getDeviate();
+ String getDescription();
/**
* @return textual cross-reference to an external document that provides
import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.model.api.Deviation;
+import org.opendaylight.yangtools.yang.model.api.DeviateKind;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-public interface DeviateStatement extends DeclaredStatement<Deviation.Deviate> {
+public interface DeviateStatement extends DeclaredStatement<DeviateKind> {
@Nonnull
- Deviation.Deviate getValue();
+ DeviateKind getValue();
}
import static org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator.MAX;
import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.model.api.Deviation;
+import org.opendaylight.yangtools.yang.model.api.DeviateKind;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DeviateStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeviateEffectiveStatementImpl;
-public class DeviateStatementImpl extends AbstractDeclaredStatement<Deviation.Deviate> implements DeviateStatement {
+public class DeviateStatementImpl extends AbstractDeclaredStatement<DeviateKind> implements DeviateStatement {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
.DEVIATE)
.add(Rfc6020Mapping.CONFIG, 0, 1)
.add(Rfc6020Mapping.UNITS, 0, 1)
.build();
- protected DeviateStatementImpl(
- StmtContext<Deviation.Deviate, DeviateStatement, ?> context) {
+ protected DeviateStatementImpl(StmtContext<DeviateKind, DeviateStatement, ?> context) {
super(context);
}
- public static class Definition extends AbstractStatementSupport<Deviation.Deviate, DeviateStatement,
- EffectiveStatement<Deviation.Deviate, DeviateStatement>> {
+ public static class Definition extends AbstractStatementSupport<DeviateKind, DeviateStatement,
+ EffectiveStatement<DeviateKind, DeviateStatement>> {
public Definition() {
super(Rfc6020Mapping.DEVIATE);
}
- @Override public Deviation.Deviate parseArgumentValue(
- StmtContext<?, ?, ?> ctx, String value) {
+ @Override public DeviateKind parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
return Utils.parseDeviateFromString(ctx, value);
}
- @Override public DeviateStatement createDeclared(
- StmtContext<Deviation.Deviate, DeviateStatement, ?> ctx) {
+ @Override public DeviateStatement createDeclared(StmtContext<DeviateKind, DeviateStatement, ?> ctx) {
return new DeviateStatementImpl(ctx);
}
- @Override public EffectiveStatement<Deviation.Deviate, DeviateStatement> createEffective(
- StmtContext<Deviation.Deviate, DeviateStatement, EffectiveStatement<Deviation.Deviate,
+ @Override public EffectiveStatement<DeviateKind, DeviateStatement> createEffective(
+ StmtContext<DeviateKind, DeviateStatement, EffectiveStatement<DeviateKind,
DeviateStatement>> ctx) {
return new DeviateEffectiveStatementImpl(ctx);
}
@Override
- public void onFullDefinitionDeclared(StmtContext.Mutable<Deviation.Deviate, DeviateStatement,
- EffectiveStatement<Deviation.Deviate, DeviateStatement>> stmt) {
+ public void onFullDefinitionDeclared(StmtContext.Mutable<DeviateKind, DeviateStatement,
+ EffectiveStatement<DeviateKind, DeviateStatement>> stmt) {
super.onFullDefinitionDeclared(stmt);
SUBSTATEMENT_VALIDATOR.validate(stmt);
}
}
@Nonnull @Override
- public Deviation.Deviate getValue() {
+ public DeviateKind getValue() {
return argument();
}
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
-import org.opendaylight.yangtools.yang.model.api.Deviation;
-import org.opendaylight.yangtools.yang.model.api.Deviation.Deviate;
+import org.opendaylight.yangtools.yang.model.api.DeviateKind;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
.add("YiSyllables")
.add("YijingHexagramSymbols").build();
- private static final Map<String, Deviate> KEYWORD_TO_DEVIATE_MAP;
+ private static final Map<String, DeviateKind> KEYWORD_TO_DEVIATE_MAP;
static {
- Builder<String, Deviate> keywordToDeviateMapBuilder = ImmutableMap.builder();
- for (Deviate deviate : Deviation.Deviate.values()) {
+ Builder<String, DeviateKind> keywordToDeviateMapBuilder = ImmutableMap.builder();
+ for (DeviateKind deviate : DeviateKind.values()) {
keywordToDeviateMapBuilder.put(deviate.getKeyword(), deviate);
}
KEYWORD_TO_DEVIATE_MAP = keywordToDeviateMapBuilder.build();
.isAssignableFrom(UnknownStatementImpl.class);
}
- public static Deviation.Deviate parseDeviateFromString(final StmtContext<?, ?, ?> ctx, final String deviateKeyword) {
+ public static DeviateKind parseDeviateFromString(final StmtContext<?, ?, ?> ctx, final String deviateKeyword) {
return Preconditions.checkNotNull(KEYWORD_TO_DEVIATE_MAP.get(deviateKeyword),
"String '%s' is not valid deviate argument. Statement source at %s", deviateKeyword,
ctx.getStatementSourceReference());
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
-import org.opendaylight.yangtools.yang.model.api.Deviation;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
+import org.opendaylight.yangtools.yang.model.api.DeviateKind;
+import org.opendaylight.yangtools.yang.model.api.MustDefinition;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UniqueConstraint;
import org.opendaylight.yangtools.yang.model.api.stmt.DeviateStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-public final class DeviateEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Deviation.Deviate, DeviateStatement> {
- public DeviateEffectiveStatementImpl(final StmtContext<Deviation.Deviate, DeviateStatement, ?> ctx) {
+public final class DeviateEffectiveStatementImpl
+ extends DeclaredEffectiveStatementBase<DeviateKind, DeviateStatement> implements DeviateDefinition {
+
+ private final DeviateKind deviateType;
+ private final Boolean deviatedConfig;
+ private final String deviatedDefault;
+ private final Boolean deviatedMandatory;
+ private final Integer deviatedMaxElements;
+ private final Integer deviatedMinElements;
+ private final Set<MustDefinition> deviatedMustDefinitions;
+ private final TypeDefinition<?> deviatedType;
+ private final Collection<UniqueConstraint> deviatedUniqueConstraints;
+ private final String deviatedUnits;
+
+
+ public DeviateEffectiveStatementImpl(final StmtContext<DeviateKind, DeviateStatement, ?> ctx) {
super(ctx);
+
+ this.deviateType = argument();
+
+ final ConfigEffectiveStatementImpl configStmt = firstEffective(ConfigEffectiveStatementImpl.class);
+ this.deviatedConfig = configStmt == null ? null : configStmt.argument();
+ final DefaultEffectiveStatementImpl defaultStmt = firstEffective(DefaultEffectiveStatementImpl.class);
+ this.deviatedDefault = defaultStmt == null ? null : defaultStmt.argument();
+ final MandatoryEffectiveStatement mandatoryStmt = firstEffective(MandatoryEffectiveStatement.class);
+ this.deviatedMandatory = mandatoryStmt == null ? null : mandatoryStmt.argument();
+ final MaxElementsEffectiveStatementImpl maxElementsStmt = firstEffective(MaxElementsEffectiveStatementImpl.class);
+ this.deviatedMaxElements = maxElementsStmt == null ? null : Integer.valueOf(maxElementsStmt.argument());
+ final MinElementsEffectiveStatementImpl minElementsStmt = firstEffective(MinElementsEffectiveStatementImpl.class);
+ this.deviatedMinElements = minElementsStmt == null ? null : minElementsStmt.argument();
+ final TypeEffectiveStatement<TypeStatement> typeStmt = firstEffective(TypeEffectiveStatement.class);
+ this.deviatedType = typeStmt == null ? null : typeStmt.getTypeDefinition();
+ final UnitsEffectiveStatementImpl unitsStmt = firstEffective(UnitsEffectiveStatementImpl.class);
+ this.deviatedUnits = unitsStmt == null ? null : unitsStmt.argument();
+
+ this.deviatedMustDefinitions = ImmutableSet.copyOf(allSubstatementsOfType(MustDefinition.class));
+ this.deviatedUniqueConstraints = ImmutableList.copyOf(allSubstatementsOfType(UniqueConstraint.class));
+ }
+
+ @Override
+ public DeviateKind getDeviateType() {
+ return deviateType;
+ }
+
+ @Override
+ public Boolean getDeviatedConfig() {
+ return deviatedConfig;
+ }
+
+ @Override
+ public String getDeviatedDefault() {
+ return deviatedDefault;
+ }
+
+ @Override
+ public Boolean getDeviatedMandatory() {
+ return deviatedMandatory;
+ }
+
+ @Override
+ public Integer getDeviatedMaxElements() {
+ return deviatedMaxElements;
+ }
+
+ @Override
+ public Integer getDeviatedMinElements() {
+ return deviatedMinElements;
+ }
+
+ @Override
+ public Set<MustDefinition> getDeviatedMusts() {
+ return deviatedMustDefinitions;
+ }
+
+ @Override
+ public TypeDefinition<?> getDeviatedType() {
+ return deviatedType;
+ }
+
+ @Override
+ public Collection<UniqueConstraint> getDeviatedUniques() {
+ return deviatedUniqueConstraints;
+ }
+
+ @Override
+ public String getDeviatedUnits() {
+ return deviatedUnits;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ DeviateEffectiveStatementImpl other = (DeviateEffectiveStatementImpl) obj;
+ return Objects.equals(deviateType, other.deviateType) &&
+ Objects.equals(deviatedConfig, other.deviatedConfig) &&
+ Objects.equals(deviatedDefault, other.deviatedDefault) &&
+ Objects.equals(deviatedMandatory, other.deviatedMandatory) &&
+ Objects.equals(deviatedMaxElements, other.deviatedMaxElements) &&
+ Objects.equals(deviatedMinElements, other.deviatedMinElements) &&
+ Objects.equals(deviatedMustDefinitions, other.deviatedMustDefinitions) &&
+ Objects.equals(deviatedType, other.deviatedType) &&
+ Objects.equals(deviatedUniqueConstraints, other.deviatedUniqueConstraints) &&
+ Objects.equals(deviatedUnits, other.deviatedUnits);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(deviateType, deviatedConfig, deviatedDefault, deviatedMandatory, deviatedMaxElements,
+ deviatedMinElements, deviatedMustDefinitions, deviatedType, deviatedUniqueConstraints, deviatedUnits);
}
}
\ No newline at end of file
import java.util.List;
import java.util.Objects;
import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
import org.opendaylight.yangtools.yang.model.api.Deviation;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
public class DeviationEffectiveStatementImpl extends DeclaredEffectiveStatementBase<SchemaNodeIdentifier, DeviationStatement>
implements Deviation, Immutable {
private final SchemaPath targetPath;
- private final Deviate deviate;
+ private final String description;
private final String reference;
private final List<UnknownSchemaNode> unknownSchemaNodes;
+ private final List<DeviateDefinition> deviateDefinitions;
public DeviationEffectiveStatementImpl(final StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> ctx) {
super(ctx);
this.targetPath = ctx.getStatementArgument().asSchemaPath();
- DeviateEffectiveStatementImpl deviateStmt = firstEffective(DeviateEffectiveStatementImpl.class);
- this.deviate = (deviateStmt == null) ? null : deviateStmt.argument();
+ this.deviateDefinitions = ImmutableList.copyOf(allSubstatementsOfType(DeviateDefinition.class));
+
+ DescriptionEffectiveStatementImpl descriptionStmt = firstEffective(DescriptionEffectiveStatementImpl.class);
+ this.description = (descriptionStmt == null) ? null : descriptionStmt.argument();
ReferenceEffectiveStatementImpl referenceStmt = firstEffective(ReferenceEffectiveStatementImpl.class);
this.reference = (referenceStmt == null) ? null : referenceStmt.argument();
}
@Override
- public Deviate getDeviate() {
- return deviate;
+ public List<DeviateDefinition> getDeviates() {
+ return deviateDefinitions;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
}
@Override
final int prime = 31;
int result = 1;
result = prime * result + Objects.hashCode(targetPath);
- result = prime * result + Objects.hashCode(deviate);
+ result = prime * result + Objects.hashCode(deviateDefinitions);
+ result = prime * result + Objects.hashCode(description);
result = prime * result + Objects.hashCode(reference);
return result;
}
if (!Objects.equals(targetPath, other.targetPath)) {
return false;
}
- if (!Objects.equals(deviate, other.deviate)) {
+ if (!Objects.equals(deviateDefinitions, other.deviateDefinitions)) {
+ return false;
+ }
+ if (!Objects.equals(description, other.description)) {
return false;
}
if (!Objects.equals(reference, other.reference)) {
public String toString() {
return DeviationEffectiveStatementImpl.class.getSimpleName() + "[" +
"targetPath=" + targetPath +
- ", deviate=" + deviate +
+ ", deviates=" + deviateDefinitions +
+ ", description=" + description +
", reference=" + reference +
"]";
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.stmt;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
+import org.opendaylight.yangtools.yang.model.api.DeviateKind;
+import org.opendaylight.yangtools.yang.model.api.Deviation;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+
+public class DeviationStmtTest {
+
+ private static final StatementStreamSource FOO_MODULE =
+ new YangStatementSourceImpl("/deviation-stmt-test/foo.yang", false);
+
+ @Test
+ public void testDeviationAndDeviate() throws ReactorException, ParseException {
+ final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+ reactor.addSources(FOO_MODULE);
+
+ final SchemaContext schemaContext = reactor.buildEffective();
+ assertNotNull(schemaContext);
+
+ final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2016-06-23");
+
+ final Module testModule = schemaContext.findModuleByName("foo", revision);
+ assertNotNull(testModule);
+
+ final Set<Deviation> deviations = testModule.getDeviations();
+ assertEquals(4, deviations.size());
+
+ for (Deviation deviation : deviations) {
+ final List<DeviateDefinition> deviates = deviation.getDeviates();
+ final String targetLocalName = deviation.getTargetPath().getLastComponent().getLocalName();
+ if ("test-leaf".equals(targetLocalName)) {
+ assertEquals("test-leaf is not supported", deviation.getDescription());
+ assertEquals(1, deviates.size());
+ assertEquals(DeviateKind.NOT_SUPPORTED, deviates.iterator().next().getDeviateType());
+ } else if ("test-leaf-2".equals(targetLocalName)) {
+ assertEquals(1, deviates.size());
+ assertEquals(DeviateKind.ADD, deviates.iterator().next().getDeviateType());
+ assertEquals("added-def-val", deviates.iterator().next().getDeviatedDefault());
+ assertFalse(deviates.iterator().next().getDeviatedConfig());
+ } else if ("test-leaf-list".equals(targetLocalName)) {
+ assertEquals(3, deviates.size());
+ for (DeviateDefinition deviate : deviates) {
+ if (DeviateKind.ADD.equals(deviate.getDeviateType())) {
+ assertEquals(12, deviate.getDeviatedMaxElements().intValue());
+ assertTrue(deviate.getDeviatedMandatory());
+ } else if (DeviateKind.REPLACE.equals(deviate.getDeviateType())) {
+ assertEquals(5, deviate.getDeviatedMinElements().intValue());
+ assertTrue(deviate.getDeviatedType() instanceof UnsignedIntegerTypeDefinition);
+ } else {
+ assertEquals(2, deviate.getDeviatedMusts().size());
+ assertEquals("minutes", deviate.getDeviatedUnits());
+ }
+ }
+ } else {
+ assertEquals(1, deviation.getDeviates().size());
+ assertEquals(DeviateKind.DELETE, deviates.iterator().next().getDeviateType());
+ assertEquals(2, deviates.iterator().next().getDeviatedUniques().size());
+ }
+ }
+ }
+}
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DeviateKind;
import org.opendaylight.yangtools.yang.model.api.Deviation;
import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
final Deviation deviationStmt = deviations.iterator().next();
assertNotNull(deviationStmt);
assertEquals(contSchemaPath, deviationStmt.getTargetPath());
- assertEquals(Deviation.Deviate.ADD, deviationStmt.getDeviate());
+ assertEquals(DeviateKind.ADD, deviationStmt.getDeviates().iterator().next().getDeviateType());
assertEquals("deviate reference", deviationStmt.getReference());
final Set<IdentitySchemaNode> identities = rootModule.getIdentities();
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import java.io.File;
import java.io.IOException;
import java.net.URI;
import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DeviateKind;
import org.opendaylight.yangtools.yang.model.api.Deviation;
-import org.opendaylight.yangtools.yang.model.api.Deviation.Deviate;
import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
SchemaPath expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, dev.getTargetPath());
- assertEquals(Deviate.ADD, dev.getDeviate());
+ assertEquals(DeviateKind.ADD, dev.getDeviates().iterator().next().getDeviateType());
}
@Test
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+
import java.net.URI;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DeviateKind;
import org.opendaylight.yangtools.yang.model.api.Deviation;
-import org.opendaylight.yangtools.yang.model.api.Deviation.Deviate;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
SchemaPath expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, dev.getTargetPath());
- assertEquals(Deviate.ADD, dev.getDeviate());
+ assertEquals(DeviateKind.ADD, dev.getDeviates().iterator().next().getDeviateType());
}
}
--- /dev/null
+module foo {
+ namespace "foo-namespace";
+ prefix "foo-prefix";
+
+ revision "2016-06-23" {
+ description "Initial revision";
+ }
+
+ deviation "/test-container/test-leaf" {
+ description "test-leaf is not supported";
+ deviate not-supported;
+ }
+
+ deviation "/test-container/test-leaf-2" {
+ deviate add {
+ default "added-def-val";
+ config false;
+ }
+ }
+
+ deviation "/test-container/test-leaf-list" {
+ deviate add {
+ max-elements 12;
+ mandatory true;
+ }
+
+ deviate replace {
+ min-elements 5;
+ type uint32;
+ }
+
+ deviate delete {
+ must "daytime or time";
+ must "time or daytime";
+ units minutes;
+ }
+ }
+
+ deviation "/test-container/test-list" {
+ deviate delete {
+ unique "list-leaf-1 list-leaf-2";
+ unique "list-leaf-3 list-leaf-4";
+ }
+ }
+
+ container test-container {
+ leaf test-leaf {
+ type string;
+ }
+
+ leaf test-leaf-2 {
+ type string;
+ }
+
+ leaf-list test-leaf-list {
+ type int32;
+ min-elements 3;
+ must "daytime or time";
+ units minutes;
+ }
+
+ list test-list {
+ key key-leaf;
+ unique "list-leaf-1 list-leaf-2";
+ unique "list-leaf-3 list-leaf-4";
+
+ leaf key-leaf {
+ type string;
+ }
+
+ leaf list-leaf-1 {
+ type string;
+ }
+
+ leaf list-leaf-2 {
+ type string;
+ }
+
+ leaf list-leaf-3 {
+ type string;
+ }
+
+ leaf list-leaf-4 {
+ type string;
+ }
+ }
+ }
+}
\ No newline at end of file