Ensure { public static <T> T notNull(T argument, String argumentName) { if (argument == null) { throw new IllegalArgumentException("Argument " + argumentName + " must not be null."); } return argument; } private  Ensure(); static T notNull(T argument, String argumentName); static String notNullOrEmpty(String argument, String argumentName);  }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenNullObjectGiven() { notNull(null, "testArgument"); }
@Test public void shouldReturnObjectWhenNotNullObjectGiven() { Object testObject = new Object(); assertThat(notNull(testObject, "testObject"), is(equalTo(testObject))); }