### Question:
LdapTlsHandshakeExceptionClassifier { public static LdapTlsHandshakeFailCause classify( Throwable cause ) { return classify( cause, null ); } private  LdapTlsHandshakeExceptionClassifier(); static LdapTlsHandshakeFailCause classify( Throwable cause ); static LdapTlsHandshakeFailCause classify( Throwable cause, X509Certificate certificate );  }### Answer:
@Test public void testClassifyNull() { LdapTlsHandshakeFailCause classification = LdapTlsHandshakeExceptionClassifier.classify( null ); assertThat( classification.getReason(), equalTo( ( Reason ) BasicReason.UNSPECIFIED ) ); assertThat( classification.getReasonPhrase(), equalTo( "Unspecified" ) ); assertThat( classification.getRootCause(), equalTo( null ) ); }
@Test public void testClassifyOther() { LdapTlsHandshakeFailCause classification = LdapTlsHandshakeExceptionClassifier .classify( new IOException( "foo" ) ); assertThat( classification.getReason(), equalTo( ( Reason ) BasicReason.UNSPECIFIED ) ); assertThat( classification.getReasonPhrase(), equalTo( "Unspecified" ) ); assertThat( classification.getRootCause(), instanceOf( IOException.class ) ); }
@Test public void testClassifyCertificateExpiredException() { LdapTlsHandshakeFailCause classification = LdapTlsHandshakeExceptionClassifier .classify( new CertificateExpiredException( "foo" ) ); assertThat( classification.getReason(), equalTo( ( Reason ) BasicReason.EXPIRED ) ); assertThat( classification.getReasonPhrase(), equalTo( "Certificate expired" ) ); assertThat( classification.getRootCause(), instanceOf( CertificateExpiredException.class ) ); }
@Test public void testClassifyCertificateNotYetValidException() { LdapTlsHandshakeFailCause classification = LdapTlsHandshakeExceptionClassifier .classify( new CertificateNotYetValidException( "foo" ) ); assertThat( classification.getReason(), equalTo( ( Reason ) BasicReason.NOT_YET_VALID ) ); assertThat( classification.getReasonPhrase(), equalTo( "Certificate not yet valid" ) ); assertThat( classification.getRootCause(), instanceOf( CertificateNotYetValidException.class ) ); }
@Test public void testClassifyCertPathBuilderException() { LdapTlsHandshakeFailCause classification = LdapTlsHandshakeExceptionClassifier .classify( new Exception( new CertPathBuilderException( "foo" ) ) ); assertThat( classification.getReason(), equalTo( ( Reason ) LdapApiReason.NO_VALID_CERTIFICATION_PATH ) ); assertThat( classification.getReasonPhrase(), equalTo( "Failed to build certification path" ) ); assertThat( classification.getRootCause(), instanceOf( CertPathBuilderException.class ) ); }
@Test public void testClassifyCertPathValidatorException() { LdapTlsHandshakeFailCause classification = LdapTlsHandshakeExceptionClassifier.classify( new Exception( new Exception( new Exception( new Exception( new CertPathValidatorException( "foo", null, null, -1, BasicReason.ALGORITHM_CONSTRAINED ) ) ) ) ) ); assertThat( classification.getReason(), equalTo( ( Reason ) BasicReason.ALGORITHM_CONSTRAINED ) ); assertThat( classification.getReasonPhrase(), equalTo( "Failed to verify certification path" ) ); assertThat( classification.getRootCause(), instanceOf( CertPathValidatorException.class ) ); }