@Test public void testGetRpcQNameFromXML_norevision() { Optional<QName> rpcQName = ConverterUtils.getRpcQName(loadResourceAsString("make-toast-input_norev.xml")); Assert.assertTrue(rpcQName.isPresent()); Assert.assertTrue(MAKE_TOAST_RPC_QNAME.getLocalName().equals(rpcQName.get().getLocalName())); Assert.assertTrue(MAKE_TOAST_RPC_QNAME.getNamespace().equals(rpcQName.get().getNamespace())); Assert.assertFalse(MAKE_TOAST_RPC_QNAME.getRevision().equals(rpcQName.get().getRevision())); }
public static Optional<QName> getRpcQName(final XmlElement xmlElement) { Optional<String> optionalNamespace = xmlElement.getNamespaceOptionally().toJavaUtil(); String name = xmlElement.getName(); if (Strings.isNullOrEmpty(name)) { return Optional.empty(); } String revision = null; String namespace; if (optionalNamespace.isPresent() && !Strings.isNullOrEmpty(optionalNamespace.get())) { String[] split = optionalNamespace.get().split("\\?"); if (split.length > 1 && split[1].contains("revision=")) { revision = split[1].replace("revision=", ""); } namespace = split[0]; } else { return Optional.of(QName.create(name)); } if (Strings.isNullOrEmpty(revision)) { return Optional.of(QName.create(namespace, name)); } else { return Optional.of(QName.create(namespace, revision, name)); } }
ConverterUtils { public static Optional<QName> getRpcQName(final XmlElement xmlElement) { Optional<String> optionalNamespace = xmlElement.getNamespaceOptionally().toJavaUtil(); String name = xmlElement.getName(); if (Strings.isNullOrEmpty(name)) { return Optional.empty(); } String revision = null; String namespace; if (optionalNamespace.isPresent() && !Strings.isNullOrEmpty(optionalNamespace.get())) { String[] split = optionalNamespace.get().split("\\?"); if (split.length > 1 && split[1].contains("revision=")) { revision = split[1].replace("revision=", ""); } namespace = split[0]; } else { return Optional.of(QName.create(name)); } if (Strings.isNullOrEmpty(revision)) { return Optional.of(QName.create(namespace, name)); } else { return Optional.of(QName.create(namespace, revision, name)); } } }
ConverterUtils { public static Optional<QName> getRpcQName(final XmlElement xmlElement) { Optional<String> optionalNamespace = xmlElement.getNamespaceOptionally().toJavaUtil(); String name = xmlElement.getName(); if (Strings.isNullOrEmpty(name)) { return Optional.empty(); } String revision = null; String namespace; if (optionalNamespace.isPresent() && !Strings.isNullOrEmpty(optionalNamespace.get())) { String[] split = optionalNamespace.get().split("\\?"); if (split.length > 1 && split[1].contains("revision=")) { revision = split[1].replace("revision=", ""); } namespace = split[0]; } else { return Optional.of(QName.create(name)); } if (Strings.isNullOrEmpty(revision)) { return Optional.of(QName.create(namespace, name)); } else { return Optional.of(QName.create(namespace, revision, name)); } } private  ConverterUtils(); }
ConverterUtils { public static Optional<QName> getRpcQName(final XmlElement xmlElement) { Optional<String> optionalNamespace = xmlElement.getNamespaceOptionally().toJavaUtil(); String name = xmlElement.getName(); if (Strings.isNullOrEmpty(name)) { return Optional.empty(); } String revision = null; String namespace; if (optionalNamespace.isPresent() && !Strings.isNullOrEmpty(optionalNamespace.get())) { String[] split = optionalNamespace.get().split("\\?"); if (split.length > 1 && split[1].contains("revision=")) { revision = split[1].replace("revision=", ""); } namespace = split[0]; } else { return Optional.of(QName.create(name)); } if (Strings.isNullOrEmpty(revision)) { return Optional.of(QName.create(namespace, name)); } else { return Optional.of(QName.create(namespace, revision, name)); } } private  ConverterUtils(); static Optional<RpcDefinition> loadRpc(final SchemaContext schemaContext, final QName rpcQName); static Optional<NotificationDefinition> loadNotification(final SchemaContext schemaContext,
            final QName notificationQname); static Optional<QName> getRpcQName(final XmlElement xmlElement); static Optional<QName> getRpcQName(final String inputString); static XmlElement rpcAsInput(final XmlElement inputXmlElement); static XmlElement rpcAsInput(final XmlElement inputXmlElement, final String namespace); static XmlElement rpcAsOutput(final XmlElement inputXmlElement); static XmlElement rpcAsOutput(final XmlElement inputXmlElement, final String namespace); static SchemaNode getSchemaNode(final SchemaContext schemaContext, final QName qname); static SchemaNode getSchemaNode(final SchemaContext schemaContext,
            final YangInstanceIdentifier yangInstanceIdentifier); static SchemaNode getSchemaNode(final SchemaContext schemaContext, final String namespace,
            final String revision, final String localName); }
ConverterUtils { public static Optional<QName> getRpcQName(final XmlElement xmlElement) { Optional<String> optionalNamespace = xmlElement.getNamespaceOptionally().toJavaUtil(); String name = xmlElement.getName(); if (Strings.isNullOrEmpty(name)) { return Optional.empty(); } String revision = null; String namespace; if (optionalNamespace.isPresent() && !Strings.isNullOrEmpty(optionalNamespace.get())) { String[] split = optionalNamespace.get().split("\\?"); if (split.length > 1 && split[1].contains("revision=")) { revision = split[1].replace("revision=", ""); } namespace = split[0]; } else { return Optional.of(QName.create(name)); } if (Strings.isNullOrEmpty(revision)) { return Optional.of(QName.create(namespace, name)); } else { return Optional.of(QName.create(namespace, revision, name)); } } private  ConverterUtils(); static Optional<RpcDefinition> loadRpc(final SchemaContext schemaContext, final QName rpcQName); static Optional<NotificationDefinition> loadNotification(final SchemaContext schemaContext,
            final QName notificationQname); static Optional<QName> getRpcQName(final XmlElement xmlElement); static Optional<QName> getRpcQName(final String inputString); static XmlElement rpcAsInput(final XmlElement inputXmlElement); static XmlElement rpcAsInput(final XmlElement inputXmlElement, final String namespace); static XmlElement rpcAsOutput(final XmlElement inputXmlElement); static XmlElement rpcAsOutput(final XmlElement inputXmlElement, final String namespace); static SchemaNode getSchemaNode(final SchemaContext schemaContext, final QName qname); static SchemaNode getSchemaNode(final SchemaContext schemaContext,
            final YangInstanceIdentifier yangInstanceIdentifier); static SchemaNode getSchemaNode(final SchemaContext schemaContext, final String namespace,
            final String revision, final String localName);  }