### Question:
DBCertificateManager extends DBManager<Certificate> implements CertificateManager { @Override @SuppressWarnings("unchecked") public <T extends Certificate> Set<T> get(final CertificateSelector certificateSelector) { return new HashSet<>( (List<T>) getWithCriteria( certificateSelector.getCertificateClass(), Collections.singleton(certificateSelector.getCriterion()) ) ); } DBCertificateManager(final SessionFactory sessionFactory); @Override @SuppressWarnings("unchecked") Set<T> get(final CertificateSelector certificateSelector); boolean deleteCertificate(final Certificate certificate);  }### Answer:
@Test public void testGet() throws IOException { CertificateManager certMan = new DBCertificateManager(sessionFactory); saveTestCertsToDb(certMan); Assert.assertEquals( testCertificates.get(CertificateAuthorityCredential.class), CertificateAuthorityCredential.select(certMan).getCertificate() ); Assert.assertEquals( testCertificates.get(ConformanceCredential.class), ConformanceCredential.select(certMan).getCertificate() ); Assert.assertEquals( testCertificates.get(EndorsementCredential.class), EndorsementCredential.select(certMan).getCertificate() ); Assert.assertEquals( testCertificates.get(PlatformCredential.class), PlatformCredential.select(certMan).getCertificate() ); IssuedAttestationCertificate issuedAttestationCertificate = IssuedAttestationCertificate.select(certMan).getCertificate(); Assert.assertEquals( testCertificates.get(IssuedAttestationCertificate.class), issuedAttestationCertificate); Assert.assertTrue(issuedAttestationCertificate.getEndorsementCredential() .equals(EndorsementCredential.select(certMan).getCertificate())); Assert.assertTrue(issuedAttestationCertificate.getPlatformCredentials() .containsAll(PlatformCredential.select(certMan).getCertificates())); }
@Test public void testGetPlatformByCriteria() throws IOException { CertificateManager certMan = new DBCertificateManager(sessionFactory); saveTestCertsToDb(certMan); PlatformCredential platformCredentialByManufacturer = PlatformCredential .select(certMan) .byManufacturer("Intel") .getCertificate(); Assert.assertEquals( testCertificates.get(PlatformCredential.class), platformCredentialByManufacturer ); Assert.assertEquals( testCertificates.get(PlatformCredential.class), PlatformCredential.select(certMan).byModel("DE3815TYKH") .getCertificate() ); Assert.assertEquals( testCertificates.get(PlatformCredential.class), PlatformCredential.select(certMan).byVersion("H26998-402") .getCertificate() ); Assert.assertEquals( testCertificates.get(PlatformCredential.class), PlatformCredential.select(certMan).byIssuer( "C=US,ST=CA,L=Santa Clara,O=Intel Corporation," + "OU=Transparent Supply Chain,CN=www.intel.com" ).getCertificate() ); UUID uuid = platformCredentialByManufacturer.getId(); Assert.assertEquals( testCertificates.get(PlatformCredential.class), PlatformCredential.select(certMan).byEntityId(uuid).getCertificate() ); Assert.assertEquals( testCertificates.get(PlatformCredential.class), PlatformCredential.select(certMan) .byManufacturer("Intel") .byModel("DE3815TYKH") .byVersion("H26998-402") .byIssuer( "C=US,ST=CA,L=Santa Clara,O=Intel Corporation," + "OU=Transparent Supply Chain,CN=www.intel.com" ).getCertificate() ); Assert.assertNull( PlatformCredential.select(certMan).byBoardSerialNumber( "BQKP52840678" ).getCertificate() ); }