### Question:
Delta { @Nonnull public static Version inferNextVersion(@Nonnull final Version version, @Nonnull final CompatibilityType compatibilityType) { if (version == null) { throw new IllegalArgumentException("null version"); } if (compatibilityType == null) { throw new IllegalArgumentException("null compatibilityType"); } switch (compatibilityType) { case BACKWARD_COMPATIBLE_IMPLEMENTER: return version.next(Version.Element.PATCH); case BACKWARD_COMPATIBLE_USER: return version.next(Version.Element.MINOR); case NON_BACKWARD_COMPATIBLE: return version.next(Version.Element.MAJOR); default: throw new IllegalArgumentException("Unknown type <"+compatibilityType+">"); } } Delta(@Nonnull final Set<? extends Difference> differences); @Nonnull final Set<Difference> getDifferences(); @Nonnull final CompatibilityType computeCompatibilityType(); @Nonnull static Version inferNextVersion(@Nonnull final Version version, @Nonnull final CompatibilityType compatibilityType); @Nonnull final Version infer(@Nonnull final Version previous); final boolean validate(@Nonnull final Version previous, @Nonnull final Version current);  }### Answer:
@Test public void inferVersion() { final int major = 1; final int minor = 2; final int patch = 3; final Version version = new Version(major, minor, patch); assertEquals(version.next(MAJOR), inferNextVersion(version, NON_BACKWARD_COMPATIBLE)); assertEquals(version.next(MINOR), inferNextVersion(version, BACKWARD_COMPATIBLE_USER)); assertEquals(version.next(PATCH), inferNextVersion(version, BACKWARD_COMPATIBLE_IMPLEMENTER)); }
@Test(expected=IllegalArgumentException.class) public void shouldInferWithNullVersionFail() { inferNextVersion(null, BACKWARD_COMPATIBLE_IMPLEMENTER); }
@Test(expected=IllegalArgumentException.class) public void shouldInferWithNullCompatibilityTypeFail() { inferNextVersion(new Version(1, 0, 0), null); }