Search in sources :

Example 16 with DomainDao

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

the class DomainServiceTest method testGetDomainCount.

/**
     * Test the getDomainCount method.
     */
public void testGetDomainCount() {
    final DomainDao domainDao = context.mock(DomainDao.class);
    final int count = 7;
    context.checking(new Expectations() {

        {
            oneOf(domainDao).count();
            will(returnValue(count));
        }
    });
    DomainServiceImpl service = new DomainServiceImpl();
    service.setDao(domainDao);
    try {
        int output = service.getDomainCount();
        assertEquals("Output does not match expected", count, output);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) DomainDao(org.nhindirect.config.store.dao.DomainDao) DomainServiceImpl(org.nhindirect.config.service.impl.DomainServiceImpl)

Example 17 with DomainDao

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

the class DomainServiceTest method testSearchDomain.

/**
     * Test the searchDomain method.
     */
public void testSearchDomain() {
    final DomainDao domainDao = context.mock(DomainDao.class);
    final String domainName = "domain.com";
    final EntityStatus status = EntityStatus.ENABLED;
    final List<Domain> expected = Arrays.asList(new Domain());
    final List<Domain> expectedNull = null;
    context.checking(new Expectations() {

        {
            oneOf(domainDao).searchDomain(domainName, status);
            will(returnValue(expected));
            oneOf(domainDao).searchDomain(domainName, status);
            will(returnValue(expectedNull));
        }
    });
    DomainServiceImpl service = new DomainServiceImpl();
    service.setDao(domainDao);
    try {
        service.searchDomain(domainName, status);
        service.searchDomain(domainName, status);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) DomainDao(org.nhindirect.config.store.dao.DomainDao) EntityStatus(org.nhindirect.config.store.EntityStatus) DomainServiceImpl(org.nhindirect.config.service.impl.DomainServiceImpl) Domain(org.nhindirect.config.store.Domain)

Example 18 with DomainDao

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

the class DomainServiceTest method testGetDomains.

/**
     * Test the getDomains method.
     * 
     * TODO: This test needs to be improved.
     */
@SuppressWarnings("unchecked")
public void testGetDomains() {
    final DomainDao domainDao = context.mock(DomainDao.class);
    final Collection<String> domainNames = Arrays.asList("domain.com", "domain2.com");
    final EntityStatus status = EntityStatus.ENABLED;
    context.checking(new Expectations() {

        {
            oneOf(domainDao).getDomains(with(any(List.class)), with(any(EntityStatus.class)));
        }
    });
    DomainServiceImpl service = new DomainServiceImpl();
    service.setDao(domainDao);
    try {
        service.getDomains(domainNames, status);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) DomainDao(org.nhindirect.config.store.dao.DomainDao) EntityStatus(org.nhindirect.config.store.EntityStatus) List(java.util.List) DomainServiceImpl(org.nhindirect.config.service.impl.DomainServiceImpl)

Example 19 with DomainDao

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

the class DomainServiceTest method testAddDomain.

/**
     * Test the addDomain method.
     */
public void testAddDomain() {
    final DomainDao domainDao = context.mock(DomainDao.class);
    final Domain domain = new Domain();
    context.checking(new Expectations() {

        {
            oneOf(domainDao).add(domain);
        }
    });
    DomainServiceImpl service = new DomainServiceImpl();
    service.setDao(domainDao);
    try {
        service.addDomain(domain);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) DomainDao(org.nhindirect.config.store.dao.DomainDao) DomainServiceImpl(org.nhindirect.config.service.impl.DomainServiceImpl) Domain(org.nhindirect.config.store.Domain)

Example 20 with DomainDao

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

the class DomainServiceTest method testRemoveDomain.

/**
     * Test the removeDomain method.
     */
public void testRemoveDomain() {
    final DomainDao domainDao = context.mock(DomainDao.class);
    final String domain = "domain.com";
    context.checking(new Expectations() {

        {
            oneOf(domainDao).delete(domain);
        }
    });
    DomainServiceImpl service = new DomainServiceImpl();
    service.setDao(domainDao);
    try {
        service.removeDomain(domain);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) DomainDao(org.nhindirect.config.store.dao.DomainDao) DomainServiceImpl(org.nhindirect.config.service.impl.DomainServiceImpl)

Aggregations

DomainDao (org.nhindirect.config.store.dao.DomainDao)31 EntityManager (javax.persistence.EntityManager)20 Test (org.junit.Test)20 Query (javax.persistence.Query)14 CertPolicyDaoImpl (org.nhindirect.config.store.dao.impl.CertPolicyDaoImpl)10 TrustBundleDaoImpl (org.nhindirect.config.store.dao.impl.TrustBundleDaoImpl)10 Expectations (org.jmock.Expectations)9 DomainServiceImpl (org.nhindirect.config.service.impl.DomainServiceImpl)9 Domain (org.nhindirect.config.store.Domain)7 NoResultException (javax.persistence.NoResultException)4 ArrayList (java.util.ArrayList)2 Address (org.nhindirect.config.store.Address)2 Anchor (org.nhindirect.config.store.Anchor)2 CertPolicy (org.nhindirect.config.store.CertPolicy)2 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)2 Certificate (org.nhindirect.config.store.Certificate)2 DNSRecord (org.nhindirect.config.store.DNSRecord)2 EntityStatus (org.nhindirect.config.store.EntityStatus)2 Setting (org.nhindirect.config.store.Setting)2 TrustBundle (org.nhindirect.config.store.TrustBundle)2