@Test void merge() throws IncompatibleVersionConstraintException { assertEquals("2.0", new DefaultVersionConstraint("1.0").merge(new DefaultVersionConstraint("2.0")).getValue()); assertEquals("[2.0]", new DefaultVersionConstraint("[1.0,2.0]").merge(new DefaultVersionConstraint("[2.0]")).getValue()); assertEquals("{[1.0,2.0]},{[2.0,]}", new DefaultVersionConstraint("[1.0,2.0]").merge(new DefaultVersionConstraint("2.0")).getValue()); assertEquals("[2.0]", new DefaultVersionConstraint("1.0").merge(new DefaultVersionConstraint("[2.0]")).getValue()); Throwable exception = assertThrows(IncompatibleVersionConstraintException.class, () -> { new DefaultVersionConstraint("[1.0]").merge(new DefaultVersionConstraint("[2.0]")).getValue(); }); assertEquals("Ranges [[1.0]] and [[2.0]] are incompatibles", exception.getMessage()); exception = assertThrows(IncompatibleVersionConstraintException.class, () -> { new DefaultVersionConstraint("[1.0]").merge(new DefaultVersionConstraint("2.0")).getValue(); }); assertEquals("Ranges [[1.0]] and [[2.0,]] are incompatibles", exception.getMessage()); }
@Override public VersionConstraint merge(VersionConstraint versionConstraint) throws IncompatibleVersionConstraintException { if (equals(versionConstraint)) { return this; } else { VersionConstraint mergedConstraint = mergeVersions(versionConstraint); return mergedConstraint == null ? mergeRanges(versionConstraint) : mergedConstraint; } }
DefaultVersionConstraint implements VersionConstraint { @Override public VersionConstraint merge(VersionConstraint versionConstraint) throws IncompatibleVersionConstraintException { if (equals(versionConstraint)) { return this; } else { VersionConstraint mergedConstraint = mergeVersions(versionConstraint); return mergedConstraint == null ? mergeRanges(versionConstraint) : mergedConstraint; } } }
DefaultVersionConstraint implements VersionConstraint { @Override public VersionConstraint merge(VersionConstraint versionConstraint) throws IncompatibleVersionConstraintException { if (equals(versionConstraint)) { return this; } else { VersionConstraint mergedConstraint = mergeVersions(versionConstraint); return mergedConstraint == null ? mergeRanges(versionConstraint) : mergedConstraint; } } DefaultVersionConstraint(String rawConstraint);  DefaultVersionConstraint(VersionConstraint versionConstraint);  DefaultVersionConstraint(Collection<? extends VersionRangeCollection> ranges, Version version);  DefaultVersionConstraint(Version version); }
DefaultVersionConstraint implements VersionConstraint { @Override public VersionConstraint merge(VersionConstraint versionConstraint) throws IncompatibleVersionConstraintException { if (equals(versionConstraint)) { return this; } else { VersionConstraint mergedConstraint = mergeVersions(versionConstraint); return mergedConstraint == null ? mergeRanges(versionConstraint) : mergedConstraint; } } DefaultVersionConstraint(String rawConstraint);  DefaultVersionConstraint(VersionConstraint versionConstraint);  DefaultVersionConstraint(Collection<? extends VersionRangeCollection> ranges, Version version);  DefaultVersionConstraint(Version version); @Override Collection<VersionRangeCollection> getRanges(); @Override Version getVersion(); @Override boolean containsVersion(Version version); @Override boolean isCompatible(Version version); @Override VersionConstraint merge(VersionConstraint versionConstraint); @Override String getValue(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); }
DefaultVersionConstraint implements VersionConstraint { @Override public VersionConstraint merge(VersionConstraint versionConstraint) throws IncompatibleVersionConstraintException { if (equals(versionConstraint)) { return this; } else { VersionConstraint mergedConstraint = mergeVersions(versionConstraint); return mergedConstraint == null ? mergeRanges(versionConstraint) : mergedConstraint; } } DefaultVersionConstraint(String rawConstraint);  DefaultVersionConstraint(VersionConstraint versionConstraint);  DefaultVersionConstraint(Collection<? extends VersionRangeCollection> ranges, Version version);  DefaultVersionConstraint(Version version); @Override Collection<VersionRangeCollection> getRanges(); @Override Version getVersion(); @Override boolean containsVersion(Version version); @Override boolean isCompatible(Version version); @Override VersionConstraint merge(VersionConstraint versionConstraint); @Override String getValue(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }