// assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1",
// mergedRange.getRecommendedVersion().toString() );
assertEquals(CHECK_VERSION_RECOMMENDATION, "1.0", mergedRange.getRecommendedVersion().toString());
List<Restriction> restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
Restriction restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
mergedRange = range2.restrict(range1);
assertEquals(CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
// TODO: test reversed restrictions on all below
range1 = VersionRange.createFromVersionSpec("[1.0,)");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertEquals(CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.1,)");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertEquals(CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.1]");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertEquals(CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(1.1,)");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.2,)");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.2]");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertEquals(CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.1]");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertEquals(CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.1)");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.0]");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.0], [1.1,)");
range2 = VersionRange.createFromVersionSpec("1.2");
mergedRange = range1.restrict(range2);
assertEquals(CHECK_VERSION_RECOMMENDATION, "1.2", mergedRange.getRecommendedVersion().toString());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 2, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.0], [1.1,)");
range2 = VersionRange.createFromVersionSpec("1.0.5");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 2, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.1), (1.1,)");
range2 = VersionRange.createFromVersionSpec("1.1");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 2, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertNull(CHECK_LOWER_BOUND, restriction.getLowerBound());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertNull(CHECK_UPPER_BOUND, restriction.getUpperBound());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.1,1.3]");
range2 = VersionRange.createFromVersionSpec("(1.1,)");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.3)");
range2 = VersionRange.createFromVersionSpec("[1.2,1.3]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.1,1.3]");
range2 = VersionRange.createFromVersionSpec("[1.2,)");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.3]");
range2 = VersionRange.createFromVersionSpec("[1.2,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(1.2,1.3]");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(1.2,1.3)");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.2,1.3)");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.1]");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.1)");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 0, restrictions.size());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2],[1.3,1.5]");
range2 = VersionRange.createFromVersionSpec("[1.1]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2],[1.3,1.5]");
range2 = VersionRange.createFromVersionSpec("[1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 1, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.4", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2],[1.3,1.5]");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 2, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2),(1.3,1.5]");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 2, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2],[1.3,1.5]");
range2 = VersionRange.createFromVersionSpec("(1.1,1.4)");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 2, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2),(1.3,1.5]");
range2 = VersionRange.createFromVersionSpec("(1.1,1.4)");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 2, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString());
assertFalse(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString());
assertFalse(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("(,1.1),(1.4,)");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 0, restrictions.size());
range1 = VersionRange.createFromVersionSpec("(,1.1],[1.4,)");
range2 = VersionRange.createFromVersionSpec("(1.1,1.4)");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 0, restrictions.size());
range1 = VersionRange.createFromVersionSpec("[,1.1],[1.4,]");
range2 = VersionRange.createFromVersionSpec("[1.2,1.3]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 0, restrictions.size());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2],[1.3,1.5]");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4],[1.6,]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 2, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2],[1.3,1.5]");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4],[1.5,]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 3, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(2);
assertEquals(CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.5", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
range1 = VersionRange.createFromVersionSpec("[1.0,1.2],[1.3,1.7]");
range2 = VersionRange.createFromVersionSpec("[1.1,1.4],[1.5,1.6]");
mergedRange = range1.restrict(range2);
assertNull(CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion());
restrictions = mergedRange.getRestrictions();
assertEquals(CHECK_NUM_RESTRICTIONS, 3, restrictions.size());
restriction = (Restriction) restrictions.get(0);
assertEquals(CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(1);
assertEquals(CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
restriction = (Restriction) restrictions.get(2);
assertEquals(CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString());
assertTrue(CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive());
assertEquals(CHECK_UPPER_BOUND, "1.6", restriction.getUpperBound().toString());
assertTrue(CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive());
// test restricting empty sets
range1 = VersionRange.createFromVersionSpec("[,1.1],[1.4,]");
range2 = VersionRange.createFromVersionSpec("[1.2,1.3]");
range1 = range1.restrict(range2);