@Test public void getCertificateTest() { CustomCertificateRepository customCertificateRepository = new MockCustomCertificateRepository(alias, content, testDate); DefaultCustomCertificateAccessor customCertificateAccessor = new DefaultCustomCertificateAccessor(customCertificateRepository); Optional<CustomCertificateModel> customCertificateModelOptional = customCertificateAccessor.getCertificate(0L); Optional<CustomCertificateModel> customCertificateModelOptionalEmpty = customCertificateAccessor.getCertificate(9L); assertTrue(customCertificateModelOptional.isPresent()); assertFalse(customCertificateModelOptionalEmpty.isPresent()); CustomCertificateModel customCertificateModel = customCertificateModelOptional.get(); testCustomCertificateModel(expectedCustomCertificateModel, customCertificateModel); }
@Override public Optional<CustomCertificateModel> getCertificate(Long id) { return customCertificateRepository.findById(id) .map(this::createModel); }
DefaultCustomCertificateAccessor implements CustomCertificateAccessor { @Override public Optional<CustomCertificateModel> getCertificate(Long id) { return customCertificateRepository.findById(id) .map(this::createModel); } }
DefaultCustomCertificateAccessor implements CustomCertificateAccessor { @Override public Optional<CustomCertificateModel> getCertificate(Long id) { return customCertificateRepository.findById(id) .map(this::createModel); } @Autowired  DefaultCustomCertificateAccessor(CustomCertificateRepository customCertificateRepository); }
DefaultCustomCertificateAccessor implements CustomCertificateAccessor { @Override public Optional<CustomCertificateModel> getCertificate(Long id) { return customCertificateRepository.findById(id) .map(this::createModel); } @Autowired  DefaultCustomCertificateAccessor(CustomCertificateRepository customCertificateRepository); @Override List<CustomCertificateModel> getCertificates(); @Override Optional<CustomCertificateModel> getCertificate(Long id); @Override CustomCertificateModel storeCertificate(CustomCertificateModel certificateModel); @Override void deleteCertificate(String certificateAlias); @Override void deleteCertificate(Long certificateId); }
DefaultCustomCertificateAccessor implements CustomCertificateAccessor { @Override public Optional<CustomCertificateModel> getCertificate(Long id) { return customCertificateRepository.findById(id) .map(this::createModel); } @Autowired  DefaultCustomCertificateAccessor(CustomCertificateRepository customCertificateRepository); @Override List<CustomCertificateModel> getCertificates(); @Override Optional<CustomCertificateModel> getCertificate(Long id); @Override CustomCertificateModel storeCertificate(CustomCertificateModel certificateModel); @Override void deleteCertificate(String certificateAlias); @Override void deleteCertificate(Long certificateId);  }