Search in sources :

Example 6 with CertificateGetOptions

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

the class ConfigurationServiceTest method testListCertificates.

/**
     * Test the listCertificates method.
     */
public void testListCertificates() throws Exception {
    final CertificateService certificateService = context.mock(CertificateService.class);
    final long lastCertificateId = 3L;
    final int maxResults = 3;
    final CertificateGetOptions options = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(certificateService).listCertificates(lastCertificateId, maxResults, options);
        }
    });
    ConfigurationServiceImpl service = new ConfigurationServiceImpl();
    service.setCertSvc(certificateService);
    try {
        service.listCertificates(lastCertificateId, maxResults, options);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateGetOptions(org.nhindirect.config.service.impl.CertificateGetOptions) ConfigurationServiceImpl(org.nhindirect.config.service.impl.ConfigurationServiceImpl)

Example 7 with CertificateGetOptions

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

the class ConfigurationServiceTest method testGetCertificate.

/**
     * Test the getCertificate method.
     */
public void testGetCertificate() throws Exception {
    final CertificateService certificateService = context.mock(CertificateService.class);
    final String owner = "owner";
    final String thumbprint = "thumbprint";
    final CertificateGetOptions certificateGetOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(certificateService).getCertificate(owner, thumbprint, certificateGetOptions);
        }
    });
    ConfigurationServiceImpl service = new ConfigurationServiceImpl();
    service.setCertSvc(certificateService);
    try {
        service.getCertificate(owner, thumbprint, certificateGetOptions);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateGetOptions(org.nhindirect.config.service.impl.CertificateGetOptions) ConfigurationServiceImpl(org.nhindirect.config.service.impl.ConfigurationServiceImpl)

Example 8 with CertificateGetOptions

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

the class ConfigurationServiceTest method testGetCertificatesForOwner.

/**
     * Test the getCertificatesForOwner method.
     */
public void testGetCertificatesForOwner() throws Exception {
    final CertificateService certificateService = context.mock(CertificateService.class);
    final String owner = "owner";
    final CertificateGetOptions certificateGetOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(certificateService).getCertificatesForOwner(owner, certificateGetOptions);
        }
    });
    ConfigurationServiceImpl service = new ConfigurationServiceImpl();
    service.setCertSvc(certificateService);
    try {
        service.getCertificatesForOwner(owner, certificateGetOptions);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateGetOptions(org.nhindirect.config.service.impl.CertificateGetOptions) ConfigurationServiceImpl(org.nhindirect.config.service.impl.ConfigurationServiceImpl)

Example 9 with CertificateGetOptions

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

the class AnchorServiceTest method testListAnchors.

/**
     * Test the listAnchors method.
     */
public void testListAnchors() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final Long anchorId = 7L;
    final int maxResults = 7;
    final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).listAll();
            will(returnValue(Collections.<Anchor>emptyList()));
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        Collection<Anchor> output = service.listAnchors(anchorId, maxResults, 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 10 with CertificateGetOptions

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

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