Search in sources :

Example 1 with CertificateGetOptions

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

the class ConfigurationServiceTest method testGetAnchorsForOwner.

/**
     * Test the getAnchorsForOwner method.
     */
public void testGetAnchorsForOwner() throws Exception {
    final AnchorService anchorService = context.mock(AnchorService.class);
    final String owner = "owner";
    final CertificateGetOptions options = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(anchorService).getAnchorsForOwner(owner, options);
        }
    });
    ConfigurationServiceImpl service = new ConfigurationServiceImpl();
    service.setAnchorSvc(anchorService);
    try {
        service.getAnchorsForOwner(owner, 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 2 with CertificateGetOptions

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

the class CertificateServiceTest method testListCertificates.

/**
     * Test the listCertificates method.
     */
public void testListCertificates() {
    final CertificateDao certificateDao = context.mock(CertificateDao.class);
    final Long certificateId = 7L;
    final int maxResults = 7;
    final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(certificateDao).list((String) null);
            will(returnValue(Collections.<Certificate>emptyList()));
        }
    });
    CertificateServiceImpl service = new CertificateServiceImpl();
    service.setDao(certificateDao);
    try {
        Collection<Certificate> output = service.listCertificates(certificateId, maxResults, certificateOptions);
        assertNotNull("Output is null when using valid params", output);
        assertEquals("Output does not match mocked return value when using valid params", 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) CertificateServiceImpl(org.nhindirect.config.service.impl.CertificateServiceImpl) Certificate(org.nhindirect.config.store.Certificate)

Example 3 with CertificateGetOptions

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

the class CertificateServiceTest method testGetCertificate.

/**
     * Test the getCertificate method.
     */
public void testGetCertificate() {
    final CertificateDao certificateDao = context.mock(CertificateDao.class);
    final String owner = "beau";
    final String thumbprint = "thumbprint";
    CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(certificateDao).load(owner, thumbprint);
        }
    });
    CertificateServiceImpl service = new CertificateServiceImpl();
    service.setDao(certificateDao);
    try {
        Certificate output = service.getCertificate(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) CertificateDao(org.nhindirect.config.store.dao.CertificateDao) CertificateServiceImpl(org.nhindirect.config.service.impl.CertificateServiceImpl) Certificate(org.nhindirect.config.store.Certificate)

Example 4 with CertificateGetOptions

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

the class CertificateServiceTest method testGetCertificatesForOwner.

/**
     * Test the getCertificatesForOwner method.
     */
public void testGetCertificatesForOwner() {
    final CertificateDao certificateDao = context.mock(CertificateDao.class);
    final String owner = "beau";
    final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(certificateDao).list(owner);
            will(returnValue(Collections.<Certificate>emptyList()));
        }
    });
    CertificateServiceImpl service = new CertificateServiceImpl();
    service.setDao(certificateDao);
    try {
        Collection<Certificate> output = service.getCertificatesForOwner(owner, certificateOptions);
        assertNotNull("Output is null when using valid params", output);
        assertEquals("Output does not match mocked return value when using valid params", 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) CertificateServiceImpl(org.nhindirect.config.service.impl.CertificateServiceImpl) Certificate(org.nhindirect.config.store.Certificate)

Example 5 with CertificateGetOptions

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

the class ConfigurationServiceTest method testGetCertificates.

/**
     * Test the getCertificates method.
     */
public void testGetCertificates() throws Exception {
    final CertificateService certificateService = context.mock(CertificateService.class);
    final Collection<Long> certIds = Arrays.asList(4L, 5L);
    final CertificateGetOptions certificateGetOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(certificateService).getCertificates(certIds, certificateGetOptions);
        }
    });
    ConfigurationServiceImpl service = new ConfigurationServiceImpl();
    service.setCertSvc(certificateService);
    try {
        service.getCertificates(certIds, 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)

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