@Test public void should_return_empty_when_identity_is_missing() throws InvalidParseOperationException { Optional<IdentityModel> result = identityRepository.findIdentity("invalid_dn", String.valueOf(BigInteger.ZERO)); assertThat(result).isEmpty(); }
public Optional<IdentityModel> findIdentity(String subjectDN, String serialNumber) throws InvalidParseOperationException { FindIterable<Document> models = identityCollection.find(filterBySubjectDNAndSerialNumber(subjectDN, serialNumber)); Document first = models.first(); if (first == null) { return Optional.empty(); } return Optional.of(JsonHandler.getFromString(BsonHelper.stringify(first), IdentityModel.class)); }
IdentityRepository implements CertificateCRLCheckStateUpdater<IdentityModel> { public Optional<IdentityModel> findIdentity(String subjectDN, String serialNumber) throws InvalidParseOperationException { FindIterable<Document> models = identityCollection.find(filterBySubjectDNAndSerialNumber(subjectDN, serialNumber)); Document first = models.first(); if (first == null) { return Optional.empty(); } return Optional.of(JsonHandler.getFromString(BsonHelper.stringify(first), IdentityModel.class)); } }
IdentityRepository implements CertificateCRLCheckStateUpdater<IdentityModel> { public Optional<IdentityModel> findIdentity(String subjectDN, String serialNumber) throws InvalidParseOperationException { FindIterable<Document> models = identityCollection.find(filterBySubjectDNAndSerialNumber(subjectDN, serialNumber)); Document first = models.first(); if (first == null) { return Optional.empty(); } return Optional.of(JsonHandler.getFromString(BsonHelper.stringify(first), IdentityModel.class)); } @VisibleForTesting  IdentityRepository(MongoDbAccess mongoDbAccess, String collectionName);  IdentityRepository(MongoDbAccess mongoDbAccess); }
IdentityRepository implements CertificateCRLCheckStateUpdater<IdentityModel> { public Optional<IdentityModel> findIdentity(String subjectDN, String serialNumber) throws InvalidParseOperationException { FindIterable<Document> models = identityCollection.find(filterBySubjectDNAndSerialNumber(subjectDN, serialNumber)); Document first = models.first(); if (first == null) { return Optional.empty(); } return Optional.of(JsonHandler.getFromString(BsonHelper.stringify(first), IdentityModel.class)); } @VisibleForTesting  IdentityRepository(MongoDbAccess mongoDbAccess, String collectionName);  IdentityRepository(MongoDbAccess mongoDbAccess); void createIdentity(IdentityModel identityModel); Optional<IdentityModel> findIdentity(String subjectDN, String serialNumber); void linkContextToIdentity(String subjectDN, String contextId, String serialNumber); boolean contextIsUsed(String contextId); @Override FindIterable<Document> findCertificate(String issuerDN, CertificateStatus certificateStatus); @Override void updateCertificateState(List<String> certificatesToUpdate, CertificateStatus certificateStatus); @Override Class<IdentityModel> getEntityModelType(); }
IdentityRepository implements CertificateCRLCheckStateUpdater<IdentityModel> { public Optional<IdentityModel> findIdentity(String subjectDN, String serialNumber) throws InvalidParseOperationException { FindIterable<Document> models = identityCollection.find(filterBySubjectDNAndSerialNumber(subjectDN, serialNumber)); Document first = models.first(); if (first == null) { return Optional.empty(); } return Optional.of(JsonHandler.getFromString(BsonHelper.stringify(first), IdentityModel.class)); } @VisibleForTesting  IdentityRepository(MongoDbAccess mongoDbAccess, String collectionName);  IdentityRepository(MongoDbAccess mongoDbAccess); void createIdentity(IdentityModel identityModel); Optional<IdentityModel> findIdentity(String subjectDN, String serialNumber); void linkContextToIdentity(String subjectDN, String contextId, String serialNumber); boolean contextIsUsed(String contextId); @Override FindIterable<Document> findCertificate(String issuerDN, CertificateStatus certificateStatus); @Override void updateCertificateState(List<String> certificatesToUpdate, CertificateStatus certificateStatus); @Override Class<IdentityModel> getEntityModelType(); static final String CERTIFICATE_COLLECTION; }