Search in sources :

Example 11 with CertificateGetOptions

use of org.nhindirect.config.service.impl.CertificateGetOptions 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");
    }
}
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 12 with CertificateGetOptions

use of org.nhindirect.config.service.impl.CertificateGetOptions 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 CertificateGetOptions

use of org.nhindirect.config.service.impl.CertificateGetOptions 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 CertificateGetOptions

use of org.nhindirect.config.service.impl.CertificateGetOptions 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 CertificateGetOptions

use of org.nhindirect.config.service.impl.CertificateGetOptions in project nhin-d by DirectProject.

the class CertificateServiceTest method testGetCertificates.

/**
     * Test the getCertificates method.
     */
public void testGetCertificates() {
    final CertificateDao certificateDao = context.mock(CertificateDao.class);
    final Collection<Long> certificateIds = Arrays.asList(7L, 8L);
    final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(certificateDao).list(new ArrayList<Long>(certificateIds));
            will(returnValue(Collections.<Certificate>emptyList()));
        }
    });
    CertificateServiceImpl service = new CertificateServiceImpl();
    service.setDao(certificateDao);
    try {
        Collection<Certificate> output = service.getCertificates(certificateIds, certificateOptions);
        assertEquals("Output does not match expected", Collections.<Certificate>emptyList(), output);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateGetOptions(org.nhindirect.config.service.impl.CertificateGetOptions) CertificateDao(org.nhindirect.config.store.dao.CertificateDao) ArrayList(java.util.ArrayList) CertificateServiceImpl(org.nhindirect.config.service.impl.CertificateServiceImpl) Certificate(org.nhindirect.config.store.Certificate)

Aggregations

Expectations (org.jmock.Expectations)20 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)20 ConfigurationServiceImpl (org.nhindirect.config.service.impl.ConfigurationServiceImpl)10 AnchorServiceImpl (org.nhindirect.config.service.impl.AnchorServiceImpl)6 Anchor (org.nhindirect.config.store.Anchor)6 AnchorDao (org.nhindirect.config.store.dao.AnchorDao)6 CertificateServiceImpl (org.nhindirect.config.service.impl.CertificateServiceImpl)4 Certificate (org.nhindirect.config.store.Certificate)4 CertificateDao (org.nhindirect.config.store.dao.CertificateDao)4 ArrayList (java.util.ArrayList)1