Search in sources :

Example 6 with AnchorServiceImpl

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

the class AnchorServiceTest method testRemoveAnchorsForOwner.

/**
     * Test the removeAnchorsForOwner method.
     */
public void testRemoveAnchorsForOwner() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final String owner = "beau";
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).delete(owner);
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        service.removeAnchorsForOwner(owner);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) AnchorServiceImpl(org.nhindirect.config.service.impl.AnchorServiceImpl) AnchorDao(org.nhindirect.config.store.dao.AnchorDao)

Example 7 with AnchorServiceImpl

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

the class AnchorServiceTest method testSetAnchorStatusForOwner.

/**
     * Test the setAnchorStatusForOwner method.
     */
public void testSetAnchorStatusForOwner() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final String owner = "beau";
    final EntityStatus status = EntityStatus.ENABLED;
    final Anchor anchor = new Anchor();
    anchor.setOwner(owner);
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).setStatus(owner, status);
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        service.setAnchorStatusForOwner(owner, status);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) Anchor(org.nhindirect.config.store.Anchor) AnchorServiceImpl(org.nhindirect.config.service.impl.AnchorServiceImpl) EntityStatus(org.nhindirect.config.store.EntityStatus) AnchorDao(org.nhindirect.config.store.dao.AnchorDao)

Example 8 with AnchorServiceImpl

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

the class AnchorServiceTest method testGetAnchorsForOwner.

/**
     * Test the getAnchorsForOwner method.
     */
public void testGetAnchorsForOwner() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final String owner = "beau";
    final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    final List<String> owners = Arrays.asList(owner);
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).list(owners);
            will(returnValue(Collections.<Anchor>emptyList()));
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        Collection<Anchor> output = service.getAnchorsForOwner(owner, 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 9 with AnchorServiceImpl

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

the class AnchorServiceTest method testGetOutgoingAnchors.

/**
     * Test the getIncomingAnchors method.
     */
public void testGetOutgoingAnchors() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final String owner = "beau";
    final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    final List<String> owners = Arrays.asList(owner);
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).list(owners);
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        Collection<Anchor> output = service.getOutgoingAnchors(owner, certificateOptions);
        assertEquals("Output does not match expected", Collections.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 AnchorServiceImpl

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

the class AnchorServiceTest method testGetAnchor.

/**
     * Test the getAnchor method.
     */
public void testGetAnchor() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final String owner = "beau";
    final String thumbprint = "thumbprint";
    CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    final List<String> owners = Arrays.asList(owner);
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).list(owners);
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        Anchor output = service.getAnchor(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) 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)10 AnchorServiceImpl (org.nhindirect.config.service.impl.AnchorServiceImpl)10 AnchorDao (org.nhindirect.config.store.dao.AnchorDao)10 Anchor (org.nhindirect.config.store.Anchor)8 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)6 EntityStatus (org.nhindirect.config.store.EntityStatus)1