Search in sources :

Example 6 with CertificateDao

use of org.nhindirect.config.store.dao.CertificateDao 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 7 with CertificateDao

use of org.nhindirect.config.store.dao.CertificateDao 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)

Example 8 with CertificateDao

use of org.nhindirect.config.store.dao.CertificateDao 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 9 with CertificateDao

use of org.nhindirect.config.store.dao.CertificateDao 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 10 with CertificateDao

use of org.nhindirect.config.store.dao.CertificateDao 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

CertificateDao (org.nhindirect.config.store.dao.CertificateDao)10 Expectations (org.jmock.Expectations)8 CertificateServiceImpl (org.nhindirect.config.service.impl.CertificateServiceImpl)8 Certificate (org.nhindirect.config.store.Certificate)7 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)4 ArrayList (java.util.ArrayList)3 Address (org.nhindirect.config.store.Address)2 Anchor (org.nhindirect.config.store.Anchor)2 CertPolicy (org.nhindirect.config.store.CertPolicy)2 CertPolicyGroup (org.nhindirect.config.store.CertPolicyGroup)2 DNSRecord (org.nhindirect.config.store.DNSRecord)2 Domain (org.nhindirect.config.store.Domain)2 Setting (org.nhindirect.config.store.Setting)2 TrustBundle (org.nhindirect.config.store.TrustBundle)2 AddressDao (org.nhindirect.config.store.dao.AddressDao)2 AnchorDao (org.nhindirect.config.store.dao.AnchorDao)2 CertPolicyDao (org.nhindirect.config.store.dao.CertPolicyDao)2 DNSDao (org.nhindirect.config.store.dao.DNSDao)2 DomainDao (org.nhindirect.config.store.dao.DomainDao)2 SettingDao (org.nhindirect.config.store.dao.SettingDao)2