import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
-import java.util.Date;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
"/deviation-resolution-test/deviation-not-supported");
assertNotNull(schemaContext);
- final Date revision = QName.parseRevision("2017-01-20");
-
- final Module importedModule = schemaContext.findModuleByName("imported", revision);
- assertNotNull(importedModule);
-
+ final Module importedModule = schemaContext.findModule("imported", Revision.valueOf("2017-01-20")).get();
final ContainerSchemaNode myContA = (ContainerSchemaNode) importedModule.getDataChildByName(
QName.create(importedModule.getQNameModule(), "my-cont-a"));
assertNotNull(myContA);
sourceForResource("/deviation-resolution-test/deviation-add/bar.yang"));
assertNotNull(schemaContext);
- final Module barModule = schemaContext.findModuleByName("bar", QName.parseRevision("2017-01-20"));
- assertNotNull(barModule);
-
+ final Module barModule = schemaContext.findModule("bar", Revision.valueOf("2017-01-20")).get();
final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-leaf-list"));
assertNotNull(myLeafList);
sourceForResource("/deviation-resolution-test/deviation-replace/bar.yang"));
assertNotNull(schemaContext);
- final Date revision = QName.parseRevision("2017-01-20");
-
- final Module barModule = schemaContext.findModuleByName("bar", revision);
+ final Module barModule = schemaContext.findModule("bar", Revision.valueOf("2017-01-20")).get();
assertNotNull(barModule);
final LeafSchemaNode myLeaf = (LeafSchemaNode) barModule.getDataChildByName(
sourceForResource("/deviation-resolution-test/deviation-delete/bar.yang"));
assertNotNull(schemaContext);
- final Date revision = QName.parseRevision("2017-01-20");
-
- final Module barModule = schemaContext.findModuleByName("bar", revision);
- assertNotNull(barModule);
-
+ final Module barModule = schemaContext.findModule("bar", Revision.valueOf("2017-01-20")).get();
final LeafSchemaNode myLeaf = (LeafSchemaNode) barModule.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-leaf"));
assertNotNull(myLeaf);
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("(bar?revision=2017-01-20)my-cont is not a valid deviation " +
- "target for substatement (urn:ietf:params:xml:ns:yang:yin:1)max-elements."));
+ assertTrue(cause.getMessage().startsWith("(bar?revision=2017-01-20)my-cont is not a valid deviation "
+ + "target for substatement (urn:ietf:params:xml:ns:yang:yin:1)max-elements."));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause().getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation target 'Absolute{path=[(bar?revision=2017-01-20)" +
- "invalid, (bar?revision=2017-01-20)path]}' not found"));
+ assertTrue(cause.getMessage().startsWith("Deviation target 'Absolute{path=[(bar?revision=2017-01-20)"
+ + "invalid, (bar?revision=2017-01-20)path]}' not found"));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" +
- ":yin:1)config to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" +
- " target and can appear only once."));
+ assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang"
+ + ":yin:1)config to target node (bar?revision=2017-01-20)my-leaf because it is already defined in"
+ + " target and can appear only once."));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" +
- ":yin:1)default to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" +
- " target and can appear only once."));
+ assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang"
+ + ":yin:1)default to target node (bar?revision=2017-01-20)my-leaf because it is already defined in"
+ + " target and can appear only once."));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" +
- ":yin:1)default to target node (bar?revision=2017-02-01)my-used-leaf because it is already " +
- "defined in target and can appear only once."));
+ assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang"
+ + ":yin:1)default to target node (bar?revision=2017-02-01)my-used-leaf because it is already "
+ + "defined in target and can appear only once."));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation cannot replace substatement " +
- "(urn:ietf:params:xml:ns:yang:yin:1)units in target node (bar?revision=2017-01-20)my-leaf " +
- "because it does not exist in target node."));
+ assertTrue(cause.getMessage().startsWith("Deviation cannot replace substatement "
+ + "(urn:ietf:params:xml:ns:yang:yin:1)units in target node (bar?revision=2017-01-20)my-leaf "
+ + "because it does not exist in target node."));
}
}
@Test
+ @SuppressWarnings("checkstyle:regexpSinglelineJava")
public void shouldLogInvalidDeviateReplaceAttempt() throws Exception {
final PrintStream stdout = System.out;
final ByteArrayOutputStream output = new ByteArrayOutputStream();
sourceForResource("/deviation-resolution-test/deviation-replace/bar-invalid-2.yang"));
testLog = output.toString();
- assertTrue(testLog.contains("Deviation cannot replace substatement (urn:ietf:params:xml:ns:yang:yin:1)default" +
- " in target leaf-list (bar?revision=2017-01-20)my-leaf-list because a leaf-list can have multiple " +
- "default statements."));
System.setOut(stdout);
+ assertTrue(testLog.contains("Deviation cannot replace substatement (urn:ietf:params:xml:ns:yang:yin:1)default"
+ + " in target leaf-list (bar?revision=2017-01-20)my-leaf-list because a leaf-list can have multiple "
+ + "default statements."));
}
@Test
+ @SuppressWarnings("checkstyle:regexpSinglelineJava")
public void shouldLogInvalidDeviateDeleteAttempt() throws Exception {
final PrintStream stdout = System.out;
final ByteArrayOutputStream output = new ByteArrayOutputStream();
sourceForResource("/deviation-resolution-test/deviation-delete/bar-invalid.yang"));
testLog = output.toString();
- assertTrue(testLog.contains("Deviation cannot delete substatement (urn:ietf:params:xml:ns:yang:yin:1)units " +
- "with argument 'seconds' in target node (bar?revision=2017-01-20)my-leaf because it does not exist " +
- "in the target node."));
System.setOut(stdout);
+ assertTrue(testLog.contains("Deviation cannot delete substatement (urn:ietf:params:xml:ns:yang:yin:1)units "
+ + "with argument 'seconds' in target node (bar?revision=2017-01-20)my-leaf because it does not exist "
+ + "in the target node."));
}
@Test