use of org.nhindirect.config.service.impl.DomainServiceImpl in project nhin-d by DirectProject.
the class DomainServiceTest method testUpdateDomain.
/**
* Test the updateDomain method.
*/
public void testUpdateDomain() {
final DomainDao domainDao = context.mock(DomainDao.class);
final Domain domain = new Domain();
context.checking(new Expectations() {
{
oneOf(domainDao).update(domain);
}
});
DomainServiceImpl service = new DomainServiceImpl();
service.setDao(domainDao);
try {
service.updateDomain(domain);
service.updateDomain(null);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.service.impl.DomainServiceImpl in project nhin-d by DirectProject.
the class DomainServiceTest method testGetDomain.
/**
* Test the getDomain method.
*/
public void testGetDomain() {
final DomainDao domainDao = context.mock(DomainDao.class);
final long id = 7;
final Domain expected = new Domain();
final Domain expectedNull = null;
context.checking(new Expectations() {
{
oneOf(domainDao).getDomain(id);
will(returnValue(expected));
oneOf(domainDao).getDomain(id);
will(returnValue(expectedNull));
}
});
DomainServiceImpl service = new DomainServiceImpl();
service.setDao(domainDao);
try {
service.getDomain(id);
service.getDomain(id);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.service.impl.DomainServiceImpl in project nhin-d by DirectProject.
the class DomainServiceTest method testListDomains.
/**
* Test the listDomains method.
*/
public void testListDomains() {
final DomainDao domainDao = context.mock(DomainDao.class);
final String lastDomainName = "lastDomainName.com";
final int maxResults = 7;
final List<Domain> expected = Arrays.asList(new Domain());
final List<Domain> expectedNull = null;
context.checking(new Expectations() {
{
oneOf(domainDao).listDomains(lastDomainName, maxResults);
will(returnValue(expected));
oneOf(domainDao).listDomains(lastDomainName, maxResults);
will(returnValue(expectedNull));
}
});
DomainServiceImpl service = new DomainServiceImpl();
service.setDao(domainDao);
try {
service.listDomains(lastDomainName, maxResults);
service.listDomains(lastDomainName, maxResults);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.service.impl.DomainServiceImpl in project nhin-d by DirectProject.
the class DomainServiceTest method testRemoveDomainById.
/**
* Test the removeDomainById method.
*/
public void testRemoveDomainById() {
final DomainDao domainDao = context.mock(DomainDao.class);
final long domainId = 1;
context.checking(new Expectations() {
{
oneOf(domainDao).delete(domainId);
}
});
DomainServiceImpl service = new DomainServiceImpl();
service.setDao(domainDao);
try {
service.removeDomainById(domainId);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.service.impl.DomainServiceImpl 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");
}
}
Aggregations