use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundlDaoImpl_deleteTrustBundlesTest method testDeleteTrustBundlesTest_noEntityManager_assertException.
@Test
public void testDeleteTrustBundlesTest_noEntityManager_assertException() {
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
boolean exceptionOccured = false;
try {
dao.deleteTrustBundles(new long[] { 1234 });
} 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_getTrustBundlesByDomainTest method testGetTrustBundlesByDomain_errorInGet_assertException.
@Test
public void testGetTrustBundlesByDomain_errorInGet_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 TrustBundleDomainReltn reltn = mock(TrustBundleDomainReltn.class);
final Query findReltnQeury = mock(Query.class);
when(findReltnQeury.getSingleResult()).thenReturn(reltn);
doThrow(new RuntimeException("Just Passing Through")).when(findReltnQeury).getResultList();
when(mgr.createQuery("SELECT tbd from TrustBundleDomainReltn tbd where tbd.domain = ?1")).thenReturn(findReltnQeury);
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
final TrustBundleDaoImpl spyDao = spy(dao);
try {
spyDao.getTrustBundlesByDomain(1234);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(new Long(1234));
verify(findReltnQeury, times(1)).getResultList();
}
use of org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_getTrustBundlesByDomainTest method testGetTrustBundlesByDomain_noEntityManager_assertException.
@Test
public void testGetTrustBundlesByDomain_noEntityManager_assertException() {
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
boolean exceptionOccured = false;
try {
dao.getTrustBundlesByDomain(1234);
} 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_updateLastUpdateErrorTest method testUpdateLastUpdateError_exceptionInQuery_assertException.
@Test
public void testUpdateLastUpdateError_exceptionInQuery_assertException() {
final Calendar now = Calendar.getInstance(Locale.getDefault());
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 {
tbDao.updateLastUpdateError(1234, now, BundleRefreshError.NOT_FOUND);
} 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_updateTrustBundleAnchorsTest method testUpdateTrustBundleAnchors_exceptionInQuery_assertException.
@Test
public void testUpdateTrustBundleAnchors_exceptionInQuery_assertException() {
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 {
dao.updateTrustBundleAnchors(1234, Calendar.getInstance(Locale.getDefault()), new ArrayList<TrustBundleAnchor>(), "6789");
} catch (ConfigurationStoreException ex) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
Aggregations