use of org.nhindirect.config.store.TrustBundleDomainReltn in project nhin-d by DirectProject.
the class DomainService_realDataTest method testDeleteDomainById_associatedTrustBundle_assertDomainDeleted.
public void testDeleteDomainById_associatedTrustBundle_assertDomainDeleted() throws Exception {
File bundleLocation = new File("./src/test/resources/bundles/signedbundle.p7b");
final ApplicationContext ctx = ConfigServiceRunner.getSpringApplicationContext();
// add a bundle
TrustBundleService trustService = (TrustBundleService) ctx.getBean("trustBundleSvc");
final TrustBundle bundle = new TrustBundle();
bundle.setBundleName("Test Bundle");
bundle.setBundleURL(filePrefix + bundleLocation.getAbsolutePath());
trustService.addTrustBundle(bundle);
// add a domain
DomainService domainService = (DomainService) ctx.getBean("domainSvc");
Domain domain = new Domain();
domain.setDomainName("Test Domain");
domain.setStatus(EntityStatus.ENABLED);
domainService.addDomain(domain);
//associate domain to bundle
trustService.associateTrustBundleToDomain(domain.getId(), bundle.getId(), true, true);
// assert the association
Collection<TrustBundleDomainReltn> associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
assertEquals(1, associatedBundel.size());
// now delete the domain
domainService.removeDomainById(domain.getId());
assertEquals(0, domainService.getDomainCount());
boolean exceptionOccured = false;
try {
associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.TrustBundleDomainReltn in project nhin-d by DirectProject.
the class TrustBundleDaoImpl method getTrustBundlesByDomain.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
@Transactional(readOnly = true)
public Collection<TrustBundleDomainReltn> getTrustBundlesByDomain(long domainId) throws ConfigurationStoreException {
validateState();
// make sure the domain exists
final Domain domain = domainDao.getDomain(domainId);
if (domain == null)
throw new ConfigurationStoreException("Domain with id " + domainId + " does not exist");
Collection<TrustBundleDomainReltn> retVal = null;
try {
final Query select = entityManager.createQuery("SELECT tbd from TrustBundleDomainReltn tbd where tbd.domain = ?1");
select.setParameter(1, domain);
retVal = (Collection<TrustBundleDomainReltn>) select.getResultList();
if (retVal.size() == 0)
return Collections.emptyList();
for (TrustBundleDomainReltn reltn : retVal) {
if (!reltn.getTrustBundle().getTrustBundleAnchors().isEmpty())
for (TrustBundleAnchor anchor : reltn.getTrustBundle().getTrustBundleAnchors()) anchor.getData();
}
} catch (Exception e) {
throw new ConfigurationStoreException("Failed to execute trust bundle relation DAO query.", e);
}
return retVal;
}
use of org.nhindirect.config.store.TrustBundleDomainReltn in project nhin-d by DirectProject.
the class DomainService_realDataTest method testDeleteDomainByName_associatedTrustBundle_assertDomainDeleted.
@SuppressWarnings("deprecation")
public void testDeleteDomainByName_associatedTrustBundle_assertDomainDeleted() throws Exception {
File bundleLocation = new File("./src/test/resources/bundles/signedbundle.p7b");
final ApplicationContext ctx = ConfigServiceRunner.getSpringApplicationContext();
// add a bundle
TrustBundleService trustService = (TrustBundleService) ctx.getBean("trustBundleSvc");
final TrustBundle bundle = new TrustBundle();
bundle.setBundleName("Test Bundle");
bundle.setBundleURL(filePrefix + bundleLocation.getAbsolutePath());
trustService.addTrustBundle(bundle);
// add a domain
DomainService domainService = (DomainService) ctx.getBean("domainSvc");
Domain domain = new Domain();
domain.setDomainName("Test Domain");
domain.setStatus(EntityStatus.ENABLED);
domainService.addDomain(domain);
//associate domain to bundle
trustService.associateTrustBundleToDomain(domain.getId(), bundle.getId(), true, true);
// assert the association
Collection<TrustBundleDomainReltn> associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
assertEquals(1, associatedBundel.size());
// now delete the domain
domainService.removeDomain(domain.getDomainName());
assertEquals(0, domainService.getDomainCount());
boolean exceptionOccured = false;
try {
associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
} catch (ConfigurationStoreException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.config.store.TrustBundleDomainReltn in project nhin-d by DirectProject.
the class TrustBundleService_realDataTest method testAssociateDomainToBundle_incomingTrueOutgoingFalse_assertIncomingAndOutgoingFlags.
public void testAssociateDomainToBundle_incomingTrueOutgoingFalse_assertIncomingAndOutgoingFlags() throws Exception {
File bundleLocation = new File("./src/test/resources/bundles/signedbundle.p7b");
final ApplicationContext ctx = ConfigServiceRunner.getSpringApplicationContext();
// add a bundle
TrustBundleService trustService = (TrustBundleService) ctx.getBean("trustBundleSvc");
final TrustBundle bundle = new TrustBundle();
bundle.setBundleName("Test Bundle");
bundle.setBundleURL(filePrefix + bundleLocation.getAbsolutePath());
trustService.addTrustBundle(bundle);
// add a domain
DomainService domainService = (DomainService) ctx.getBean("domainSvc");
Domain domain = new Domain();
domain.setDomainName("Test Domain");
domain.setStatus(EntityStatus.ENABLED);
domainService.addDomain(domain);
//associate domain to bundle
trustService.associateTrustBundleToDomain(domain.getId(), bundle.getId(), true, false);
// assert the association
Collection<TrustBundleDomainReltn> associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
assertEquals(1, associatedBundel.size());
TrustBundleDomainReltn reltn = associatedBundel.iterator().next();
assertTrue(reltn.isIncoming());
assertFalse(reltn.isOutgoing());
}
use of org.nhindirect.config.store.TrustBundleDomainReltn in project nhin-d by DirectProject.
the class TrustBundleService_realDataTest method testAssociateDomainToBundle_incomingAndOutgoingTrue_assertIncomingAndOutgoingFlags.
public void testAssociateDomainToBundle_incomingAndOutgoingTrue_assertIncomingAndOutgoingFlags() throws Exception {
File bundleLocation = new File("./src/test/resources/bundles/signedbundle.p7b");
final ApplicationContext ctx = ConfigServiceRunner.getSpringApplicationContext();
// add a bundle
TrustBundleService trustService = (TrustBundleService) ctx.getBean("trustBundleSvc");
final TrustBundle bundle = new TrustBundle();
bundle.setBundleName("Test Bundle");
bundle.setBundleURL(filePrefix + bundleLocation.getAbsolutePath());
trustService.addTrustBundle(bundle);
// add a domain
DomainService domainService = (DomainService) ctx.getBean("domainSvc");
Domain domain = new Domain();
domain.setDomainName("Test Domain");
domain.setStatus(EntityStatus.ENABLED);
domainService.addDomain(domain);
//associate domain to bundle
trustService.associateTrustBundleToDomain(domain.getId(), bundle.getId(), true, true);
// assert the association
Collection<TrustBundleDomainReltn> associatedBundel = trustService.getTrustBundlesByDomain(domain.getId(), true);
assertEquals(1, associatedBundel.size());
TrustBundleDomainReltn reltn = associatedBundel.iterator().next();
assertTrue(reltn.isIncoming());
assertTrue(reltn.isOutgoing());
}
Aggregations