SignatureUtil { public static Signature createSignature(String algorithm) { AssertUtil.notNull(algorithm, "algorithm is required; it must not be null"); try { return Signature.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException(e); } } private  SignatureUtil(); @Deprecated static Signature getRS256(); @Deprecated static Signature getES256(); static Signature createRS256(); static Signature createES256(); static Signature createSignature(String algorithm);  }
@Test void createSignature_test() { SignatureUtil.createSignature("SHA256withRSA"); }
@Test void createSignature_test_with_null() { Throwable t = assertThrows(IllegalArgumentException.class, () -> SignatureUtil.createSignature(null) ); assertThat(t).hasMessage("algorithm is required; it must not be null"); }
@Test void createSignature_test_with_illegal_argument() { Throwable t = assertThrows(IllegalArgumentException.class, () -> SignatureUtil.createSignature("dummyAlg") ); assertThat(t).hasMessageContaining("dummyAlg Signature not available"); }