Search in sources :

Example 6 with CertificateServiceImpl

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

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

the class CertificateServiceTest method testRemoveCertificatesForOwner.

/**
     * Test the removeCertificatesForOwner method.
     */
public void testRemoveCertificatesForOwner() {
    final CertificateDao certificateDao = context.mock(CertificateDao.class);
    final String owner = "beau";
    context.checking(new Expectations() {

        {
            oneOf(certificateDao).delete(owner);
        }
    });
    CertificateServiceImpl service = new CertificateServiceImpl();
    service.setDao(certificateDao);
    try {
        service.removeCertificatesForOwner(owner);
    } 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)

Example 8 with CertificateServiceImpl

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