use of org.nhindirect.config.store.dao.AnchorDao in project nhin-d by DirectProject.
the class AnchorServiceTest method testGetAnchors.
/**
* Test the getAnchors method.
*/
public void testGetAnchors() {
final AnchorDao anchorDao = context.mock(AnchorDao.class);
final List<Long> anchorIds = Arrays.asList(7L, 8L);
final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
context.checking(new Expectations() {
{
oneOf(anchorDao).listByIds(anchorIds);
will(returnValue(Collections.<Long>emptyList()));
}
});
AnchorServiceImpl service = new AnchorServiceImpl();
service.setDao(anchorDao);
try {
Collection<Anchor> output = service.getAnchors(null, certificateOptions);
assertNotNull("Output is null when passing a null param", output);
assertEquals("Output does not match expected return value for a null param", Collections.emptyList(), output);
} catch (Exception e) {
fail("Exception thrown");
}
try {
Collection<Anchor> output = service.getAnchors(Collections.<Long>emptyList(), certificateOptions);
assertNotNull("Output is null when passing an empty collection", output);
assertEquals("Output does not match expected return value for an empty collection", Collections.emptyList(), output);
} catch (Exception e) {
fail("Exception thrown");
}
try {
Collection<Anchor> output = service.getAnchors(anchorIds, certificateOptions);
assertNotNull("Output is null when using valid params", output);
assertEquals("Output does not match mocked return value when using valid params", Collections.<Long>emptyList(), output);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.store.dao.AnchorDao in project nhin-d by DirectProject.
the class AnchorServiceTest method testGetIncomingAnchors.
/**
* Test the getIncomingAnchors method.
*/
public void testGetIncomingAnchors() {
final AnchorDao anchorDao = context.mock(AnchorDao.class);
final String owner = "beau";
final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
final List<String> owners = Arrays.asList(owner);
context.checking(new Expectations() {
{
oneOf(anchorDao).list(owners);
}
});
AnchorServiceImpl service = new AnchorServiceImpl();
service.setDao(anchorDao);
try {
Collection<Anchor> output = service.getIncomingAnchors(owner, certificateOptions);
assertEquals("Output does not match expected", Collections.emptyList(), output);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.store.dao.AnchorDao in project nhin-d by DirectProject.
the class AnchorServiceTest method testRemoveAnchorsForOwner.
/**
* Test the removeAnchorsForOwner method.
*/
public void testRemoveAnchorsForOwner() {
final AnchorDao anchorDao = context.mock(AnchorDao.class);
final String owner = "beau";
context.checking(new Expectations() {
{
oneOf(anchorDao).delete(owner);
}
});
AnchorServiceImpl service = new AnchorServiceImpl();
service.setDao(anchorDao);
try {
service.removeAnchorsForOwner(owner);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.store.dao.AnchorDao in project nhin-d by DirectProject.
the class AnchorServiceTest method testSetAnchorStatusForOwner.
/**
* Test the setAnchorStatusForOwner method.
*/
public void testSetAnchorStatusForOwner() {
final AnchorDao anchorDao = context.mock(AnchorDao.class);
final String owner = "beau";
final EntityStatus status = EntityStatus.ENABLED;
final Anchor anchor = new Anchor();
anchor.setOwner(owner);
context.checking(new Expectations() {
{
oneOf(anchorDao).setStatus(owner, status);
}
});
AnchorServiceImpl service = new AnchorServiceImpl();
service.setDao(anchorDao);
try {
service.setAnchorStatusForOwner(owner, status);
} catch (Exception e) {
fail("Exception thrown");
}
}
use of org.nhindirect.config.store.dao.AnchorDao in project nhin-d by DirectProject.
the class AnchorServiceTest method testGetAnchorsForOwner.
/**
* Test the getAnchorsForOwner method.
*/
public void testGetAnchorsForOwner() {
final AnchorDao anchorDao = context.mock(AnchorDao.class);
final String owner = "beau";
final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
final List<String> owners = Arrays.asList(owner);
context.checking(new Expectations() {
{
oneOf(anchorDao).list(owners);
will(returnValue(Collections.<Anchor>emptyList()));
}
});
AnchorServiceImpl service = new AnchorServiceImpl();
service.setDao(anchorDao);
try {
Collection<Anchor> output = service.getAnchorsForOwner(owner, certificateOptions);
assertNotNull("Output is null when passing valid params", output);
assertEquals("Output does not match mocked return value when using valid params", Collections.<Anchor>emptyList(), output);
} catch (Exception e) {
fail("Exception thrown");
}
}
Aggregations