### Question:
DigiDoc4J { public static boolean isWarning(String documentFormat, DigiDoc4JException exception) { int errorCode = exception.getErrorCode(); return (errorCode == DigiDocException.ERR_DF_INV_HASH_GOOD_ALT_HASH || errorCode == DigiDocException.ERR_OLD_VER || errorCode == DigiDocException.ERR_TEST_SIGNATURE || errorCode == DigiDocException.WARN_WEAK_DIGEST || (errorCode == DigiDocException.ERR_ISSUER_XMLNS && !documentFormat.equals(SignedDoc.FORMAT_SK_XML))); } private  DigiDoc4J(); static void main(String[] args); static boolean isWarning(String documentFormat, DigiDoc4JException exception);  }### Answer:
@Test public void testIsWarningWhenNoWarningExists() throws DigiDocException { Assert.assertFalse(isWarning(SignedDoc.FORMAT_DIGIDOC_XML, new DigiDoc4JException(1, "testError"))); }
@Test public void testIsNotWarningWhenCodeIsErrIssuerXmlnsAndDocumentFormatIsSkXML() throws DigiDocException { Assert.assertFalse(isWarning(SignedDoc.FORMAT_SK_XML, new DigiDoc4JException(DigiDocException.ERR_ISSUER_XMLNS, "testError"))); }
@Test public void testIsWarningWhenCodeIsErrIssuerXmlnsAndDocumentFormatIsNotSkXML() throws DigiDocException { Assert.assertTrue(isWarning(SignedDoc.FORMAT_DIGIDOC_XML, new DigiDoc4JException(DigiDocException.ERR_ISSUER_XMLNS, "testError"))); }
@Test public void testIsWarningWhenWarningIsFound() throws DigiDocException { Assert.assertTrue(isWarning(SignedDoc.FORMAT_DIGIDOC_XML, new DigiDoc4JException(DigiDocException.ERR_DF_INV_HASH_GOOD_ALT_HASH, "test"))); Assert.assertTrue(isWarning(SignedDoc.FORMAT_DIGIDOC_XML, new DigiDoc4JException(DigiDocException.ERR_OLD_VER, "test"))); Assert.assertTrue(isWarning(SignedDoc.FORMAT_DIGIDOC_XML, new DigiDoc4JException(DigiDocException.ERR_TEST_SIGNATURE, "test"))); Assert.assertTrue(isWarning(SignedDoc.FORMAT_DIGIDOC_XML, new DigiDoc4JException(DigiDocException.WARN_WEAK_DIGEST, "test"))); }