Search in sources :

Example 1 with AddressServiceImpl

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

the class AddressServiceTest method testRemoveAddress.

/**
     * Test the removeAddress method.
     */
public void testRemoveAddress() {
    final AddressDao addressDao = context.mock(AddressDao.class);
    final String addressName = "beau@address.com";
    context.checking(new Expectations() {

        {
            oneOf(addressDao).delete(addressName);
        }
    });
    AddressServiceImpl service = new AddressServiceImpl();
    service.setDao(addressDao);
    try {
        service.removeAddress(addressName);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) AddressServiceImpl(org.nhindirect.config.service.impl.AddressServiceImpl) AddressDao(org.nhindirect.config.store.dao.AddressDao)

Example 2 with AddressServiceImpl

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

the class AddressServiceTest method testGetAddressCount.

/**
     * Test the getAddressCount method.
     */
public void testGetAddressCount() {
    final AddressDao addressDao = context.mock(AddressDao.class);
    final int count = 0;
    context.checking(new Expectations() {

        {
            oneOf(addressDao).count();
            will(returnValue(count));
        }
    });
    AddressServiceImpl service = new AddressServiceImpl();
    service.setDao(addressDao);
    try {
        int output = service.getAddressCount();
        assertEquals("Output does not match expected", count, output);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) AddressServiceImpl(org.nhindirect.config.service.impl.AddressServiceImpl) AddressDao(org.nhindirect.config.store.dao.AddressDao)

Example 3 with AddressServiceImpl

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

the class AddressServiceTest method testGetAddress.

/**
     * Test the getAddress method.
     */
public void testGetAddress() {
    final AddressDao addressDao = context.mock(AddressDao.class);
    final Collection<String> addresses = Arrays.asList("beau@healthdomain.com", "beau@helthdomain2.com");
    final EntityStatus status = EntityStatus.ENABLED;
    context.checking(new Expectations() {

        {
            oneOf(addressDao).listAddresses(with(equal(new ArrayList<String>(addresses))), with(same(status)));
        }
    });
    AddressServiceImpl service = new AddressServiceImpl();
    service.setDao(addressDao);
    try {
        service.getAddress(addresses, status);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) AddressServiceImpl(org.nhindirect.config.service.impl.AddressServiceImpl) ArrayList(java.util.ArrayList) EntityStatus(org.nhindirect.config.store.EntityStatus) AddressDao(org.nhindirect.config.store.dao.AddressDao)

Example 4 with AddressServiceImpl

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

the class AddressServiceTest method testUpdateAddress.

/**
     * Test the updateAddress method.
     */
public void testUpdateAddress() {
    final AddressDao addressDao = context.mock(AddressDao.class);
    final Address address = new Address();
    context.checking(new Expectations() {

        {
        // TODO
        }
    });
    AddressServiceImpl service = new AddressServiceImpl();
    service.setDao(addressDao);
    try {
        service.updateAddress(address);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) AddressServiceImpl(org.nhindirect.config.service.impl.AddressServiceImpl) Address(org.nhindirect.config.store.Address) AddressDao(org.nhindirect.config.store.dao.AddressDao)

Example 5 with AddressServiceImpl

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

the class AddressServiceTest method testAddAddress.

/**
     * Test the addAddress method.
     */
public void testAddAddress() {
    final AddressDao addressDao = context.mock(AddressDao.class);
    final Collection<Address> addresses = Arrays.asList(new Address(new Domain("healthdomain.com"), "beau@healthdomain.com"), new Address(new Domain("healthdomain2.com"), "beau@healthdomain2.com"));
    context.checking(new Expectations() {

        {
        // TODO
        }
    });
    AddressServiceImpl service = new AddressServiceImpl();
    service.setDao(addressDao);
    try {
        service.addAddress(addresses);
    } catch (Exception e) {
        fail("Exception thrown");
    }
}
Also used : Expectations(org.jmock.Expectations) AddressServiceImpl(org.nhindirect.config.service.impl.AddressServiceImpl) Address(org.nhindirect.config.store.Address) Domain(org.nhindirect.config.store.Domain) AddressDao(org.nhindirect.config.store.dao.AddressDao)

Aggregations

Expectations (org.jmock.Expectations)6 AddressServiceImpl (org.nhindirect.config.service.impl.AddressServiceImpl)6 AddressDao (org.nhindirect.config.store.dao.AddressDao)6 Address (org.nhindirect.config.store.Address)2 ArrayList (java.util.ArrayList)1 Domain (org.nhindirect.config.store.Domain)1 EntityStatus (org.nhindirect.config.store.EntityStatus)1