use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_updateLastUpdateErrorTest method testUpdateLastUpdateError_noEntityManager_assertException.
@Test
public void testUpdateLastUpdateError_noEntityManager_assertException() {
final Calendar now = Calendar.getInstance(Locale.getDefault());
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
boolean exceptionOccured = false;
try {
dao.updateLastUpdateError(1234, now, BundleRefreshError.NOT_FOUND);
} catch (IllegalStateException ex) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_updateTrustBundleAttributesTest method testUpdateTrustBundleAttributes_noEntityManager_assertException.
@Test
public void testUpdateTrustBundleAttributes_noEntityManager_assertException() throws Exception {
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
boolean exceptionOccured = false;
try {
TrustBundleAnchor anchor = new TrustBundleAnchor();
anchor.setData(loadCertificateData("secureHealthEmailCACert.der"));
dao.updateTrustBundleSigningCertificate(1234, anchor.toCertificate());
} catch (IllegalStateException ex) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_updateTrustBundleSigningCertificateTest method testUpdateTrustBundleSigningCertificate_exceptionInQuery_assertException.
@Test
public void testUpdateTrustBundleSigningCertificate_exceptionInQuery_assertException() throws Exception {
final EntityManager manager = mock(EntityManager.class);
doThrow(new RuntimeException("Just Passing Through")).when(manager).createQuery((String) any());
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
dao.setEntityManager(manager);
boolean exceptionOccured = false;
try {
TrustBundleAnchor anchor = new TrustBundleAnchor();
anchor.setData(loadCertificateData("secureHealthEmailCACert.der"));
tbDao.updateTrustBundleSigningCertificate(1234, anchor.toCertificate());
} catch (ConfigurationStoreException ex) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_disassociateTrustBundlesFromDomainTest method testDisassociateTrustBundlesFromDomain_unknownErrorInRemove_assertException.
@Test
public void testDisassociateTrustBundlesFromDomain_unknownErrorInRemove_assertException() {
boolean exceptionOccured = false;
final EntityManager mgr = mock(EntityManager.class);
final Domain domain = mock(Domain.class);
final DomainDao domainDao = mock(DomainDao.class);
when(domainDao.getDomain(new Long(1234))).thenReturn(domain);
final Query deleteQuery = mock(Query.class);
doThrow(new RuntimeException("Just Passing Through")).when(deleteQuery).executeUpdate();
when(mgr.createQuery("DELETE from TrustBundleDomainReltn tbd where tbd.domain = ?1")).thenReturn(deleteQuery);
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
final TrustBundleDaoImpl spyDao = spy(dao);
try {
spyDao.disassociateTrustBundlesFromDomain(1234);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(new Long(1234));
verify(deleteQuery, times(1)).executeUpdate();
}
use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_disassociateTrustBundlesFromDomainTest method testDisassociateTrustBundlesFromDomain_unknownDomain_assertException.
@Test
public void testDisassociateTrustBundlesFromDomain_unknownDomain_assertException() {
boolean exceptionOccured = false;
final EntityManager mgr = mock(EntityManager.class);
final DomainDao domainDao = mock(DomainDao.class);
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
TrustBundleDaoImpl spyDao = spy(dao);
try {
spyDao.disassociateTrustBundlesFromDomain(1234);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(new Long(1234));
}
Aggregations