Assert { public static <T> T assertNotNull(T value, String parameterName) { if (parameterName == null) { throw new IllegalArgumentException("You must provide a parameter name!"); } if (value == null) { throw new IllegalArgumentException("Parameter >" + parameterName + "< must not be null!"); } return value; } private  Assert(); static T assertNotNull(T value, String parameterName);  }
@Test public void parameterNotNullWithNullValue() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage("Parameter >parameterName< must not be null!"); Assert.assertNotNull(null, "parameterName"); }
@Test public void parameterNotNullWithNonNullValue() { Integer result = Assert.assertNotNull(123, "parameterName"); assertThat(result, is(123)); }
@Test public void parameterNotNullWithMissingParameterName() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage("You must provide a parameter name!"); Assert.assertNotNull("", null); }