Search in sources :

Example 1 with AnchorServiceImpl

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

the class AnchorServiceTest method testAddAnchors.

/**
     * Test the addAnchors method.
     */
public void testAddAnchors() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final Collection<Anchor> anchors = Arrays.asList(new Anchor());
    context.checking(new Expectations() {

        {
            for (Anchor anchor : anchors) oneOf(anchorDao).add(anchor);
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        service.addAnchors(anchors);
    } 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) AnchorDao(org.nhindirect.config.store.dao.AnchorDao)

Example 2 with AnchorServiceImpl

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

the class AnchorServiceTest method testRemoveAnchors.

/**
     * Test the removeAnchor method.
     */
public void testRemoveAnchors() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final List<Long> anchorIds = Arrays.asList(7L, 8L);
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).delete(anchorIds);
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        service.removeAnchors(anchorIds);
    } 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 3 with AnchorServiceImpl

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

the class AnchorServiceTest method testListAnchors.

/**
     * Test the listAnchors method.
     */
public void testListAnchors() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final Long anchorId = 7L;
    final int maxResults = 7;
    final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).listAll();
            will(returnValue(Collections.<Anchor>emptyList()));
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        Collection<Anchor> output = service.listAnchors(anchorId, maxResults, 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 4 with AnchorServiceImpl

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

the class AnchorServiceTest method testGetAnchors.

/**
     * Test the getAnchors method.
     */
public void testGetAnchors() {
    final AnchorDao anchorDao = context.mock(AnchorDao.class);
    final List<Long> anchorIds = Arrays.asList(7L, 8L);
    final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
    context.checking(new Expectations() {

        {
            oneOf(anchorDao).listByIds(anchorIds);
            will(returnValue(Collections.<Long>emptyList()));
        }
    });
    AnchorServiceImpl service = new AnchorServiceImpl();
    service.setDao(anchorDao);
    try {
        Collection<Anchor> output = service.getAnchors(null, certificateOptions);
        assertNotNull("Output is null when passing a null param", output);
        assertEquals("Output does not match expected return value for a null param", Collections.emptyList(), output);
    } catch (Exception e) {
        fail("Exception thrown");
    }
    try {
        Collection<Anchor> output = service.getAnchors(Collections.<Long>emptyList(), certificateOptions);
        assertNotNull("Output is null when passing an empty collection", output);
        assertEquals("Output does not match expected return value for an empty collection", Collections.emptyList(), output);
    } catch (Exception e) {
        fail("Exception thrown");
    }
    try {
        Collection<Anchor> output = service.getAnchors(anchorIds, certificateOptions);
        assertNotNull("Output is null when using valid params", output);
        assertEquals("Output does not match mocked return value when using valid params", Collections.<Long>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 5 with AnchorServiceImpl

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

the class AnchorServiceTest method testGetIncomingAnchors.

/**
     * Test the getIncomingAnchors method.
     */
public void testGetIncomingAnchors() {
    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.getIncomingAnchors(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)

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