use of org.nhindirect.config.store.dao.DomainDao in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_disassociateTrustBundleFromDomainTest method testDisassociateTrustBundleFromDomain_unknownTrustBundle_assertException.
@Test
public void testDisassociateTrustBundleFromDomain_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.disassociateTrustBundleFromDomain(1234, 5678);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(new Long(1234));
verify(spyDao, times(1)).getTrustBundleById(5678);
verify(mgr, never()).remove((TrustBundleDomainReltn) any());
}
Aggregations