InstanceCertManager { public boolean updateX509CertRecord(X509CertRecord certRecord) { if (certStore == null) { return false; } boolean result; try (CertRecordStoreConnection storeConnection = certStore.getConnection()) { result = storeConnection.updateX509CertRecord(certRecord); } return result; } InstanceCertManager(final PrivateKeyStore keyStore, Authorizer authorizer, HostnameResolver hostnameResolver,
            boolean readOnlyMode); void setCertStore(CertRecordStore certStore); void setSSHStore(SSHRecordStore sshStore); CertificateAuthorityBundle getCertificateAuthorityBundle(final String name); List<X509CertRecord> getUnrefreshedCertsNotifications(String serverHostName, String provider); X509CertRecord getX509CertRecord(final String provider, X509Certificate cert); X509CertRecord getX509CertRecord(final String provider, final String instanceId,
            final String service); boolean updateX509CertRecord(X509CertRecord certRecord); boolean deleteX509CertRecord(final String provider, final String instanceId,
            final String service); boolean insertX509CertRecord(X509CertRecord certRecord); String generateX509Certificate(final String csr, final String keyUsage, int expiryTime); String getCACertificate(); InstanceIdentity generateIdentity(String csr, String cn, String keyUsage,
            int expiryTime); String getX509CertificateSigner(); SSHCertificates generateSSHCertificates(Principal principal, SSHCertRequest certRequest); boolean generateSSHIdentity(Principal principal, InstanceIdentity identity, final String hostname,
            final String csr, SSHCertRecord sshCertRecord, final String certType); boolean authorizeLaunch(Principal providerService, String domain, String service,
            StringBuilder errorMsg); boolean verifyCertRefreshIPAddress(final String ipAddress); boolean verifyInstanceCertIPAddress(final String provider, final String ipAddress); boolean validPrincipals(final String hostname, SSHCertRecord sshCertRecord, SshHostCsr sshHostCsr); void logX509Cert(final Principal principal, final String ip, final String provider,
            final String instanceId, final X509Certificate x509Cert); SSHCertRecord getSSHCertRecord(final String instanceId, final String service); boolean updateSSHCertRecord(SSHCertRecord certRecord, boolean refresh); boolean enableCertStoreNotifications(NotificationManager notificationManager, RolesProvider rolesProvider, String serverName); boolean enableSSHStoreNotifications(NotificationManager notificationManager, RolesProvider rolesProvider, String serverName);  }
@Test public void testUpdateX509CertRecord() { InstanceCertManager instance = new InstanceCertManager(null, null, null, true); instance.setCertSigner(null); CertRecordStore certStore = Mockito.mock(CertRecordStore.class); CertRecordStoreConnection certConnection = Mockito.mock(CertRecordStoreConnection.class); when(certStore.getConnection()).thenReturn(certConnection); when(certConnection.updateX509CertRecord(ArgumentMatchers.isA(X509CertRecord.class))).thenReturn(true); instance.setCertStore(certStore); X509CertRecord x509CertRecord = new X509CertRecord(); boolean result = instance.updateX509CertRecord(x509CertRecord); assertTrue(result); instance.shutdown(); }