Search in sources :

Example 16 with Domain

use of org.nhindirect.config.store.Domain 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());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) TrustBundle(org.nhindirect.config.store.TrustBundle) Domain(org.nhindirect.config.store.Domain) File(java.io.File) TrustBundleDomainReltn(org.nhindirect.config.store.TrustBundleDomainReltn)

Example 17 with Domain

use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.

the class ConfigurationServiceTest method testAddAddress.

/**
     * Test the addAddress method.
     */
public void testAddAddress() throws Exception {
    final AddressService addressService = context.mock(AddressService.class);
    final Collection<Address> collection = Arrays.asList(new Address(new Domain("domain"), "address"));
    context.checking(new Expectations() {

        {
            oneOf(addressService).addAddress(collection);
        }
    });
    ConfigurationServiceImpl service = new ConfigurationServiceImpl();
    service.setAddressSvc(addressService);
    try {
        service.addAddress(collection);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) Address(org.nhindirect.config.store.Address) Domain(org.nhindirect.config.store.Domain) ConfigurationServiceImpl(org.nhindirect.config.service.impl.ConfigurationServiceImpl)

Example 18 with Domain

use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.

the class ConfigurationServiceTest method testUpdateDomain.

/**
     * Test the updateDomain method.
     */
public void testUpdateDomain() throws Exception {
    final DomainService domainService = context.mock(DomainService.class);
    final Domain domain = new Domain("domain");
    context.checking(new Expectations() {

        {
            oneOf(domainService).updateDomain(domain);
        }
    });
    ConfigurationServiceImpl service = new ConfigurationServiceImpl();
    service.setDomainSvc(domainService);
    try {
        service.updateDomain(domain);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) Domain(org.nhindirect.config.store.Domain) ConfigurationServiceImpl(org.nhindirect.config.service.impl.ConfigurationServiceImpl)

Example 19 with Domain

use of org.nhindirect.config.store.Domain 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 20 with Domain

use of org.nhindirect.config.store.Domain in project nhin-d by DirectProject.

the class ConfigurationServiceTest method testAddDomain.

/**
     * Test the addDomain method.
     */
public void testAddDomain() throws Exception {
    final DomainService domainService = context.mock(DomainService.class);
    final Domain domain = new Domain("domain");
    context.checking(new Expectations() {

        {
            oneOf(domainService).addDomain(domain);
        }
    });
    ConfigurationServiceImpl service = new ConfigurationServiceImpl();
    service.setDomainSvc(domainService);
    try {
        service.addDomain(domain);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) Domain(org.nhindirect.config.store.Domain) ConfigurationServiceImpl(org.nhindirect.config.service.impl.ConfigurationServiceImpl)

Aggregations

Domain (org.nhindirect.config.store.Domain)32 Transactional (org.springframework.transaction.annotation.Transactional)14 Query (javax.persistence.Query)10 Expectations (org.jmock.Expectations)10 ConfigurationStoreException (org.nhindirect.config.store.ConfigurationStoreException)10 TrustBundle (org.nhindirect.config.store.TrustBundle)9 NoResultException (javax.persistence.NoResultException)8 TrustBundleDomainReltn (org.nhindirect.config.store.TrustBundleDomainReltn)8 DomainDao (org.nhindirect.config.store.dao.DomainDao)7 ApplicationContext (org.springframework.context.ApplicationContext)7 File (java.io.File)5 DomainServiceImpl (org.nhindirect.config.service.impl.DomainServiceImpl)5 Address (org.nhindirect.config.store.Address)5 ArrayList (java.util.ArrayList)4 ConfigurationServiceImpl (org.nhindirect.config.service.impl.ConfigurationServiceImpl)4 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)4 CertPolicyGroupDomainReltn (org.nhindirect.config.store.CertPolicyGroupDomainReltn)3 AddressDao (org.nhindirect.config.store.dao.AddressDao)3 List (java.util.List)2 Anchor (org.nhindirect.config.store.Anchor)2