Cleanup the code and enforce checkstyle.
Change-Id: Ieb6087afc1b98065bc2e0c941dd5ff0277c8244b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
</dependency>
</dependencies>
- <!--
- Maven Site Configuration
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
- The following configuration is necessary for maven-site-plugin to
- correctly identify the correct deployment path for OpenDaylight Maven
- sites.
- -->
- <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+ <!--
+ Maven Site Configuration
- <distributionManagement>
- <site>
- <id>opendaylight-site</id>
- <url>${nexus.site.url}/${project.artifactId}/</url>
- </site>
- </distributionManagement>
+ The following configuration is necessary for maven-site-plugin to
+ correctly identify the correct deployment path for OpenDaylight Maven
+ sites.
+ -->
+ <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+
+ <distributionManagement>
+ <site>
+ <id>opendaylight-site</id>
+ <url>${nexus.site.url}/${project.artifactId}/</url>
+ </site>
+ </distributionManagement>
</project>
}
@Override
+ @SuppressWarnings("checkstyle:parameterName")
protected QNameModule doForward(@Nonnull final String a) {
return delegate.convert(a);
}
@Override
+ @SuppressWarnings("checkstyle:parameterName")
protected String doBackward(@Nonnull final QNameModule b) {
return delegate.reverse().convert(b);
}
void enterBinaryExpr(final BinaryExpr expr) {
}
+
void exitBinaryExpr(final BinaryExpr expr) {
}
@Nonnull
@Override
public XPathExpression compileExpression(@Nonnull final SchemaPath schemaPath,
- final Converter<String, QNameModule> prefixes, @Nonnull final String xpath) throws XPathExpressionException {
+ final Converter<String, QNameModule> prefixes, @Nonnull final String xpath)
+ throws XPathExpressionException {
try {
return JaxenXPath.create(prefixes, schemaPath, xpath);
} catch (JaxenException e) {
}
@Override
- public Optional<? extends XPathResult<?>> evaluate(@Nonnull final XPathDocument document, @Nonnull final YangInstanceIdentifier path)
- throws XPathExpressionException {
+ public Optional<? extends XPathResult<?>> evaluate(@Nonnull final XPathDocument document,
+ @Nonnull final YangInstanceIdentifier path) throws XPathExpressionException {
Preconditions.checkArgument(document instanceof JaxenDocument);
final NormalizedNodeContextSupport contextSupport = NormalizedNodeContextSupport.create(
return Optional.of((XPathNumberResult) () -> (Number) result);
} else if (result instanceof Boolean) {
return Optional.of((XPathBooleanResult) () -> (Boolean) result);
- } else if (result != null){
+ } else if (result != null) {
return Optional.of((XPathNodesetResult) () -> {
// XXX: Will this really work, or do we need to perform deep transformation?
return Lists.transform((List<NormalizedNodeContext>) result, NormalizedNodeContext::getNode);
private static final String NODE_IDENTIFIER_STR = "([A-Za-z_][A-Za-z0-9_\\.-]*:)?([A-Za-z_][A-Za-z0-9_\\.-]*)";
/**
- * Pattern matching node-identifier YANG ABNF token
+ * Pattern matching node-identifier YANG ABNF token.
*/
private static final Pattern NODE_IDENTIFIER_PATTERN = Pattern.compile(NODE_IDENTIFIER_STR);
/**
- * Matcher matching WSP YANG ABNF token
- *
+ * Matcher matching WSP YANG ABNF token.
*/
private static final CharMatcher WSP = CharMatcher.anyOf(" \t");
/**
* Matcher matching IDENTIFIER first char token.
- *
*/
private static final CharMatcher IDENTIFIER_FIRST_CHAR = CharMatcher.inRange('a', 'z')
.or(CharMatcher.inRange('A', 'Z')).or(CharMatcher.is('_')).precomputed();
/**
- *
- * Matcher matching IDENTIFIER token
- *
+ * Matcher matching IDENTIFIER token.
*/
private static final CharMatcher IDENTIFIER = IDENTIFIER_FIRST_CHAR.or(CharMatcher.inRange('0', '9'))
.or(CharMatcher.anyOf(".-")).precomputed();
private static final char PRECONDITION_START = '[';
private static final char PRECONDITION_END = ']';
- private final String xPathString;
+ private final String xpathString;
private final SchemaContext schemaContext;
private final TypedSchemaNode schemaNode;
private final NormalizedNodeContext currentNodeCtx;
private int offset = 0;
- LeafrefXPathStringParsingPathArgumentBuilder(final String xPathString, final SchemaContext schemaContext,
+ LeafrefXPathStringParsingPathArgumentBuilder(final String xpathString, final SchemaContext schemaContext,
final TypedSchemaNode schemaNode, final NormalizedNodeContext currentNodeCtx) {
- this.xPathString = xPathString;
+ this.xpathString = xpathString;
this.schemaContext = schemaContext;
this.schemaNode = schemaNode;
this.currentNodeCtx = currentNodeCtx;
final QName name = nextQName();
if (allCharactersConsumed() || SLASH == currentChar()) {
return new NodeIdentifier(name);
- } else {
- checkValid(PRECONDITION_START == currentChar(), "Last element must be identifier, predicate or '/'");
- return computeIdentifierWithPredicate(name);
}
+
+ checkValid(PRECONDITION_START == currentChar(), "Last element must be identifier, predicate or '/'");
+ return computeIdentifierWithPredicate(name);
}
private PathArgument computeIdentifierWithPredicate(final QName name) {
}
private Object nextCurrentFunctionPathValue() {
- final String xPathSubStr = xPathString.substring(offset);
+ final String xPathSubStr = xpathString.substring(offset);
final String pathKeyExpression = xPathSubStr.substring(0, xPathSubStr.indexOf(PRECONDITION_END));
final String relPathKeyExpression = pathKeyExpression.substring(CURRENT_FUNCTION_INVOCATION_STR.length());
} else {
throw new IllegalArgumentException(String.format(
"Could not parse leafref path '%s'. Offset: %s : Reason: Malformed path component: '%s'.",
- xPathString, offset, pathComponent));
+ xpathString, offset, pathComponent));
}
}
}
/**
- *
* Returns following QName and sets offset to end of QName.
*
* @return following QName.
private QName nextQName() {
// Consume prefix or identifier
final String maybePrefix = nextIdentifier();
- final String prefix, localName;
+ final String prefix;
+ final String localName;
if (!allCharactersConsumed() && COLON == currentChar()) {
// previous token is prefix;
prefix = maybePrefix;
}
/**
- * Returns true if all characters from input string
- * were consumed.
+ * Returns true if all characters from input string were consumed.
*
- * @return true if all characters from input string
- * were consumed.
+ * @return true if all characters from input string were consumed.
*/
private boolean allCharactersConsumed() {
- return offset == xPathString.length();
+ return offset == xpathString.length();
}
private QName createQName(final String prefix, final String localName) {
}
/**
- *
* Skips current char if it equals expected otherwise fails parsing.
*
* @param expected Expected character
}
/**
- *
* Fails parsing if condition is not met.
*
- * In case of error provides pointer to failed leafref,
- * offset on which failure occured with explanation.
+ * <p>
+ * In case of error provides pointer to failed leafref, offset on which failure occured with explanation.
*
* @param condition Fails parsing if {@code condition} is false
* @param errorMsg Error message which will be provided to user.
- * @param attributes
+ * @param attributes Message attributes
*/
private void checkValid(final boolean condition, final String errorMsg, final Object... attributes) {
if (!condition) {
throw new IllegalArgumentException(String.format(
- "Could not parse leafref path '%s'. Offset: %s : Reason: %s", xPathString, offset,
+ "Could not parse leafref path '%s'. Offset: %s : Reason: %s", xpathString, offset,
String.format(errorMsg, attributes)));
}
}
* @return character at current offset.
*/
private char currentChar() {
- return xPathString.charAt(offset);
+ return xpathString.charAt(offset);
}
/**
- * Increases processing offset by 1
+ * Increments processing offset by 1.
*/
private void skipCurrentChar() {
offset++;
}
/**
- * Skip whitespace characters, sets offset to first following
- * non-whitespace character.
+ * Skip whitespace characters, sets offset to first following non-whitespace character.
*/
private void skipWhitespaces() {
nextSequenceEnd(WSP);
*/
private String nextIdentifier() {
int start = offset;
- checkValid(IDENTIFIER_FIRST_CHAR.matches(currentChar()), "Identifier must start with character from set 'a-zA-Z_'");
+ checkValid(IDENTIFIER_FIRST_CHAR.matches(currentChar()),
+ "Identifier must start with character from set 'a-zA-Z_'");
nextSequenceEnd(IDENTIFIER);
- return xPathString.substring(start, offset);
+ return xpathString.substring(start, offset);
}
private void nextSequenceEnd(final CharMatcher matcher) {
- while (!allCharactersConsumed() && matcher.matches(xPathString.charAt(offset))) {
+ while (!allCharactersConsumed() && matcher.matches(xpathString.charAt(offset))) {
offset++;
}
}
-}
\ No newline at end of file
+}
this.root = new NormalizedNodeContext(this, navigator.getRootNode(), null);
}
- static NormalizedNodeContextSupport create(final JaxenDocument document, final Converter<String, QNameModule> prefixes) {
+ static NormalizedNodeContextSupport create(final JaxenDocument document,
+ final Converter<String, QNameModule> prefixes) {
final ConverterNamespaceContext context = new ConverterNamespaceContext(prefixes);
final NormalizedNodeNavigator navigator = new NormalizedNodeNavigator(context, document);
throw new UnsupportedOperationException();
}
+ @Override
+ public Iterator<NormalizedNodeContext> getChildAxisIterator(final Object contextNode) {
+ final NormalizedNodeContext ctx = cast(contextNode);
+ final NormalizedNode<?, ?> node = ctx.getNode();
+ if (node instanceof DataContainerNode) {
+ return Iterators.transform(((DataContainerNode<?>) node).getValue().iterator(), ctx);
+ }
+
+ return null;
+ }
+
@Override
public Iterator<NormalizedNodeContext> getChildAxisIterator(final Object contextNode, final String localName,
final String namespacePrefix, final String namespaceURI) {
}
@Override
- public Iterator<? extends Entry<?, ?>> getAttributeAxisIterator(final Object contextNode, final String localName, final String namespacePrefix,
- final String namespaceURI) {
+ public Iterator<? extends Entry<?, ?>> getAttributeAxisIterator(final Object contextNode) {
final NormalizedNode<?, ?> node = contextNode(contextNode);
if (node instanceof AttributesContainer) {
final Map<QName, String> attributes = ((AttributesContainer) node).getAttributes();
return null;
}
- final QName qname = resolveQName(node, namespacePrefix, localName);
- final String value = attributes.get(qname);
- return value == null ? null : Iterators.singletonIterator(new SimpleImmutableEntry<>(qname, value));
+ return attributes.entrySet().iterator();
}
return null;
}
@Override
- public Iterator<NormalizedNodeContext> getChildAxisIterator(final Object contextNode) {
- final NormalizedNodeContext ctx = cast(contextNode);
- final NormalizedNode<?, ?> node = ctx.getNode();
- if (node instanceof DataContainerNode) {
- return Iterators.transform(((DataContainerNode<?>) node).getValue().iterator(), ctx);
+ public Iterator<? extends Entry<?, ?>> getAttributeAxisIterator(final Object contextNode, final String localName,
+ final String namespacePrefix, final String namespaceURI) {
+ final NormalizedNode<?, ?> node = contextNode(contextNode);
+ if (node instanceof AttributesContainer) {
+ final Map<QName, String> attributes = ((AttributesContainer) node).getAttributes();
+ if (attributes.isEmpty()) {
+ return null;
+ }
+
+ final QName qname = resolveQName(node, namespacePrefix, localName);
+ final String value = attributes.get(qname);
+ return value == null ? null : Iterators.singletonIterator(new SimpleImmutableEntry<>(qname, value));
}
return null;
}
@Override
- public Iterator<NormalizedNodeContext> getAncestorAxisIterator(final Object contextNode) throws UnsupportedAxisException {
+ public Iterator<NormalizedNodeContext> getAncestorAxisIterator(final Object contextNode)
+ throws UnsupportedAxisException {
final NormalizedNodeContext parent = cast(contextNode).getParent();
return parent == null ? null : new NormalizedNodeContextIterator(parent);
}
@Override
- public Iterator<? extends Entry<?, ?>> getAttributeAxisIterator(final Object contextNode) {
- final NormalizedNode<?, ?> node = contextNode(contextNode);
- if (node instanceof AttributesContainer) {
- final Map<QName, String> attributes = ((AttributesContainer) node).getAttributes();
- if (attributes.isEmpty()) {
- return null;
- }
-
- return attributes.entrySet().iterator();
- }
-
- return null;
- }
-
- @Override
- public Iterator<NormalizedNodeContext> getSelfAxisIterator(final Object contextNode) throws UnsupportedAxisException {
+ public Iterator<NormalizedNodeContext> getSelfAxisIterator(final Object contextNode)
+ throws UnsupportedAxisException {
return Iterators.singletonIterator(cast(contextNode));
}
@Override
- public Iterator<NormalizedNodeContext> getAncestorOrSelfAxisIterator(final Object contextNode) throws UnsupportedAxisException {
+ public Iterator<NormalizedNodeContext> getAncestorOrSelfAxisIterator(final Object contextNode)
+ throws UnsupportedAxisException {
return new NormalizedNodeContextIterator(cast(contextNode));
}
import org.jaxen.expr.TextNodeStep;
abstract class StepListener {
+
void onAll(final AllNodeStep step) {
}
+
void onComment(final CommentNodeStep step) {
}
+
void onName(final NameStep step) {
}
+
void onProcessingInstruction(final ProcessingInstructionNodeStep step) {
}
+
void onTest(final TextNodeStep step) {
}
}
Verify.verify(context instanceof NormalizedNodeContext, "Unhandled context %s", context.getClass());
- return ((NormalizedNodeContext) context);
+ return (NormalizedNodeContext) context;
};
// re-match(string subject, string pattern) function as per https://tools.ietf.org/html/rfc7950#section-10.2.1
final NormalizedNodeContext currentNodeContext = (NormalizedNodeContext) context;
final SchemaContext schemaContext = getSchemaContext(currentNodeContext);
- final TypedSchemaNode correspondingSchemaNode = getCorrespondingTypedSchemaNode(schemaContext, currentNodeContext);
+ final TypedSchemaNode correspondingSchemaNode = getCorrespondingTypedSchemaNode(schemaContext,
+ currentNodeContext);
final Object nodeValue = currentNodeContext.getNode().getValue();
if (correspondingSchemaNode.getType() instanceof LeafrefTypeDefinition) {
final LeafrefTypeDefinition leafrefType = (LeafrefTypeDefinition) correspondingSchemaNode.getType();
- final RevisionAwareXPath xPath = leafrefType.getPathStatement();
- return getNodeReferencedByLeafref(xPath, currentNodeContext, schemaContext, correspondingSchemaNode, nodeValue);
+ final RevisionAwareXPath xpath = leafrefType.getPathStatement();
+ return getNodeReferencedByLeafref(xpath, currentNodeContext, schemaContext, correspondingSchemaNode,
+ nodeValue);
}
return null;
return null;
}
- private static NormalizedNode<?, ?> getNodeReferencedByLeafref(final RevisionAwareXPath xPath,
+ private static NormalizedNode<?, ?> getNodeReferencedByLeafref(final RevisionAwareXPath xpath,
final NormalizedNodeContext currentNodeContext, final SchemaContext schemaContext,
final TypedSchemaNode correspondingSchemaNode, final Object nodeValue) {
- final NormalizedNode<?, ?> referencedNode = xPath.isAbsolute() ? getNodeReferencedByAbsoluteLeafref(xPath,
- currentNodeContext, schemaContext, correspondingSchemaNode) : getNodeReferencedByRelativeLeafref(xPath,
+ final NormalizedNode<?, ?> referencedNode = xpath.isAbsolute() ? getNodeReferencedByAbsoluteLeafref(xpath,
+ currentNodeContext, schemaContext, correspondingSchemaNode) : getNodeReferencedByRelativeLeafref(xpath,
currentNodeContext, schemaContext, correspondingSchemaNode);
if (referencedNode instanceof LeafSetNode) {
return null;
}
- private static NormalizedNode<?, ?> getNodeReferencedByAbsoluteLeafref(final RevisionAwareXPath xPath,
+ private static NormalizedNode<?, ?> getNodeReferencedByAbsoluteLeafref(final RevisionAwareXPath xpath,
final NormalizedNodeContext currentNodeContext, final SchemaContext schemaContext,
final TypedSchemaNode correspondingSchemaNode) {
final LeafrefXPathStringParsingPathArgumentBuilder builder = new LeafrefXPathStringParsingPathArgumentBuilder(
- xPath.toString(), schemaContext, correspondingSchemaNode, currentNodeContext);
+ xpath.toString(), schemaContext, correspondingSchemaNode, currentNodeContext);
final List<PathArgument> pathArguments = builder.build();
final NormalizedNodeNavigator navigator = (NormalizedNodeNavigator) currentNodeContext.getNavigator();
final NormalizedNode<?, ?> rootNode = navigator.getRootNode();
return null;
}
- private static NormalizedNode<?, ?> getNodeReferencedByRelativeLeafref(final RevisionAwareXPath xPath,
+ private static NormalizedNode<?, ?> getNodeReferencedByRelativeLeafref(final RevisionAwareXPath xpath,
final NormalizedNodeContext currentNodeContext, final SchemaContext schemaContext,
final TypedSchemaNode correspondingSchemaNode) {
NormalizedNodeContext relativeNodeContext = currentNodeContext;
- final StringBuilder xPathStringBuilder = new StringBuilder(xPath.toString());
+ final StringBuilder xPathStringBuilder = new StringBuilder(xpath.toString());
// strip the relative path of all ../ at the beginning
while (xPathStringBuilder.indexOf("../") == 0) {
xPathStringBuilder.delete(0, 3);
final NormalizedNodeContext currentNodeContext = (NormalizedNodeContext) context;
final SchemaContext schemaContext = getSchemaContext(currentNodeContext);
- final TypedSchemaNode correspondingSchemaNode = getCorrespondingTypedSchemaNode(schemaContext, currentNodeContext);
+ final TypedSchemaNode correspondingSchemaNode = getCorrespondingTypedSchemaNode(schemaContext,
+ currentNodeContext);
if (!(correspondingSchemaNode.getType() instanceof IdentityrefTypeDefinition)) {
return Boolean.FALSE;
return Boolean.valueOf(ancestorIdentities.contains(identityArgSchemaNode));
};
- // derived-from-or-self(node-set nodes, string identity) function as per https://tools.ietf.org/html/rfc7950#section-10.4.2
+ // derived-from-or-self(node-set nodes, string identity) function as per
+ // https://tools.ietf.org/html/rfc7950#section-10.4.2
private static final Function DERIVED_FROM_OR_SELF_FUNCTION = (context, args) -> {
if (args == null || args.size() != 1) {
- throw new FunctionCallException("derived-from-or-self() takes two arguments: node-set nodes, string identity");
+ throw new FunctionCallException(
+ "derived-from-or-self() takes two arguments: node-set nodes, string identity");
}
if (!(args.get(0) instanceof String)) {
- throw new FunctionCallException("Argument 'identity' of derived-from-or-self() function should be a String.");
+ throw new FunctionCallException(
+ "Argument 'identity' of derived-from-or-self() function should be a String.");
}
final String identityArg = (String) args.get(0);
final NormalizedNodeContext currentNodeContext = (NormalizedNodeContext) context;
final SchemaContext schemaContext = getSchemaContext(currentNodeContext);
- final TypedSchemaNode correspondingSchemaNode = getCorrespondingTypedSchemaNode(schemaContext, currentNodeContext);
+ final TypedSchemaNode correspondingSchemaNode = getCorrespondingTypedSchemaNode(schemaContext,
+ currentNodeContext);
if (!(correspondingSchemaNode.getType() instanceof IdentityrefTypeDefinition)) {
return Boolean.FALSE;
}
}
- throw new IllegalArgumentException(String.format("Identity %s does not have a corresponding" +
- " identity schema node in the module %s.", identityQName, module));
+ throw new IllegalArgumentException(String.format("Identity %s does not have a corresponding"
+ + " identity schema node in the module %s.", identityQName, module));
}
// enum-value(node-set nodes) function as per https://tools.ietf.org/html/rfc7950#section-10.5.1
enumName, enumerationType));
}
- // bit-is-set(node-set nodes, string bit-name) function as per https://tools.ietf.org/html/rfc7950#section-10.6.1
+ // bit-is-set(node-set nodes, string bit-name) function as per
+ // https://tools.ietf.org/html/rfc7950#section-10.6.1
private static final Function BIT_IS_SET_FUNCTION = (context, args) -> {
if (args == null || args.size() != 1) {
throw new FunctionCallException("bit-is-set() takes two arguments: node-set nodes, string bit-name");
final NormalizedNodeContext currentNodeContext = (NormalizedNodeContext) context;
final SchemaContext schemaContext = getSchemaContext(currentNodeContext);
- final TypedSchemaNode correspondingSchemaNode = getCorrespondingTypedSchemaNode(schemaContext, currentNodeContext);
+ final TypedSchemaNode correspondingSchemaNode = getCorrespondingTypedSchemaNode(schemaContext,
+ currentNodeContext);
final TypeDefinition<?> nodeType = correspondingSchemaNode.getType();
if (!(nodeType instanceof BitsTypeDefinition)) {
return ENUM_VALUE_FUNCTION;
case "re-match":
return REMATCH_FUNCTION;
+ default:
+ break;
}
}
private static JaxenSchemaContextFactory jaxenSchemaContextFactory;
private static QNameModule fooModule;
- private static QName myContainer;
+ private static QName myContainer;
private static QName myList;
private static QName flags;
private static QName ordinaryLeaf;
assertNotNull(schemaContext);
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
- final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(invalidNodeValueType));
+ final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(
+ invalidNodeValueType));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
converterBiMap.put("foo-prefix", fooModule);
.node(new NodeIdentifierWithPredicates(myList, keys)).node(flags);
return path;
}
-}
\ No newline at end of file
+}
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
- final LeafNode<?> referencedLeafNode = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(referencedLeaf))
- .withValue("referenced-leaf-node-value").build();
+ final LeafNode<?> referencedLeafNode = Builders.leafBuilder().withNodeIdentifier(
+ new NodeIdentifier(referencedLeaf)).withValue("referenced-leaf-node-value").build();
- final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNodeForIIdTest(referencedLeafNode));
+ final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNodeForIIdTest(
+ referencedLeafNode));
final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
converterBiMap.put("foo-prefix", fooModule);
private static JaxenSchemaContextFactory jaxenSchemaContextFactory;
private static QNameModule barModule;
- private static QName myContainer;
+ private static QName myContainer;
private static QName myList;
private static QName keyLeaf;
private static QName idrefLeaf;
getDerivedFromResult(derivedFromFunction, normalizedNodeContext, "unknown-prefix:id-a3");
fail("Function call should have failed on unresolved prefix of the identity argument.");
} catch (IllegalArgumentException ex) {
- assertEquals("Cannot resolve prefix 'unknown-prefix' from identity 'unknown-prefix:id-a3'.", ex.getMessage());
+ assertEquals("Cannot resolve prefix 'unknown-prefix' from identity 'unknown-prefix:id-a3'.",
+ ex.getMessage());
}
}
fail("Function call should have failed on unknown identity argument.");
} catch (IllegalArgumentException ex) {
assertTrue(ex.getMessage().startsWith(
- "Identity (foo-ns?revision=2017-04-03)id-a333 does not have a corresponding identity schema " +
- "node in the module"));
+ "Identity (foo-ns?revision=2017-04-03)id-a333 does not have a corresponding identity schema "
+ + "node in the module"));
}
}
.node(new NodeIdentifierWithPredicates(myList, keys)).node(idrefLeaf);
return path;
}
-}
\ No newline at end of file
+}
xpathSchemaContext = new JaxenSchemaContextFactory().createContext(schemaContext);
assertNotNull(xpathSchemaContext);
- xpathExpression = xpathSchemaContext.compileExpression(createSchemaPath(), createPrefixes(), createXPath
- (false));
+ xpathExpression = xpathSchemaContext.compileExpression(createSchemaPath(), createPrefixes(), createXPath(
+ false));
assertNotNull(xpathExpression);
xpathDocument = xpathSchemaContext.createDocument(createNormalizedNodes());
.evaluate(xpathDocument, createYangInstanceIdentifier(false));
assertNotNull(resultExpressionEvaluate);
assertTrue(resultExpressionEvaluate.isPresent());
- XPathResult<?> xPathResult = resultExpressionEvaluate.get();
- Object value = ((XPathNodesetResult) xPathResult).getValue().iterator().next().getValue();
+ XPathResult<?> xpathResult = resultExpressionEvaluate.get();
+ Object value = ((XPathNodesetResult) xpathResult).getValue().iterator().next().getValue();
assertNotNull(value);
assertEquals("three", value);
Optional<? extends XPathResult<?>> resultExpressionEvaluate = xpathExpressionWithPredicates
.evaluate(xpathDocument, createYangInstanceIdentifier(true));
assertTrue(resultExpressionEvaluate.isPresent());
- XPathResult<?> xPathResult = resultExpressionEvaluate.get();
- Object value = ((XPathNodesetResult) xPathResult).getValue().iterator().next().getValue();
+ XPathResult<?> xpathResult = resultExpressionEvaluate.get();
+ Object value = ((XPathNodesetResult) xpathResult).getValue().iterator().next().getValue();
assertEquals("two", value);
}
@Test(expected = VerifyException.class)
public void testIsMethodsInNodeNavigator() {
- assertNotNull(navigator.isDocument("test"));
+ assertTrue(navigator.isDocument("test"));
}
@Test(expected = XPathExpressionException.class)
function.call(context, list);
fail();
} catch (VerifyException e) {
+ // Expected
}
yangFun.getFunction("urn:opendaylight.test2", "test2", "root");
}
- /**
- * @return container-a -> container-b -> leaf-d
- * list-a -> list-b -> leaf-b
+ /*
+ * container-a -> container-b -> leaf-d
+ * list-a -> list-b -> leaf-b
*/
- private YangInstanceIdentifier createYangInstanceIdentifier(Boolean withPredicates) {
- YangInstanceIdentifier testYangInstanceIdentifier = YangInstanceIdentifier.of(containerAQName).node
- (containerBQName).node(leafDQName);
+ private YangInstanceIdentifier createYangInstanceIdentifier(final boolean withPredicates) {
+ YangInstanceIdentifier testYangInstanceIdentifier = YangInstanceIdentifier.of(containerAQName).node(
+ containerBQName).node(leafDQName);
if (withPredicates) {
final Map<QName, Object> keys1 = new HashMap<>();
keys1.put(leafAQName, "bar");
return testYangInstanceIdentifier;
}
- private static String createXPath(boolean withPredicates) {
- String xPath = "/container-a/container-b/leaf-d";
- if (withPredicates) {
- xPath = "/list-a[leaf-a='bar']/list-b[leaf-b='two']/leaf-b";
- }
- return xPath;
+ private static String createXPath(final boolean withPredicates) {
+ return withPredicates ? "/list-a[leaf-a='bar']/list-b[leaf-b='two']/leaf-b" : "/container-a/container-b/leaf-d";
}
private Converter<String, QNameModule> createPrefixes() {
return Maps.asConverter(currentConverter);
}
- /**
- * @return rootQName -> listAQName -> leafAQName
- */
+ // rootQName -> listAQName -> leafAQName
private SchemaPath createSchemaPath() {
return SchemaPath.create(true, rootQName, listAQName, leafAQName);
}
- private SchemaContext createSchemaContext() throws IOException, URISyntaxException, ReactorException {
+ private static SchemaContext createSchemaContext() throws IOException, URISyntaxException, ReactorException {
return YangParserTestUtils.parseYangSources("/test/documentTest");
}
}
/**
- * Returns a test document
+ * Returns a test document.
*
* <pre>
* root
* leaf-d "three"
* </pre>
*
- * @return
+ * @return A test document instance.
*/
public static NormalizedNode<?, ?> createNormalizedNodes() {
return ImmutableContainerNodeBuilder
.build())
.withChild(ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONTAINER_A_QNAME))
- .withChild(ImmutableContainerNodeBuilder.create().
- withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier
- (CONTAINER_B_QNAME))
+ .withChild(ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONTAINER_B_QNAME))
.withChild(ImmutableNodes.leafNode(LEAF_D_QNAME, THREE))
.build())
.build())
.build();
}
-}
\ No newline at end of file
+}