use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.
the class CertPolicyDaoImpl_disassociatePolicyGroupsFromDomainTest method testDisassociatePolicyGroupsFromDomain_noEntityManager_assertException.
@Test
public void testDisassociatePolicyGroupsFromDomain_noEntityManager_assertException() {
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
boolean exceptionOccured = false;
try {
dao.disassociatePolicyGroupsFromDomain(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_disassociatePolicyGroupsFromDomainTest method testDisassociatePolicyGroupsFromDomain_unknownErrorInRemove_assertException.
@Test
public void testDisassociatePolicyGroupsFromDomain_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 CertPolicyGroupDomainReltn cpr where cpr.domain = ?1")).thenReturn(deleteQuery);
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
final CertPolicyDaoImpl spyDao = spy(dao);
try {
spyDao.disassociatePolicyGroupsFromDomain(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.CertPolicyDaoImpl in project nhin-d by DirectProject.
the class CertPolicyDaoImpl_addPolicyUseToGroupTest method testAddPolicyToGroup_noEntityManager_assertException.
@Test
public void testAddPolicyToGroup_noEntityManager_assertException() {
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
boolean exceptionOccured = false;
try {
dao.addPolicyUseToGroup(1234L, 5678L, CertPolicyUse.PRIVATE_RESOLVER, true, true);
} 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_addPolicyUseToGroupTest method testAddPolicyToGroup_errorInAdd_assertException.
@Test
public void testAddPolicyToGroup_errorInAdd_assertException() {
boolean exceptionOccured = false;
final EntityManager mgr = mock(EntityManager.class);
doThrow(new RuntimeException("Just Passing Through")).when(mgr).persist((CertPolicyGroupReltn) any());
final CertPolicyDaoImpl certDao = new CertPolicyDaoImpl() {
@Override
public CertPolicy getPolicyById(long id) throws ConfigurationStoreException {
return new CertPolicy();
}
@Override
public CertPolicyGroup getPolicyGroupById(long id) throws ConfigurationStoreException {
return new CertPolicyGroup();
}
};
certDao.setEntityManager(mgr);
final CertPolicyDaoImpl spyDao = spy(certDao);
try {
spyDao.addPolicyUseToGroup(1234L, 5678L, CertPolicyUse.PRIVATE_RESOLVER, true, true);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(spyDao, times(1)).getPolicyGroupById(1234);
verify(spyDao, times(1)).getPolicyById(5678);
verify(mgr, times(1)).persist((CertPolicyGroupReltn) any());
}
use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.
the class CertPolicyDaoImpl_associatePolicyGroupToDomainTest method testAssociatePolicyGroupToDomain_unknownDomain_assertException.
@Test
public void testAssociatePolicyGroupToDomain_unknownDomain_assertException() {
boolean exceptionOccured = false;
final EntityManager mgr = mock(EntityManager.class);
final DomainDao domainDao = mock(DomainDao.class);
final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
CertPolicyDaoImpl spyDao = spy(dao);
try {
spyDao.associatePolicyGroupToDomain(1234, 5678);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(new Long(1234));
verify(spyDao, never()).getPolicyGroupById(5678);
}
Aggregations