use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.
the class CertPolicyDaoImpl_getPolicyGroupByIdTest method testGetPolicyGroupById_exceptionInQuery_assertException.
@Test
public void testGetPolicyGroupById_exceptionInQuery_assertException() {
final EntityManager manager = mock(EntityManager.class);
doThrow(new RuntimeException("Just Passing Through")).when(manager).createQuery((String) any());
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
dao.setEntityManager(manager);
boolean exceptionOccured = false;
try {
dao.getPolicyGroupById(1234);
} catch (ConfigurationStoreException ex) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.
the class CertPolicyDaoImpl_getPolicyGroupByIdTest method testGetPolicyGroupById_noEntityManager_assertException.
@Test
public void testGetPolicyGroupById_noEntityManager_assertException() {
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
boolean exceptionOccured = false;
try {
dao.getPolicyGroupById(1234);
} catch (IllegalStateException ex) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.
the class CertPolicyDaoImpl_disassociatePolicyGroupFromDomainTest method testDisassociatePolicyGroupFromDomain_noEntityManager_assertException.
@Test
public void testDisassociatePolicyGroupFromDomain_noEntityManager_assertException() {
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
boolean exceptionOccured = false;
try {
dao.disassociatePolicyGroupFromDomain(1234, 5678);
} catch (IllegalStateException ex) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.
the class CertPolicyDaoImpl_disassociatePolicyGroupFromDomainTest method testDisassociatePolicyGroupFromDomain_unknownErrorInRemove_assertException.
@Test
public void testDisassociatePolicyGroupFromDomain_unknownErrorInRemove_assertException() {
boolean exceptionOccured = false;
final EntityManager mgr = mock(EntityManager.class);
doThrow(new RuntimeException("Just Passing Through")).when(mgr).remove((CertPolicyGroupDomainReltn) any());
final Domain domain = mock(Domain.class);
final DomainDao domainDao = mock(DomainDao.class);
when(domainDao.getDomain(new Long(1234))).thenReturn(domain);
final CertPolicyGroup group = mock(CertPolicyGroup.class);
final Query query = mock(Query.class);
when(query.getSingleResult()).thenReturn(group);
when(mgr.createQuery("SELECT cpg from CertPolicyGroup cpg WHERE cpg.id = ?1")).thenReturn(query);
final CertPolicyGroupDomainReltn reltn = mock(CertPolicyGroupDomainReltn.class);
final Query findReltnQeury = mock(Query.class);
when(findReltnQeury.getSingleResult()).thenReturn(reltn);
when(mgr.createQuery("SELECT cpr from CertPolicyGroupDomainReltn cpr where cpr.domain = ?1 " + " and cpr.certPolicyGroup = ?2 ")).thenReturn(findReltnQeury);
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
final CertPolicyDaoImpl spyDao = spy(dao);
try {
spyDao.disassociatePolicyGroupFromDomain(1234, 5678);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(1234L);
verify(spyDao, times(1)).getPolicyGroupById(5678);
verify(mgr, times(1)).remove((CertPolicyGroupDomainReltn) any());
}
use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.
the class CertPolicyDaoImpl_disassociatePolicyGroupFromDomainsTest method testDisassociatePolicyGroupFromDomains_noEntityManager_assertException.
@Test
public void testDisassociatePolicyGroupFromDomains_noEntityManager_assertException() {
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
boolean exceptionOccured = false;
try {
dao.disassociatePolicyGroupFromDomains(1234);
} catch (IllegalStateException ex) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
Aggregations