use of org.nhindirect.config.store.dao.DomainDao 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.store.dao.DomainDao 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.store.dao.DomainDao 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.store.dao.DomainDao in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_disassociateTrustBundlesFromDomainTest method testDisassociateTrustBundlesFromDomain_unknownErrorInRemove_assertException.
@Test
public void testDisassociateTrustBundlesFromDomain_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 TrustBundleDomainReltn tbd where tbd.domain = ?1")).thenReturn(deleteQuery);
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
final TrustBundleDaoImpl spyDao = spy(dao);
try {
spyDao.disassociateTrustBundlesFromDomain(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.DomainDao in project nhin-d by DirectProject.
the class TrustBundleDaoImpl_disassociateTrustBundlesFromDomainTest method testDisassociateTrustBundlesFromDomain_unknownDomain_assertException.
@Test
public void testDisassociateTrustBundlesFromDomain_unknownDomain_assertException() {
boolean exceptionOccured = false;
final EntityManager mgr = mock(EntityManager.class);
final DomainDao domainDao = mock(DomainDao.class);
final TrustBundleDaoImpl dao = new TrustBundleDaoImpl();
dao.setDomainDao(domainDao);
dao.setEntityManager(mgr);
TrustBundleDaoImpl spyDao = spy(dao);
try {
spyDao.disassociateTrustBundlesFromDomain(1234);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
verify(domainDao, times(1)).getDomain(new Long(1234));
}
Aggregations