We are going through SchemaNode.getPath() only to acquire the last
component -- this is equivalent to SchemaNode.getQName(), so use
that.
Change-Id: I206d9cbdf9932f8ef4eb102eb2fa88660460aca3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
* @throws NullPointerException if any of the arguments is null
*/
public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
- final QName qname = schemaNode.getPath().getLastComponent();
- checkState(qname != null, "Schema Path contains invalid state of path parts. "
- + "The Schema Path MUST contain at least ONE QName which defines namespace and Local name of path.");
- return context.findModule(qname.getModule()).orElse(null);
+ return context.findModule(schemaNode.getQName().getModule()).orElse(null);
}
public static SchemaNode findNodeInSchemaContext(final SchemaContext context, final Iterable<QName> path) {
@Test
public void findParentModuleIllegalArgumentTest2() {
- doReturn(SchemaPath.create(true, QName.create("foo", "bar"))).when(schemaNode).getPath();
+ doReturn(QName.create("foo", "bar")).when(schemaNode).getQName();
assertThrows(NullPointerException.class, () -> SchemaContextUtil.findParentModule(null, schemaNode));
}