DynamoDBCertRecordStoreConnection implements CertRecordStoreConnection { @Override public X509CertRecord getX509CertRecord(String provider, String instanceId, String service) { final String primaryKey = getPrimaryKey(provider, instanceId, service); try { Item item = table.getItem(KEY_PRIMARY, primaryKey); if (item == null) { LOGGER.error("DynamoDB Get Error for {}: item not found", primaryKey); return null; } return itemToX509CertRecord(item); } catch (Exception ex) { LOGGER.error("DynamoDB Get Error for {}: {}/{}", primaryKey, ex.getClass(), ex.getMessage()); return null; } } DynamoDBCertRecordStoreConnection(DynamoDB dynamoDB, final String tableName, String indexName); @Override void setOperationTimeout(int queryTimeout); @Override void close(); @Override X509CertRecord getX509CertRecord(String provider, String instanceId, String service); @Override boolean updateX509CertRecord(X509CertRecord certRecord); @Override boolean insertX509CertRecord(X509CertRecord certRecord); @Override boolean deleteX509CertRecord(String provider, String instanceId, String service); @Override int deleteExpiredX509CertRecords(int expiryTimeMins); @Override List<X509CertRecord> updateUnrefreshedCertificatesNotificationTimestamp(String lastNotifiedServer,
                                                                      long lastNotifiedTime,
                                                                      String provider);  }
@Test public void testGetX509CertRecord() { Date now = new Date(); long tstamp = mockNonNullableColumns(now); Mockito.doReturn(tstamp).when(item).getLong("lastNotifiedTime"); Mockito.doReturn(tstamp).when(item).get("lastNotifiedTime"); Mockito.doReturn("last-notified-server").when(item).getString("lastNotifiedServer"); Mockito.doReturn(tstamp).when(item).getLong("expiryTime"); Mockito.doReturn(tstamp).when(item).get("expiryTime"); Mockito.doReturn("hostname").when(item).getString("hostName"); DynamoDBCertRecordStoreConnection dbConn = getDBConnection(); dbConn.setOperationTimeout(10); X509CertRecord certRecord = dbConn.getX509CertRecord("athenz.provider", "1234", "cn"); assertNonNullableColumns(now, certRecord); assertEquals(certRecord.getLastNotifiedTime(), now); assertEquals(certRecord.getLastNotifiedServer(), "last-notified-server"); assertEquals(certRecord.getExpiryTime(), now); assertEquals(certRecord.getHostName(), "hostname"); dbConn.close(); }