Secret { static Secret newInstance(final String key, final String value) { return new Secret(key, value); } private  Secret(final String name, final String value); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void tryToCreateNewInstanceWithNullName() { assertThatNullPointerException() .isThrownBy(() -> Secret.newInstance(null, KNOWN_VALUE)) .withMessage("The Secret name must not be null!") .withNoCause(); }
@Test public void tryToCreateNewInstanceWithNullValue() { assertThatNullPointerException() .isThrownBy(() -> Secret.newInstance(KNOWN_NAME, null)) .withMessage("The Secret value must not be null!") .withNoCause(); }