Search in sources :

Example 6 with DomainServiceImpl

use of org.nhindirect.config.service.impl.DomainServiceImpl 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 7 with DomainServiceImpl

use of org.nhindirect.config.service.impl.DomainServiceImpl 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 8 with DomainServiceImpl

use of org.nhindirect.config.service.impl.DomainServiceImpl 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 9 with DomainServiceImpl

use of org.nhindirect.config.service.impl.DomainServiceImpl 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

Expectations (org.jmock.Expectations)9 DomainServiceImpl (org.nhindirect.config.service.impl.DomainServiceImpl)9 DomainDao (org.nhindirect.config.store.dao.DomainDao)9 Domain (org.nhindirect.config.store.Domain)5 EntityStatus (org.nhindirect.config.store.EntityStatus)2 List (java.util.List)1