use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_updateTrustBundleAnchorsTest method testUpdateTrustBundleAnchors_noEntityManager_assertException.
@Test
public void testUpdateTrustBundleAnchors_noEntityManager_assertException() {
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
boolean exceptionOccured = false;
try {
dao.updateTrustBundleAnchors(1234, Calendar.getInstance(Locale.getDefault()), new ArrayList<TrustBundleAnchor>(), "6789");
} 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_exceptionInQuery_assertException.
@Test
public void testUpdateTrustBundleAttributes_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_updateTrustBundleSigningCertificateTest method testUpdateTrustBundleSigningCertificate_noEntityManager_assertException.
@Test
public void testUpdateTrustBundleSigningCertificate_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_associateTrustBundleToDomainTest method testAssociateTrustBundleToDomain_errorInAdd_assertException.
@Test
public void testAssociateTrustBundleToDomain_errorInAdd_assertException() {
boolean exceptionOccured = false;
final EntityManager mgr = mock(EntityManager.class);
doThrow(new RuntimeException("Just Passing Through")).when(mgr).persist((TrustBundleDomainReltn) any());
final Domain domain = mock(Domain.class);
final DomainDao domainDao = mock(DomainDao.class);
when(domainDao.getDomain(new Long(1234))).thenReturn(domain);
final TrustBundle bundle = mock(TrustBundle.class);
final Query query = mock(Query.class);
when(query.getSingleResult()).thenReturn(bundle);
when(mgr.createQuery("SELECT tb from TrustBundle tb WHERE tb.id = ?1")).thenReturn(query);
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
final TrustBundleDaoImpl spyDao = spy(dao);
try {
spyDao.associateTrustBundleToDomain(1234, 5678, true, true);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(new Long(1234));
verify(spyDao, times(1)).getTrustBundleById(5678);
verify(mgr, times(1)).persist((TrustBundleDomainReltn) any());
}
use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_associateTrustBundleToDomainTest method testAssociateTrustBundleToDomain_unknownTrustBundle_assertException.
@Test
public void testAssociateTrustBundleToDomain_unknownTrustBundle_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 TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
final Query query = mock(Query.class);
doThrow(new NoResultException()).when(query).getSingleResult();
when(mgr.createQuery("SELECT tb from TrustBundle tb WHERE tb.id = ?1")).thenReturn(query);
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
final TrustBundleDaoImpl spyDao = spy(dao);
try {
spyDao.associateTrustBundleToDomain(1234, 5678, true, true);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(new Long(1234));
verify(spyDao, times(1)).getTrustBundleById(5678);
verify(mgr, never()).persist((TrustBundleDomainReltn) any());
}
Aggregations