### Question:
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; }  @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer);  }### Answer:
@Test public void testValidatingAValidDocument() throws Exception { Document doc = getDocument("complete-valid2.xml"); Assert.assertTrue(validator.isDocumentValid(doc)); }
@Test public void testValidatingAnInvalidDocument() throws Exception { Document doc = getDocument("complete-invalid.xml"); Assert.assertTrue(!validator.isDocumentValid(doc)); }