Unneeded imports, static methods, missing generics.
Change-Id: Ib3fd8282d69067c11fefbc557b4c72c3700f4e63
Signed-off-by: Robert Varga <rovarga@cisco.com>
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.net.URI;
import java.util.Date;
import org.junit.Test;
assertNotNull(qNameModule.getRevisionNamespace());
}
- private void assertLocalNameFails(final String localName) {
+ private static void assertLocalNameFails(final String localName) {
try {
new QName((URI)null, localName);
fail("Local name should fail:" + localName);
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-
-import com.google.common.util.concurrent.ListenableFuture;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
assertEquals(rpcErrorShort.getErrorType(), rpcErrorShortWarn.getErrorType());
assertEquals(rpcErrorLong.getErrorType(), rpcErrorLongWarn.getErrorType());
assertEquals(rpcResultRpcResultBuilder1, rpcResultRpcResultBuilder2);
- assertTrue(rpcResultBuilder.buildFuture() instanceof ListenableFuture);
+ assertNotNull(rpcResultBuilder.buildFuture());
assertEquals("RpcResult [successful=true, result=null, errors=[RpcError [message=msg, severity=ERROR, " +
"errorType=RPC, tag=tag, applicationTag=null, info=null, cause=null]]]", rpcResult.toString());
}
"error message", "my-app-tag", "my-info", cause );
}
- void verifyRpcError( RpcResult<?> result, int errorIndex, ErrorSeverity expSeverity,
- ErrorType expErrorType, String expTag, String expMessage, String expAppTag,
- String expInfo, Throwable expCause ) {
+ void verifyRpcError( final RpcResult<?> result, final int errorIndex, final ErrorSeverity expSeverity,
+ final ErrorType expErrorType, final String expTag, final String expMessage, final String expAppTag,
+ final String expInfo, final Throwable expCause ) {
List<RpcError> errors = new ArrayList<>( result.getErrors() );
assertTrue( "Expected error at index " + errorIndex + " not found",
assertEquals( "getCause", expCause, error.getCause() );
}
- void verifyRpcResult( RpcResult<?> result, boolean expSuccess, Object expValue ) {
+ void verifyRpcResult( final RpcResult<?> result, final boolean expSuccess, final Object expValue ) {
assertEquals( "isSuccessful", expSuccess, result.isSuccessful() );
assertEquals( "getResult", expValue, result.getResult() );
}
return this;
}
- private String readAnyXmlValue(final XMLStreamReader in) throws XMLStreamException {
+ private static String readAnyXmlValue(final XMLStreamReader in) throws XMLStreamException {
String result = "";
String anyXmlElementName = in.getLocalName();
return codecs.codecFor(node).deserialize(value);
}
- private AbstractNodeDataWithSchema newEntryNode(final AbstractNodeDataWithSchema parent) {
+ private static AbstractNodeDataWithSchema newEntryNode(final AbstractNodeDataWithSchema parent) {
AbstractNodeDataWithSchema newChild;
if (parent instanceof ListNodeDataWithSchema) {
newChild = new ListEntryNodeDataWithSchema(parent.getSchema());
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import org.opendaylight.yangtools.util.UnmodifiableCollection;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
private static final MapEntryNode LIST_MAIN_CHILD_2 = ImmutableNodes.mapEntry(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 2);
private static final MapEntryNode LIST_MAIN_CHILD_3 = ImmutableNodes.mapEntry(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 3);
private static final Integer SIZE = 3;
- private static final YangInstanceIdentifier.NodeWithValue BAR_PATH = new YangInstanceIdentifier
- .NodeWithValue(LEAF_LIST_MAIN, "bar");
+ private static final NodeWithValue BAR_PATH = new NodeWithValue<>(LEAF_LIST_MAIN, "bar");
private static final LeafSetEntryNode LEAF_SET_ENTRY_NODE = ImmutableLeafSetEntryNodeBuilder.create()
.withNodeIdentifier(BAR_PATH)
.withValue("bar")
@Test
public void immutableOrderedMapBuilderTest() {
- final LinkedList<MapEntryNode> mapEntryNodeColl = new LinkedList();
+ final LinkedList<MapEntryNode> mapEntryNodeColl = new LinkedList<>();
mapEntryNodeColl.add(LIST_MAIN_CHILD_3);
final Map<QName, Object> keys = new HashMap<>();
keys.put(LIST_MAIN_CHILD_QNAME_1, 1);
@Test
public void immutableOrderedLeafSetNodeBuilderTest() {
- final NormalizedNode orderedLeafSet = ImmutableOrderedLeafSetNodeBuilder.create()
+ final NormalizedNode<?, ?> orderedLeafSet = ImmutableOrderedLeafSetNodeBuilder.create()
.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
.withChild(LEAF_SET_ENTRY_NODE)
.withChildValue("baz")
.removeChild(BAR_PATH)
.build();
- final LinkedList<LeafSetNode> mapEntryNodeColl = new LinkedList();
- mapEntryNodeColl.add((LeafSetNode)orderedLeafSet);
- final UnmodifiableCollection leafSetCollection = (UnmodifiableCollection)orderedLeafSet.getValue();
- final NormalizedNode orderedMapNodeSchemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList)
+ final LinkedList<LeafSetNode<?>> mapEntryNodeColl = new LinkedList<>();
+ mapEntryNodeColl.add((LeafSetNode<?>)orderedLeafSet);
+ final UnmodifiableCollection<?> leafSetCollection = (UnmodifiableCollection<?>)orderedLeafSet.getValue();
+ final NormalizedNode<?, ?> orderedMapNodeSchemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList)
.withChildValue("baz")
.build();
- final UnmodifiableCollection SchemaAwareleafSetCollection = (UnmodifiableCollection)orderedMapNodeSchemaAware
+ final UnmodifiableCollection<?> SchemaAwareleafSetCollection = (UnmodifiableCollection<?>)orderedMapNodeSchemaAware
.getValue();
- final NormalizedNode orderedLeafSetShemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList,
- (LeafSetNode)orderedLeafSet)
+ final NormalizedNode<?, ?> orderedLeafSetShemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList,
+ (LeafSetNode<?>)orderedLeafSet)
.build();
assertNotNull(Builders.orderedLeafSetBuilder(leafList));
assertNotNull(Builders.anyXmlBuilder());
assertNotNull(orderedLeafSetShemaAware.hashCode());
assertNotNull(orderedLeafSetShemaAware);
- assertEquals(1, ((OrderedLeafSetNode)orderedLeafSet).getSize());
- assertEquals("baz", ((OrderedLeafSetNode)orderedLeafSet).getChild(0).getValue());
- assertNotNull(((OrderedLeafSetNode)orderedLeafSet).getChild(BAR_PATH));
+ assertEquals(1, ((OrderedLeafSetNode<?>)orderedLeafSet).getSize());
+ assertEquals("baz", ((OrderedLeafSetNode<?>)orderedLeafSet).getChild(0).getValue());
+ assertNotNull(((OrderedLeafSetNode<?>)orderedLeafSet).getChild(BAR_PATH));
assertEquals(1, leafSetCollection.size());
assertEquals(1, SchemaAwareleafSetCollection.size());
}
@Test
public void immutableMapNodeBuilderTest() {
- final LinkedList<MapEntryNode> mapEntryNodeColl = new LinkedList();
+ final LinkedList<MapEntryNode> mapEntryNodeColl = new LinkedList<>();
mapEntryNodeColl.add(LIST_MAIN_CHILD_3);
final CollectionNodeBuilder<MapEntryNode, MapNode> collectionNodeBuilder = ImmutableMapNodeBuilder.create(1);
assertNotNull(collectionNodeBuilder);
@Test(expected=NullPointerException.class)
public void immutableLeafSetNodeBuilderExceptionTest() {
- final LeafSetNode leafSetNode = ImmutableLeafSetNodeBuilder.create(1).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
+ final LeafSetNode<?> leafSetNode = ImmutableLeafSetNodeBuilder.create(1).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
.build();
assertNotNull(leafSetNode);
ImmutableLeafSetNodeSchemaAwareBuilder.create(mock(LeafListSchemaNode.class), leafSetNode).build();
ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST).build();
}
- private static LeafSetNode getImmutableLeafSetNode() {
+ private static LeafSetNode<?> getImmutableLeafSetNode() {
final ListNodeBuilder<Object, LeafSetEntryNode<Object>> leafSetBuilder = Builders.leafSetBuilder();
leafSetBuilder.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST);
leafSetBuilder.addChild(LEAF_SET_ENTRY_NODE);
import java.io.IOException;
import java.text.ParseException;
import org.junit.Test;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
public class LeafSetDomSerializerTest {
private LeafSetEntryNodeDomSerializer temp;
private LeafListSchemaNode currentLeafList;
- private LeafSetEntryNode tempLeafList;
+ private LeafSetEntryNode<?> tempLeafList;
@Test
public void leafSetDomSerializerTest() throws IOException, YangSyntaxErrorException, ParseException, ReactorException {
currentLeafList = (LeafListSchemaNode) currentContainer.getDataChildByName(DomSerializerTestUtils
.generateQname("first-leaf-list"));
- final YangInstanceIdentifier.NodeWithValue barPath = new YangInstanceIdentifier.NodeWithValue
- (DomSerializerTestUtils.generateQname("first-leaf-list"), "bar");
+ final NodeWithValue<?> barPath = new NodeWithValue<>(DomSerializerTestUtils.generateQname("first-leaf-list"), "bar");
tempLeafList = ImmutableLeafSetEntryNodeBuilder.create()
.withNodeIdentifier(barPath)
.withValue("bar")
}
} else if (arg instanceof NodeWithValue) {
sb.append("[.='");
- sb.append(((NodeWithValue) arg).getValue());
+ sb.append(((NodeWithValue<?>) arg).getValue());
sb.append("']");
}
}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-final class LeafListEntryContextNode extends AbstractLeafNodeContext<NodeWithValue> {
+final class LeafListEntryContextNode extends AbstractLeafNodeContext<NodeWithValue<?>> {
public LeafListEntryContextNode(final LeafListSchemaNode potential) {
- super(new NodeWithValue(potential.getQName(), null), potential);
+ super(new NodeWithValue<>(potential.getQName(), null), potential);
}
@Override
private DataSchemaContextNode<?> current;
private int offset;
- XpathStringParsingPathArgumentBuilder(AbstractStringInstanceIdentifierCodec codec, String data) {
+ XpathStringParsingPathArgumentBuilder(final AbstractStringInstanceIdentifierCodec codec, final String data) {
this.codec = Preconditions.checkNotNull(codec);
this.data = Preconditions.checkNotNull(data);
this.current = codec.getDataContextTree().getRoot();
}
- private DataSchemaContextNode<?> nextContextNode(QName name) {
+ private DataSchemaContextNode<?> nextContextNode(final QName name) {
current = current.getChild(name);
checkValid(current != null, "%s is not correct schema node identifier.",name);
while (current.isMixin()) {
* @param name QName of node, for which predicates are computed.
* @return PathArgument representing node selection with predictes
*/
- private PathArgument computeIdentifierWithPredicate(QName name) {
+ private PathArgument computeIdentifierWithPredicate(final QName name) {
DataSchemaContextNode<?> currentNode = nextContextNode(name);
checkValid(currentNode.isKeyedEntry(), "Entry %s does not allow specifying predicates.", name);
// Break-out from method for leaf-list case
if (key == null && currentNode.isLeaf()) {
checkValid(offset == data.length(), "Leaf argument must be last argument of instance identifier.");
- return new YangInstanceIdentifier.NodeWithValue(name, keyValue);
+ return new YangInstanceIdentifier.NodeWithValue<>(name, keyValue);
}
final DataSchemaContextNode<?> keyNode = currentNode.getChild(key);
checkValid(keyNode != null, "%s is not correct schema node identifier.", key);
}
- private PathArgument computeIdentifier(QName name) {
+ private PathArgument computeIdentifier(final QName name) {
DataSchemaContextNode<?> currentNode = nextContextNode(name);
checkValid(!currentNode.isKeyedEntry(), "Entry %s requires key or value predicate to be present", name);
return currentNode.getIdentifier();
}
- private QName createQName(String prefix, String localName) {
+ private QName createQName(final String prefix, final String localName) {
return codec.createQName(prefix, localName);
}
* @param expected Expected character
* @param errorMsg Error message if {@link #currentChar()} does not match expected.
*/
- private void checkCurrentAndSkip(char expected, String errorMsg) {
+ private void checkCurrentAndSkip(final char expected, final String errorMsg) {
checkValid(expected == currentChar(), errorMsg);
offset++;
}
* @param value Value to be checked and deserialized
* @return Object representing value in yang-data-api format.
*/
- private Object deserializeValue(@Nullable QName key, String value) {
+ private Object deserializeValue(@Nullable final QName key, final String value) {
// FIXME: Use codec to deserialize value to correct Java type
return value;
}
* @param errorMsg Error message which will be provided to user.
* @param attributes
*/
- private void checkValid(boolean condition, String errorMsg, Object... attributes) {
+ private void checkValid(final boolean condition, final String errorMsg, final Object... attributes) {
Preconditions.checkArgument(condition, "Could not parse Instance Identifier '%s'. Offset: %s : Reason: %s",
data,
offset,
return data.substring(start, offset);
}
- private void nextSequenceEnd(CharMatcher matcher) {
+ private void nextSequenceEnd(final CharMatcher matcher) {
while (!allCharactersConsumed() && matcher.matches(data.charAt(offset))) {
offset++;
}
}
- private void checkValidQuotation(char quoteChar) {
+ private void checkValidQuotation(final char quoteChar) {
checkValid(
SQUOTE.matches(quoteChar) || DQUOTE.matches(quoteChar),
"Value must be qoute escaped with ''' or '\"'.");
package org.opendaylight.yangtools.yang.model.export.test;
import static org.junit.Assert.assertNotNull;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
}
}
- private File exportModule(final SchemaContext schemaContext, final Module module, final File outDir)
+ private static File exportModule(final SchemaContext schemaContext, final Module module, final File outDir)
throws Exception {
final File outFile = new File(outDir, YinExportUtils.wellFormedYinName(module.getName(), module.getRevision()));
try (OutputStream output = new FileOutputStream(outFile)) {
}
}
- private File exportModule(final SchemaContext schemaContext, final Module module, final File outDir)
+ private static File exportModule(final SchemaContext schemaContext, final Module module, final File outDir)
throws Exception {
final File outFile = new File(outDir, YinExportUtils.wellFormedYinName(module.getName(), module.getRevision()));
try (OutputStream output = new FileOutputStream(outFile)) {
final TypeDefinition<?> typeDefinition = concreteTypeBuilder.buildType();
assertEquals(typeDefinition.getBaseType(), derivedTypeDef.getBaseType());
}
-}
\ No newline at end of file
+}
private final String errorMessage;
private final A constraints;
- public AbstractConstraintEffectiveStatement(final StmtContext<A, D, ?> ctx, ConstraintFactory<A> constraintFactory) {
+ public AbstractConstraintEffectiveStatement(final StmtContext<A, D, ?> ctx, final ConstraintFactory<A> constraintFactory) {
super(ctx);
String descriptionInit = null;
String referenceInit = null;
abstract class ListConstraintFactory<A> extends ConstraintFactory<List<A>> {
@Override
- protected List<A> createConstraints(AbstractConstraintEffectiveStatement<List<A>, ?> stmt, List<A> argument) {
+ protected List<A> createConstraints(final AbstractConstraintEffectiveStatement<List<A>, ?> stmt, final List<A> argument) {
if (!stmt.isCustomizedStatement()) {
return ImmutableList.copyOf(argument);
}
final class LengthConstraintFactory extends ListConstraintFactory<LengthConstraint> {
@Override
- protected LengthConstraint createCustomizedConstraint(LengthConstraint lengthConstraint,
- AbstractConstraintEffectiveStatement<List<LengthConstraint>, ?> stmt) {
+ protected LengthConstraint createCustomizedConstraint(final LengthConstraint lengthConstraint,
+ final AbstractConstraintEffectiveStatement<List<LengthConstraint>, ?> stmt) {
return new LengthConstraintEffectiveImpl(lengthConstraint.getMin(), lengthConstraint.getMax(),
stmt.getDescription(), stmt.getReference(), stmt.getErrorAppTag(), stmt.getErrorMessage());
}
final class RangeConstraintFactory extends ListConstraintFactory<RangeConstraint> {
@Override
- protected RangeConstraint createCustomizedConstraint(RangeConstraint rangeConstraint,
- AbstractConstraintEffectiveStatement<List<RangeConstraint>, ?> stmt) {
+ protected RangeConstraint createCustomizedConstraint(final RangeConstraint rangeConstraint,
+ final AbstractConstraintEffectiveStatement<List<RangeConstraint>, ?> stmt) {
return new RangeConstraintEffectiveImpl(rangeConstraint.getMin(), rangeConstraint.getMax(),
stmt.getDescription(), stmt.getReference(), stmt.getErrorAppTag(), stmt.getErrorMessage());
}
final class PatternConstraintFactory extends ConstraintFactory<PatternConstraint> {
@Override
- protected PatternConstraint createConstraints(AbstractConstraintEffectiveStatement<PatternConstraint, ?> stmt, PatternConstraint argument) {
+ protected PatternConstraint createConstraints(final AbstractConstraintEffectiveStatement<PatternConstraint, ?> stmt, final PatternConstraint argument) {
if (!stmt.isCustomizedStatement()) {
return argument;
} else {
}
}
- private PatternConstraint createCustomizedConstraint(PatternConstraint patternConstraint,
- AbstractConstraintEffectiveStatement<?, ?> stmt) {
+ private static PatternConstraint createCustomizedConstraint(final PatternConstraint patternConstraint,
+ final AbstractConstraintEffectiveStatement<?, ?> stmt) {
return new PatternConstraintEffectiveImpl(patternConstraint.getRegularExpression(), stmt.getDescription(),
stmt.getReference(), stmt.getErrorAppTag(), stmt.getErrorMessage());
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.CheckedFuture;
import java.util.HashSet;
assertNotNull(testLeafC);
}
- private SettableSchemaProvider<ASTSchemaSource> getImmediateYangSourceProviderFromResource(
+ private static SettableSchemaProvider<ASTSchemaSource> getImmediateYangSourceProviderFromResource(
final String resourceName) throws Exception {
final ResourceYangSource yangSource = new ResourceYangSource(resourceName);
final CheckedFuture<ASTSchemaSource, SchemaSourceException> aSTSchemaSource = TextToASTTransformer.TRANSFORMATION.apply(yangSource);
return SettableSchemaProvider.createImmediate(aSTSchemaSource.get(), ASTSchemaSource.class);
}
- private void assertSchemaContext(final SchemaContext schemaContext, final int moduleSize) {
+ private static void assertSchemaContext(final SchemaContext schemaContext, final int moduleSize) {
assertNotNull(schemaContext);
assertEquals(moduleSize, schemaContext.getModules().size());
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
assertEquals(1, unknownSchemaNodes.size());
UnknownSchemaNode next = unknownSchemaNodes.iterator().next();
- assertTrue(next instanceof UnknownSchemaNode);
assertTrue(next instanceof AnyxmlSchemaLocationEffectiveStatementImpl);
AnyxmlSchemaLocationEffectiveStatementImpl anyxmlSchemaLocationUnknownNode= (AnyxmlSchemaLocationEffectiveStatementImpl) next;
assertEquals(SupportedExtensionsMapping.ANYXML_SCHEMA_LOCATION.getStatementName(), anyxmlSchemaLocationUnknownNode.getNodeType());
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
import java.net.URI;
import java.util.Date;
import org.junit.Test;
}
- private ContainerEffectiveStatementImpl findContainer(SchemaContext context, QName... path) {
+ private static ContainerEffectiveStatementImpl findContainer(final SchemaContext context, final QName... path) {
SchemaNode node = SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, path));
assertTrue(node instanceof ContainerEffectiveStatementImpl);
ContainerEffectiveStatementImpl container = (ContainerEffectiveStatementImpl) node;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import org.junit.Test;
verifyExtendedLeaf(topContainer);
}
- private ContainerSchemaNode verifyTopContainer(SchemaContext context) {
+ private static ContainerSchemaNode verifyTopContainer(final SchemaContext context) {
QName top = QName.create("http://example.com/module1", "2016-03-09", "top");
DataSchemaNode dataChildByName = context.getDataChildByName(top);
assertTrue(dataChildByName instanceof ContainerSchemaNode);
return topContainer;
}
- private void verifyExtendedLeaf(ContainerSchemaNode topContainer) {
+ private static void verifyExtendedLeaf(final ContainerSchemaNode topContainer) {
DataSchemaNode dataChildByName2 = topContainer.getDataChildByName(QName.create("http://example.com/module2",
"2016-03-09", "extended-leaf"));
assertTrue(dataChildByName2 instanceof LeafSchemaNode);
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import org.junit.Test;
checkThing2TypeDef(badModule);
}
- private void checkThing2TypeDef(Module badModule) {
+ private static void checkThing2TypeDef(final Module badModule) {
TypeDefinition<?> thing2 = null;
for (TypeDefinition<?> typeDef : badModule.getTypeDefinitions()) {
if (typeDef.getQName().getLocalName().equals("thing2")) {
List<TypeDefinition<?>> unionTypes = baseType.getTypes();
StringTypeDefinition ipv4 = (StringTypeDefinition) unionTypes.get(0);
- assertTrue(ipv4.getBaseType() instanceof StringTypeDefinition);
+ assertNotNull(ipv4.getBaseType());
String expectedPattern = "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}"
+ "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])" + "(%[\\p{N}\\p{L}]+)?$";
assertEquals(expectedPattern, ipv4.getPatternConstraints().get(0).getRegularExpression());
StringTypeDefinition ipv6 = (StringTypeDefinition) unionTypes.get(1);
- assertTrue(ipv6.getBaseType() instanceof StringTypeDefinition);
+ assertNotNull(ipv6.getBaseType());
List<PatternConstraint> ipv6Patterns = ipv6.getPatternConstraints();
expectedPattern = "^((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}"
+ "((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|" + "(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}"
Module tested = TestUtils.findModule(testedModules, "ietf-inet-types");
Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
StringTypeDefinition type = (StringTypeDefinition) TestUtils.findTypedef(typedefs, "domain-name");
- assertTrue(type.getBaseType() instanceof StringTypeDefinition);
+ assertNotNull(type.getBaseType());
List<PatternConstraint> patterns = type.getPatternConstraints();
assertEquals(1, patterns.size());
String expectedPattern = "^((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*"