2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.util;
10 import com.google.common.base.Optional;
11 import org.junit.Test;
12 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
13 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
15 import static org.junit.Assert.assertEquals;
17 public class BaseConstraintsTest {
20 public void canCreateConstraints() {
23 String description = "Any description";
24 String reference = "any_ref";
25 String reg_exp = "x|z";
26 Optional<String> desc = Optional.of(description);
27 Optional<String> ref = Optional.of(reference);
29 LengthConstraint lengthCons = BaseConstraints.newLengthConstraint(min, max, desc, ref);
31 assertEquals("LengthConstraints Get min", min, lengthCons.getMin());
32 assertEquals("LengthConstraints Get max", max, lengthCons.getMax());
33 assertEquals("LengthConstraints Get description", description, lengthCons.getDescription());
34 assertEquals("LengthConstraints Get reference", reference, lengthCons.getReference());
36 PatternConstraint patternCons = BaseConstraints.newPatternConstraint(reg_exp, desc, ref);
38 assertEquals("PatternConstraints Get regex", reg_exp, patternCons.getRegularExpression());
39 assertEquals("PatternConstraints Get description", description, patternCons.getDescription());
40 assertEquals("PatternConstraints Get reference", reference, patternCons.getReference());