### Question:
X509Cert implements Serializable { public boolean isValid(Date date) { logger.debug("Date: " + date); try { originalCert.checkValidity(date); } catch (CertificateExpiredException e) { logger.debug("Date " + date + " is not valid"); return false; } catch (CertificateNotYetValidException e) { logger.debug("Date " + date + " is not valid"); return false; } logger.debug("Date " + date + " is valid"); return true; } X509Cert(X509Certificate cert);   X509Cert(String path); List<String> getCertificatePolicies(); X509Certificate getX509Certificate(); String issuerName(Issuer part); String issuerName(); boolean isValid(Date date); boolean isValid(); List<KeyUsage> getKeyUsages(); String getSerial(); String getSubjectName(SubjectName part); String getSubjectName();  }### Answer:
@Test public void testIsValidAtSpecifiedDate() { Assert.assertTrue(this.certificate.isValid(new Date())); }
@Test public void testIsNotValidYet() throws ParseException { Date certValidFrom = this.dateFormat.parse("17.04.2014"); Assert.assertFalse(this.certificate.isValid(new Date(certValidFrom.getTime() - TestConstants.ONE_DAY_IN_MILLIS))); }
@Test public void testIsNoLongerValid() throws ParseException { Date certValidFrom = this.dateFormat.parse("12.04.2016"); Assert.assertFalse(this.certificate.isValid(new Date(certValidFrom.getTime() + TestConstants.ONE_DAY_IN_MILLIS))); }
@Test public void testIsValidThrowsCertificateExpiredException() throws Exception { X509Certificate mock = Mockito.mock(X509Certificate.class); Mockito.doThrow(new CertificateExpiredException()).when(mock).checkValidity(); new X509Cert(mock).isValid(); }
@Test public void testIsValidThrowsCertificateNotYetValidException() throws Exception { X509Certificate mock = Mockito.mock(X509Certificate.class); Mockito.doThrow(new CertificateNotYetValidException()).when(mock).checkValidity(); new X509Cert(mock).isValid(); }
@Test public void testIsCertValidToday() { Assert.assertTrue(this.certificate.isValid()); }