Search in sources :

Example 11 with CertPolicyDaoImpl

use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.

the class CertPolicyDaoImpl_getPoliciesTest method testGetPolices_exceptionInQuery_assertException.

@Test
public void testGetPolices_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.getPolicies();
    } catch (ConfigurationStoreException ex) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : EntityManager(javax.persistence.EntityManager) CertPolicyDaoImpl(org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl) Test(org.junit.Test)

Example 12 with CertPolicyDaoImpl

use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.

the class CertPolicyDaoImpl_getPolicyByIdTest method testGetPolicyById_noEntityManager_assertException.

@Test
public void testGetPolicyById_noEntityManager_assertException() {
    final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
    boolean exceptionOccured = false;
    try {
        dao.getPolicyById(1234);
    } catch (IllegalStateException ex) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : CertPolicyDaoImpl(org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl) Test(org.junit.Test)

Example 13 with CertPolicyDaoImpl

use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.

the class CertPolicyDaoImpl_getPolicyByIdTest method testGetPolicyById_exceptionInQuery_assertException.

@Test
public void testGetPolicyById_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.getPolicyById(1234);
    } catch (ConfigurationStoreException ex) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : EntityManager(javax.persistence.EntityManager) CertPolicyDaoImpl(org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl) Test(org.junit.Test)

Example 14 with CertPolicyDaoImpl

use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.

the class CertPolicyDaoImpl_getPolicyByNameTest method testGetPolicyByName_exceptionInQuery_assertException.

@Test
public void testGetPolicyByName_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.getPolicyByName("any");
    } catch (ConfigurationStoreException ex) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : EntityManager(javax.persistence.EntityManager) CertPolicyDaoImpl(org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl) Test(org.junit.Test)

Example 15 with CertPolicyDaoImpl

use of org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl in project nhin-d by DirectProject.

the class CertPolicyDaoImpl_getPolicyByNameTest method testGetPolicyByName_noEntityManager_assertException.

@Test
public void testGetPolicyByName_noEntityManager_assertException() {
    final CertPolicyDaoImpl dao = new CertPolicyDaoImpl();
    boolean exceptionOccured = false;
    try {
        dao.getPolicyByName("any");
    } catch (IllegalStateException ex) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : CertPolicyDaoImpl(org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)44 CertPolicyDaoImpl (org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl)44 EntityManager (javax.persistence.EntityManager)24 DomainDao (org.nhindirect.config.store.dao.DomainDao)10 Query (javax.persistence.Query)8 NoResultException (javax.persistence.NoResultException)3