use of gov.ca.cwds.rest.api.domain.PostedAddress in project API by ca-cwds.
the class AddressServiceTest method testCreateReturnsPostedClass.
@Override
@Test
public void testCreateReturnsPostedClass() throws Exception {
gov.ca.cwds.data.persistence.ns.Address toCreate = new gov.ca.cwds.data.persistence.ns.Address(1L, "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
Address request = new Address(toCreate);
when(addressDao.create(any(gov.ca.cwds.data.persistence.ns.Address.class))).thenReturn(toCreate);
PostedAddress postedAddress = addressService.create(request);
assertThat(postedAddress.getClass(), is(PostedAddress.class));
}
use of gov.ca.cwds.rest.api.domain.PostedAddress in project API by ca-cwds.
the class AddressServiceTest method testCreateReturnsCorrectEntity.
@Override
@Test
public void testCreateReturnsCorrectEntity() throws Exception {
gov.ca.cwds.data.persistence.ns.Address toCreate = new gov.ca.cwds.data.persistence.ns.Address(10L, "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
Address request = new Address(toCreate);
when(addressDao.create(any(gov.ca.cwds.data.persistence.ns.Address.class))).thenReturn(toCreate);
PostedAddress expected = new PostedAddress(10, "", "", "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
PostedAddress returned = addressService.create(request);
assertThat(returned, is(expected));
}
use of gov.ca.cwds.rest.api.domain.PostedAddress in project API by ca-cwds.
the class AddressService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedAddress create(Request request) {
assert request instanceof Address;
Address address = (Address) request;
gov.ca.cwds.data.persistence.ns.Address managed = new gov.ca.cwds.data.persistence.ns.Address(address, null, null);
managed = addressDao.create(managed);
return new PostedAddress(managed);
}
use of gov.ca.cwds.rest.api.domain.PostedAddress in project API by ca-cwds.
the class AddressServiceTest method testCreateExistsError.
@SuppressWarnings("javadoc")
@Test
public void testCreateExistsError() throws Exception {
gov.ca.cwds.data.persistence.ns.Address toCreate = new gov.ca.cwds.data.persistence.ns.Address((long) 1, "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
Address request = new Address(toCreate);
when(addressDao.create(any(gov.ca.cwds.data.persistence.ns.Address.class))).thenReturn(toCreate);
PostedAddress expected = new PostedAddress(1, "", "", "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
PostedAddress returned = addressService.create(request);
// String e = MAPPER.writeValueAsString(expected);
// System.out.println(e);
// String r = MAPPER.writeValueAsString(returned);
// System.out.println(r);
assertThat(returned, is(expected));
}
Aggregations