Search in sources :

Example 11 with Anchor

use of org.nhindirect.config.store.Anchor 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");
    }
}
Also used : Expectations(org.jmock.Expectations) Anchor(org.nhindirect.config.store.Anchor) AnchorServiceImpl(org.nhindirect.config.service.impl.AnchorServiceImpl) EntityStatus(org.nhindirect.config.store.EntityStatus) AnchorDao(org.nhindirect.config.store.dao.AnchorDao)

Example 12 with Anchor

use of org.nhindirect.config.store.Anchor 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");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateGetOptions(org.nhindirect.config.service.impl.CertificateGetOptions) AnchorServiceImpl(org.nhindirect.config.service.impl.AnchorServiceImpl) Anchor(org.nhindirect.config.store.Anchor) AnchorDao(org.nhindirect.config.store.dao.AnchorDao)

Example 13 with Anchor

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

the class AnchorServiceTest method testGetOutgoingAnchors.

/**
     * Test the getIncomingAnchors method.
     */
public void testGetOutgoingAnchors() {
    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.getOutgoingAnchors(owner, certificateOptions);
        assertEquals("Output does not match expected", Collections.emptyList(), output);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateGetOptions(org.nhindirect.config.service.impl.CertificateGetOptions) AnchorServiceImpl(org.nhindirect.config.service.impl.AnchorServiceImpl) Anchor(org.nhindirect.config.store.Anchor) AnchorDao(org.nhindirect.config.store.dao.AnchorDao)

Example 14 with Anchor

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

the class AnchorServiceTest method testGetAnchor.

/**
     * Test the getAnchor method.
     */
public void testGetAnchor() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final String owner = "beau";
    final String thumbprint = "thumbprint";
    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 {
        Anchor output = service.getAnchor(owner, thumbprint, certificateOptions);
        assertEquals("Output does not match expected", null, output);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateGetOptions(org.nhindirect.config.service.impl.CertificateGetOptions) AnchorServiceImpl(org.nhindirect.config.service.impl.AnchorServiceImpl) Anchor(org.nhindirect.config.store.Anchor) AnchorDao(org.nhindirect.config.store.dao.AnchorDao)

Example 15 with Anchor

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

the class AnchorServiceImpl method getOutgoingAnchors.

/*
     * (non-Javadoc)
     * 
     * @see org.nhindirect.config.service.AnchorService#getOutgoingAnchors(java.lang.String, org.nhindirect.config.service.impl.CertificateGetOptions)
     */
public Collection<Anchor> getOutgoingAnchors(String owner, CertificateGetOptions options) throws ConfigurationServiceException {
    Collection<Anchor> anchors = getAnchorsForOwner(owner, options);
    if (anchors == null || anchors.size() == 0)
        return Collections.emptyList();
    Collection<Anchor> retList = new ArrayList<Anchor>();
    for (Anchor anchor : anchors) if (anchor.isOutgoing())
        retList.add(anchor);
    return retList;
}
Also used : Anchor(org.nhindirect.config.store.Anchor) ArrayList(java.util.ArrayList)

Aggregations

Anchor (org.nhindirect.config.store.Anchor)19 AnchorDao (org.nhindirect.config.store.dao.AnchorDao)10 ArrayList (java.util.ArrayList)9 Expectations (org.jmock.Expectations)9 AnchorServiceImpl (org.nhindirect.config.service.impl.AnchorServiceImpl)8 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)6 Transactional (org.springframework.transaction.annotation.Transactional)5 List (java.util.List)3 Query (javax.persistence.Query)3 Address (org.nhindirect.config.store.Address)2 CertPolicy (org.nhindirect.config.store.CertPolicy)2 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)2 Certificate (org.nhindirect.config.store.Certificate)2 DNSRecord (org.nhindirect.config.store.DNSRecord)2 Domain (org.nhindirect.config.store.Domain)2 Setting (org.nhindirect.config.store.Setting)2 TrustBundle (org.nhindirect.config.store.TrustBundle)2 AddressDao (org.nhindirect.config.store.dao.AddressDao)2 CertPolicyDao (org.nhindirect.config.store.dao.CertPolicyDao)2 CertificateDao (org.nhindirect.config.store.dao.CertificateDao)2