BUG-8043: correct RangeConstraint definition
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / TypedefConstraintsTest.java
index 1db40ee58ee293882ba18b4b74ec7f0c4b570933..3f0fee007e2f4f7f9c464df1d5c89d9e50aa6575 100644 (file)
@@ -13,8 +13,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import com.google.common.collect.Range;
 import java.math.BigDecimal;
-import java.util.List;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -23,7 +23,6 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
 
 public class TypedefConstraintsTest {
@@ -43,8 +42,8 @@ public class TypedefConstraintsTest {
         assertNotNull(myDecimal);
         assertTrue(myDecimal instanceof DecimalTypeDefinition);
 
-        final List<RangeConstraint> rangeConstraints = ((DecimalTypeDefinition) myDecimal)
-                .getRangeConstraints();
+        final Set<? extends Range<?>> rangeConstraints = ((DecimalTypeDefinition) myDecimal).getRangeConstraint()
+                .get().getAllowedRanges().asRanges();
 
         assertNotNull(rangeConstraints);
         assertEquals(1, rangeConstraints.size());
@@ -60,13 +59,14 @@ public class TypedefConstraintsTest {
         assertTrue(type instanceof DecimalTypeDefinition);
         final DecimalTypeDefinition decType = (DecimalTypeDefinition) type;
 
-        final List<RangeConstraint> decRangeConstraints = decType.getRangeConstraints();
+        final Set<? extends Range<?>> decRangeConstraints = decType.getRangeConstraint().get().getAllowedRanges()
+                .asRanges();
 
         assertEquals(1, decRangeConstraints.size());
 
-        final RangeConstraint range = decRangeConstraints.iterator().next();
-        assertEquals(new BigDecimal(1.5), range.getMin());
-        assertEquals(new BigDecimal(5.5), range.getMax());
+        final Range<?> range = decRangeConstraints.iterator().next();
+        assertEquals(new BigDecimal(1.5), range.lowerEndpoint());
+        assertEquals(new BigDecimal(5.5), range.upperEndpoint());
 
         assertTrue(decType.getQName().getModule().equals(leafDecimal.getQName().getModule()));
         assertTrue(decType.getQName().getLocalName().equals(TypeUtils.DECIMAL64));