### Question:
DefaultCertificateClient implements CertificateClient { @Override public byte[] signDataStream(InputStream stream) throws CertificateException { try { Signature sign = Signature.getInstance(securityConfig.getSignatureAlgo(), securityConfig.getProvider()); sign.initSign(getPrivateKey()); byte[] buffer = new byte[1024 * 4]; int len; while (-1 != (len = stream.read(buffer))) { sign.update(buffer, 0, len); } return sign.sign(); } catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidKeyException | SignatureException | IOException e) { getLogger().error("Error while signing the stream", e); throw new CertificateException("Error while signing the stream", e, CRYPTO_SIGN_ERROR); } } DefaultCertificateClient(SecurityConfig securityConfig, Logger log,
      String certSerialId, String component); @Override PrivateKey getPrivateKey(); @Override PublicKey getPublicKey(); @Override X509Certificate getCertificate(); @Override X509Certificate getCACertificate(); @Override X509Certificate getCertificate(String certId); @Override boolean verifyCertificate(X509Certificate certificate); @Override byte[] signDataStream(InputStream stream); @Override byte[] signData(byte[] data); @Override boolean verifySignature(InputStream stream, byte[] signature,
      X509Certificate cert); @Override boolean verifySignature(byte[] data, byte[] signature,
      X509Certificate cert); @Override CertificateSignRequest.Builder getCSRBuilder(); @Override X509Certificate queryCertificate(String query); @Override void storeCertificate(String pemEncodedCert, boolean force); @Override void storeCertificate(String pemEncodedCert, boolean force,
      boolean caCert); @Override synchronized void storeTrustChain(CertStore ks); @Override synchronized void storeTrustChain(List<X509Certificate> certificates); @Override synchronized InitResponse init(); Logger getLogger();  }### Answer:
@Test public void testSignDataStream() throws Exception { String data = RandomStringUtils.random(100, UTF); FileUtils.deleteQuietly(Paths.get( omSecurityConfig.getKeyLocation(OM_COMPONENT).toString(), omSecurityConfig.getPrivateKeyFileName()).toFile()); FileUtils.deleteQuietly(Paths.get( omSecurityConfig.getKeyLocation(OM_COMPONENT).toString(), omSecurityConfig.getPublicKeyFileName()).toFile()); LambdaTestUtils.intercept(IOException.class, "Error while " + "signing the stream", () -> omCertClient.signDataStream(IOUtils.toInputStream(data, UTF))); generateKeyPairFiles(); byte[] sign = omCertClient.signDataStream(IOUtils.toInputStream(data, UTF)); validateHash(sign, data.getBytes()); }