Search in sources :

Example 1 with CertificateServiceImpl

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

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

the class CertificateServiceTest method testAddCertificates.

/**
     * Test the addCertificates method.
     */
public void testAddCertificates() {
    final CertificateDao certificateDao = context.mock(CertificateDao.class);
    final Collection<Certificate> certificates = Arrays.asList(new Certificate());
    context.checking(new Expectations() {

        {
            oneOf(certificateDao).save(certificates.iterator().next());
        }
    });
    CertificateServiceImpl service = new CertificateServiceImpl();
    service.setDao(certificateDao);
    try {
        service.addCertificates(certificates);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateDao(org.nhindirect.config.store.dao.CertificateDao) CertificateServiceImpl(org.nhindirect.config.service.impl.CertificateServiceImpl) Certificate(org.nhindirect.config.store.Certificate)

Example 3 with CertificateServiceImpl

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

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

the class CertificateServiceTest method testSetCertificateStatusForOwner.

/**
     * Test the setCertificateStatusForOwner method.
     */
public void testSetCertificateStatusForOwner() {
    final CertificateDao certificateDao = context.mock(CertificateDao.class);
    final String owner = "beau";
    final EntityStatus status = EntityStatus.ENABLED;
    context.checking(new Expectations() {

        {
            oneOf(certificateDao).setStatus(owner, status);
        }
    });
    CertificateServiceImpl service = new CertificateServiceImpl();
    service.setDao(certificateDao);
    try {
        service.setCertificateStatusForOwner(owner, status);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateDao(org.nhindirect.config.store.dao.CertificateDao) EntityStatus(org.nhindirect.config.store.EntityStatus) CertificateServiceImpl(org.nhindirect.config.service.impl.CertificateServiceImpl)

Example 5 with CertificateServiceImpl

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

the class CertificateServiceTest method testRemoveCertificates.

/**
     * Test the removeCertificate method.
     */
public void testRemoveCertificates() {
    final CertificateDao certificateDao = context.mock(CertificateDao.class);
    final List<Long> certificateIds = Arrays.asList(7L, 8L);
    context.checking(new Expectations() {

        {
            oneOf(certificateDao).delete(certificateIds);
        }
    });
    CertificateServiceImpl service = new CertificateServiceImpl();
    service.setDao(certificateDao);
    try {
        service.removeCertificates(certificateIds);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateDao(org.nhindirect.config.store.dao.CertificateDao) CertificateServiceImpl(org.nhindirect.config.service.impl.CertificateServiceImpl)

Aggregations

Expectations (org.jmock.Expectations)8 CertificateServiceImpl (org.nhindirect.config.service.impl.CertificateServiceImpl)8 CertificateDao (org.nhindirect.config.store.dao.CertificateDao)8 Certificate (org.nhindirect.config.store.Certificate)5 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)4 ArrayList (java.util.ArrayList)1 EntityStatus (org.nhindirect.config.store.EntityStatus)1