package semver4j;

import org.junit.Test;

import java.util.regex.Pattern;

import static org.junit.Assert.*;

@SuppressWarnings("InstanceMethodNamingConvention")
public final class UtilsTest {
  @Test(expected = IllegalArgumentException.class)
  public void requireNonNegative_throwsIAE_onNegative() {
    Utils.requireNonNegative(-1);
  }

  @Test
  public void requireNonNegative_returnsParameter_onNonNegative() {
    assertEquals(1, Utils.requireNonNegative(1));
  }

  @Test
  public void requireNonNegative_returnsParameter_onZero() {
    assertEquals(0, Utils.requireNonNegative(0));
  }

  @Test(expected = IllegalArgumentException.class)
  public void requireMatches_throwsIllegalArgumentException_onMismatch() {
    Utils.requireMatches("abc", Pattern.compile("def"));
  }

  @Test
  public void requireMatches_returnsParameter_onMatch() {
    assertEquals("abc", Utils.requireMatches("abc", Pattern.compile("[a-z]+")));
  }

  @Test(expected = IllegalArgumentException.class)
  public void require_throwsIAE_onFalse() {
    Utils.require(false);
  }

  @Test
  public void require_succeeds_onTrue() {
    Utils.require(true);
  }

  @Test
  public void nullToBlank_returnsBlank_onNull() {
    assertEquals("", Utils.nullToBlank(null));
  }

  @Test
  public void nullToBlank_returnsBlank_onBlank() {
    assertEquals("", Utils.nullToBlank(""));
  }

  @Test
  public void nullToBlank_returnsParameter_onNonBlank() {
    assertEquals("a", Utils.nullToBlank("a"));
  }
}

@@ -36,16 +36,89 @@
 .Test;%0A%0A
+import java.lang.reflect.Constructor;%0Aimport java.lang.reflect.Modifier;%0A
 import j
@@ -1544,11 +1544,445 @@
 %22));%0A  %7D
+%0A%0A  @Test%0A  public void hasOnly1PrivateConstructor_alsoForConverage() throws Exception %7B%0A    final Constructor%3C?%3E%5B%5D constructors = Utils.class.getDeclaredConstructors();%0A    assertEquals(1, constructors.length);%0A%0A    final Constructor%3C?%3E constructor = constructors%5B0%5D;%0A    assertTrue(Modifier.isPrivate(constructor.getModifiers()));%0A%0A    constructor.setAccessible(true);%0A    assertTrue(constructor.newInstance() instanceof Utils);%0A  %7D
 %0A%7D%0A

Test private contructor.