@Test public void deleteCertificateByAliasBlankTest() throws Exception { CustomCertificateRepository customCertificateRepository = new MockCustomCertificateRepository(alias, content, testDate); DefaultCustomCertificateAccessor customCertificateAccessor = new DefaultCustomCertificateAccessor(customCertificateRepository); try { customCertificateAccessor.deleteCertificate(""); fail(); } catch (AlertDatabaseConstraintException e) { assertNotNull(e); } }
@Override public void deleteCertificate(String certificateAlias) throws AlertDatabaseConstraintException { if (StringUtils.isBlank(certificateAlias)) { throw new AlertDatabaseConstraintException("The field 'certificateAlias' cannot be blank"); } CustomCertificateEntity customCertificateEntity = customCertificateRepository.findByAlias(certificateAlias) .orElseThrow(() -> new AlertDatabaseConstraintException("A custom certificate with the alias " + certificateAlias + " did not exist")); deleteCertificate(customCertificateEntity.getId()); }
DefaultCustomCertificateAccessor implements CustomCertificateAccessor { @Override public void deleteCertificate(String certificateAlias) throws AlertDatabaseConstraintException { if (StringUtils.isBlank(certificateAlias)) { throw new AlertDatabaseConstraintException("The field 'certificateAlias' cannot be blank"); } CustomCertificateEntity customCertificateEntity = customCertificateRepository.findByAlias(certificateAlias) .orElseThrow(() -> new AlertDatabaseConstraintException("A custom certificate with the alias " + certificateAlias + " did not exist")); deleteCertificate(customCertificateEntity.getId()); } }
DefaultCustomCertificateAccessor implements CustomCertificateAccessor { @Override public void deleteCertificate(String certificateAlias) throws AlertDatabaseConstraintException { if (StringUtils.isBlank(certificateAlias)) { throw new AlertDatabaseConstraintException("The field 'certificateAlias' cannot be blank"); } CustomCertificateEntity customCertificateEntity = customCertificateRepository.findByAlias(certificateAlias) .orElseThrow(() -> new AlertDatabaseConstraintException("A custom certificate with the alias " + certificateAlias + " did not exist")); deleteCertificate(customCertificateEntity.getId()); } @Autowired  DefaultCustomCertificateAccessor(CustomCertificateRepository customCertificateRepository); }
DefaultCustomCertificateAccessor implements CustomCertificateAccessor { @Override public void deleteCertificate(String certificateAlias) throws AlertDatabaseConstraintException { if (StringUtils.isBlank(certificateAlias)) { throw new AlertDatabaseConstraintException("The field 'certificateAlias' cannot be blank"); } CustomCertificateEntity customCertificateEntity = customCertificateRepository.findByAlias(certificateAlias) .orElseThrow(() -> new AlertDatabaseConstraintException("A custom certificate with the alias " + certificateAlias + " did not exist")); deleteCertificate(customCertificateEntity.getId()); } @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 void deleteCertificate(String certificateAlias) throws AlertDatabaseConstraintException { if (StringUtils.isBlank(certificateAlias)) { throw new AlertDatabaseConstraintException("The field 'certificateAlias' cannot be blank"); } CustomCertificateEntity customCertificateEntity = customCertificateRepository.findByAlias(certificateAlias) .orElseThrow(() -> new AlertDatabaseConstraintException("A custom certificate with the alias " + certificateAlias + " did not exist")); deleteCertificate(customCertificateEntity.getId()); } @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);  }